Prompt
How do I isolate workloads between teams in Kubernetes?
Latest observation
To isolate workloads between teams in Kubernetes, use layered isolation—Kubernetes doesn’t give perfect tenant isolation by default, so combine namespace, network, access, and compute boundaries.
1) Put each team in its own namespace
Use Namespaces as the basic administrative boundary.
- Separate team resources into
team-a,team-b, etc. - Apply ResourceQuotas and LimitRanges per namespace.
- Use RBAC so teams can only manage their own namespace.
Example:
apiVersion: v1
kind: Namespace
metadata:
name: team-a
2) Restrict access with RBAC
Give users/service accounts only the permissions they need.
- Team admins: full access only within their namespace
- Developers: read/write to workloads in their namespace
- No cluster-wide permissions unless necessary
Typical approach:
Role+RoleBindingfor namespace-scoped access- Avoid
ClusterRoleBindingunless required
3) Enforce network isolation
Use NetworkPolicies to control which pods can talk to each other.
- Default-deny traffic in each namespace
- Allow only required ingress/egress
- Restrict cross-team communication explicitly
Example default-deny:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny
namespace: team-a
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
Then add allow rules for needed traffic.
Note: NetworkPolicies require a CNI plugin that supports them (e.g. Calico, Cilium, Weave).
4) Limit compute and storage usage
Prevent one team from consuming all cluster resources.
- ResourceQuota: cap CPU, memory, pods, PVCs, etc.
- LimitRange: set default min/max requests and limits
- Use separate storage classes or PVC quotas if needed
Example:
apiVersion: v1
kind: ResourceQuota
metadata:
name: team-a-quota
namespace: team-a
spec:
hard:
requests.cpu: "4"
requests.memory: 8Gi
limits.cpu: "8"
limits.memory: 16Gi
pods: "20"
5) Separate sensitive workloads with node isolation
For stronger isolation, keep workloads on different nodes.
Options:
- nodeSelector / nodeAffinity to pin workloads to dedicated node pools
- Taints and tolerations so only specific teams/workloads can run there
- Separate node pools for production vs non-production, or team-specific pools
Example taint:
kubectl taint nodes node1 team=team-a:NoSchedule
Then workloads need a toleration to run there.
6) Use Pod Security controls
Prevent privilege escalation and risky pod specs.
- Enforce Pod Security Standards (
restricted,baseline,privileged) - Prefer
restrictedfor team namespaces - Disallow privileged containers, host networking, hostPath, etc.
7) Isolate service accounts and secrets
- Use one ServiceAccount per app or workload
- Don’t share secrets across teams
- Use external secret managers if possible
- Restrict secret read permissions with RBAC
8) Consider stronger isolation for high-trust boundaries
If teams have very different trust levels or compliance requirements, namespace isolation may not be enough. Consider:
- Separate clusters
- Separate node pools with hardened configs
- Sandboxing runtimes like gVisor or Kata Containers
- Admission control policies (OPA Gatekeeper or Kyverno)
Recommended baseline pattern
For most organizations:
- One namespace per team
- RBAC limited to that namespace
- Default-deny NetworkPolicies
- ResourceQuota + LimitRange
- Pod Security
restricted - Dedicated node pools for sensitive workloads
When to use separate clusters
Use separate clusters if you need:
- Strong isolation between business units
- Regulatory/compliance separation
- Different Kubernetes versions or add-ons
- Reduced blast radius for failures
If you want, I can also give you:
- a sample namespace isolation setup
- a YAML bundle for RBAC + quotas + network policy
- or a best-practice team isolation checklist.