Configure workspace network isolation
Turn on network isolation for a workspace, then open the ingress and egress paths its agents need.
Prerequisites
Section titled “Prerequisites”- A workspace.
- A cluster whose CNI enforces NetworkPolicy.
Enable isolation
Section titled “Enable isolation”-
Set
isolatein the Workspace spec.spec:networkPolicy:isolate: true
The controller creates the policy in the workspace namespace. The rules the policy contains by default are in the Workspace reference.
Open a path
Section titled “Open a path”Add rules under the same networkPolicy block. Each rule is a list of peers and an optional list of ports.
-
Allow ingress from an ingress controller.
spec:networkPolicy:isolate: trueallowFrom:- peers:- namespaceSelector:matchLabels:kubernetes.io/metadata.name: ingress-nginx -
Allow egress to an internal service. The CIDR and ports below are examples.
spec:networkPolicy:isolate: trueallowTo:- peers:- ipBlock:cidr: 10.0.0.0/8ports:- protocol: TCPport: 5432
Restrict external access
Section titled “Restrict external access”To drop the rule that lets agents reach public addresses, set allowExternalAPIs: false, then list the destinations that remain. The CIDR below is an example.
spec: networkPolicy: isolate: true allowExternalAPIs: false allowTo: - peers: - ipBlock: cidr: 104.18.0.0/16 ports: - protocol: TCP port: 443With allowExternalAPIs: false, agents cannot reach their LLM provider unless you add its address under allowTo.
Reach private networks in development
Section titled “Reach private networks in development”To let agents call a service on a private network, such as a local Ollama, set allowPrivateNetworks: true. It removes the 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 exclusions from the external rule. Link-local 169.254.0.0/16, where the node’s cloud metadata service answers, stays excluded either way.
spec: networkPolicy: isolate: true allowPrivateNetworks: trueIn production, use an allowTo rule for each service instead.
Turn isolation off
Section titled “Turn isolation off”Set isolate: false or remove the networkPolicy block. The controller deletes the NetworkPolicy.
Verify
Section titled “Verify”Confirm the controller created the policy.
kubectl get networkpolicy -n omnia-customer-supportThe list contains workspace-customer-support-isolation. The name is workspace-<workspace name>-isolation.
Troubleshooting
Section titled “Troubleshooting”Agents cannot reach an API or service
Section titled “Agents cannot reach an API or service”-
Confirm the policy exists and read its rules.
Terminal window kubectl describe networkpolicy workspace-customer-support-isolation -n omnia-customer-support -
Check whether
allowExternalAPIs: falseremoved the rule you were relying on. -
Add an
allowTorule for the destination. -
Test from inside the namespace.
Terminal window kubectl run -n omnia-customer-support debug --rm -it --image=busybox -- sh
Ingress traffic does not reach agents
Section titled “Ingress traffic does not reach agents”- Add the ingress controller’s namespace to
allowFrom, as above. - Confirm that namespace carries the label your
matchLabelsselects. Kubernetes setskubernetes.io/metadata.nameon every namespace. - If you set
portson the rule, confirm they include the port the agent listens on.
Related pages
Section titled “Related pages”- Manage workspaces
- Workspace reference: every field and the rule structures
- Multi-tenancy architecture: why the policy is shaped this way