Multi-tenancy allows multiple teams or customers to share a Kubernetes cluster. Proper isolation is critical to prevent security breaches between tenants.

Multi-Tenancy Models

Namespace-based

Soft isolation using namespaces with RBAC and network policies.

Virtual Cluster

Stronger isolation with virtual control planes (vcluster).

Dedicated Clusters

Complete isolation with separate clusters per tenant.

Namespace Isolation

RBAC

YAML
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: tenant-a
  name: tenant-admin
rules:
- apiGroups: ["*"]
  resources: ["*"]
  verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  namespace: tenant-a
  name: tenant-a-admins
subjects:
- kind: Group
  name: tenant-a-admins
roleRef:
  kind: Role
  name: tenant-admin
Click to expand and view more

Network Policies

YAML
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: deny-cross-namespace
  namespace: tenant-a
spec:
  podSelector: {}
  policyTypes:
  - Ingress
  - Egress
  ingress:
  - from:
    - namespaceSelector:
        matchLabels:
          name: tenant-a
  egress:
  - to:
    - namespaceSelector:
        matchLabels:
          name: tenant-a
Click to expand and view more

Resource Quotas

YAML
apiVersion: v1
kind: ResourceQuota
metadata:
  name: tenant-quota
  namespace: tenant-a
spec:
  hard:
    requests.cpu: "10"
    requests.memory: 20Gi
    limits.cpu: "20"
    limits.memory: 40Gi
    pods: "50"
Click to expand and view more

Hierarchical Namespaces

Use HNC for namespace hierarchies:

YAML
apiVersion: hnc.x-k8s.io/v1alpha2
kind: SubnamespaceAnchor
metadata:
  name: team-frontend
  namespace: tenant-a
Click to expand and view more

Virtual Clusters

For stronger isolation:

BASH
vcluster create tenant-a -n host-namespace
Click to expand and view more

Benefits:

Security Checklist

Multi-tenancy requires defense in depth across all layers.

Start searching

Enter keywords to search articles

↑↓
ESC
⌘K Shortcut