NetworkPolicy, deployed as a Helm service in each environment. You don’t need any cluster-wide permission, and the policy follows the environment: it is cloned with it and deleted with it.
How it works
The policy is a plain Kubernetes object, deployed with the genericraw Helm chart. It allows incoming traffic only from:
- pods in the same namespace (the same environment)
- the Qovery system namespaces, so public traffic coming through the cluster gateway still reaches your services
Prerequisites
- An environment running on a cluster that enforces NetworkPolicies. Qovery-managed clusters do this out of the box.
- On a self-managed cluster, enforcement depends on your CNI. Cilium and Calico enforce NetworkPolicies; some CNIs, such as Flannel used alone, accept the objects but ignore them. Check your CNI before relying on this guide.
Step 1: Add the Helm Repository
In the Qovery console, open Organization settings → Helm Repositories → Add repository and enter:- Kind: HTTPS
- Repository URL:
https://bedag.github.io/helm-charts
Step 2: Create the Policy Service
In the environment you want to isolate, create a Helm service:- Name:
tenant-isolation - Helm source: Helm repository, the repository from Step 1
- Chart name:
raw - Version:
2.0.2. Pin the version. - Allow cluster-wide resources: disabled. A NetworkPolicy lives in the environment namespace.
podSelector: {} selects every pod of the namespace, so the policy applies to all services of the environment, including the ones you add later.
The allowed system namespaces:
Step 3: Deploy the Policy Before Your Services
Move thetenant-isolation service to a deployment stage that runs before your applications, for example a new first stage. Your services are then never running without the policy, including in new environments.
Deploy the environment.
Step 4: Apply It to Every Environment
Isolation only holds if every environment has the policy. An environment without it accepts traffic from all the others.- Add the service to the environment you clone to create new environments, so every clone gets it.
- For Preview Environments, add it to the blueprint environment.
- Repeat Steps 2 and 3 in existing environments.
Step 5: Check the Isolation
Open a shell on a service of environment A, then call a service of the same environment and a service of environment B by their internal hostname:000). Public URLs of both environments keep responding.
The shell runs in your service’s container, so the image needs curl (or wget).
Optional: Restrict Outgoing Traffic
The policy above controls incoming traffic. Each environment blocks the others, so this is enough to isolate environments from each other. To also stop the services of an environment from opening connections to other environments, add an egress section. Egress rules depend on the cluster network, so the values differ by cloud provider.- AWS EKS
- Other managed clusters
except.Qovery doesn’t set a custom Service CIDR, so EKS uses one of the two defaults above. To check yours, look at the cluster IP of the kubernetes Service in the default namespace (kubectl get svc kubernetes -n default): it belongs to the Service CIDR.Qovery creates the cluster VPC with 10.0.0.0/16 unless you set a Custom VPC Subnet on the cluster. If you did, or if the cluster uses an existing VPC, replace 10.0.0.0/16 with the VPC CIDR shown in the AWS console.Remove the Isolation
Delete thetenant-isolation Helm service, then redeploy the environment.
Don’t empty the resources list instead: a chart that renders no object makes the deployment fail.
Troubleshooting
The public URL of a service times out after deploying the policy
The public URL of a service times out after deploying the policy
The
qovery namespace is missing from the allowed namespaces. The cluster gateway runs there.A service of another environment is still reachable
A service of another environment is still reachable
- On AWS EKS, connections opened before the policy keep working: redeploy the services of the protected environment.
- Check that the protected environment has the
tenant-isolationservice deployed. The policy protects the environment it is deployed in, not the environment the traffic comes from. - On a self-managed cluster, check that your CNI enforces NetworkPolicies.
The deployment fails with 'cluster-wide resource should be allowed'
The deployment fails with 'cluster-wide resource should be allowed'
The
resources list is empty or a manifest has no metadata. To remove the policy, delete the Helm service instead.Services can't resolve hostnames after adding an egress section
Services can't resolve hostnames after adding an egress section
The DNS rule to
kube-system on port 53 is missing.Services can't reach their database after adding an egress section
Services can't reach their database after adding an egress section
The database sits inside the cluster network, which the
except list blocks. Add an ipBlock rule to the database subnet.Related
- Filter Outbound Traffic with an Egress Proxy: restrict the domains a service can call.
- Helm: Helm service configuration.
- Deployment pipeline: deployment stages.