Skip to content

feat(templates): add optional NetworkPolicy resources for production hardening - #164

Open
eddysella wants to merge 1 commit into
supabase-community:mainfrom
eddysella:feat/network-policies
Open

feat(templates): add optional NetworkPolicy resources for production hardening#164
eddysella wants to merge 1 commit into
supabase-community:mainfrom
eddysella:feat/network-policies

Conversation

@eddysella

Copy link
Copy Markdown

What kind of change does this PR introduce?

Feature — production hardening

What is the current behavior?

All pods can communicate freely with each other and external services. There is no network-level isolation between Supabase components, which means a compromised pod could reach any other service in the namespace.

What is the new behavior?

Adds optional Kubernetes NetworkPolicy templates for auth, kong, and rest services, controlled by a single toggle: networkPolicies.enabled (default: false). Existing deployments are unaffected unless explicitly opted in.

When enabled, each policy enforces least-privilege network access:

Service Ingress Egress
Auth Kong only (port 9999) DNS, PostgreSQL (5432), SMTP (587/465), HTTPS (443 for OAuth)
Kong Any namespace (port 8000) DNS, all enabled Supabase services on their configured ports
REST Kong only (port 3000) DNS, PostgreSQL (5432)

Enable with:

networkPolicies:
  enabled: true

Additional context

This is a defense-in-depth measure for production Kubernetes deployments. The policies are intentionally scoped to the three most security-sensitive services (API gateway, authentication, and database API). Additional services can be covered in follow-up PRs.

All service ports are read from service.<svc>.port values rather than hardcoded, ensuring compatibility with custom port configurations.

Adds Kubernetes NetworkPolicy templates for auth, kong, and rest
services, controlled by networkPolicies.enabled (default: false).

When enabled:
- Auth: ingress from Kong only, egress to DB/DNS/SMTP/HTTPS
- Kong: ingress from any namespace, egress to all enabled services
- REST: ingress from Kong only, egress to DB/DNS
@luizfelmach luizfelmach added the enhancement New feature or request label Apr 2, 2026
@eddysella

Copy link
Copy Markdown
Author

Any thoughts on this? @luizfelmach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants