examples/multitenancy/team-a.yaml packs the entire syllabus for this section into 74 lines: one namespace carrying every tenant guardrail the exam can test. Read it top to bottom before running anything, because every exercise below pokes at one of its controls.

needsmake up sec

Orientation

competency 1.3 · optimizing multi-tenancy resource usage

On its own, a namespace is just a folder. A tenant is a namespace wrapped in a stack of controls, where each layer closes a different gap, and can also be the exact thing that just rejected your pod. Notice the word "optimizing" in the competency: the exam cares about strong isolation that doesn't burn idle capacity, and about spotting which guardrail rejected a request at a glance.

The soft-to-hard isolation ladder

Multi-tenancy isn't binary. Soft isolation shares the control plane and worker nodes, separating teams with namespaces, quotas, policies, and RBAC (what this lab and most internal platforms run). Climb up for harder isolation: tainted dedicated node pools (no shared kernel), virtual control planes like vcluster (isolated API servers and CRDs), and finally separate clusters. Every rung trades extra idle capacity and operational overhead for a stronger boundary. Know the ladder and what each rung buys you, and you can answer any tenant-isolation design prompt cold.

The isolation stack, layer by layer

what rejects your pod, and with which message
  1. ResourceQuota caps the namespace total: requests.*, limits.*, object counts (pods: "20", services.loadbalancers: "1"), and per-class storage. The catch: once a quota tracks requests.cpu or limits.memory, it rejects any pod that omits them, which brings us straight to layer 2.
  2. LimitRange injects per-container defaults (default, defaultRequest) and enforces bounds (min, max, maxLimitRequestRatio). A bare pod arrives at the quota check with defaults already filled in, keeping onboarding smooth without weakening the quota.
  3. NetworkPolicy pairs a default-deny baseline with explicit allow rules. team-a allows same-namespace traffic and DNS to kube-dns, and blocks everything else. Because rules are additive allow-lists, you loosen by adding and tighten by removing, the exact quirk our netpol break drill exploits.
  4. Pod Security Standards labels on the namespace (enforce: baseline, warn and audit: restricted here). We dive deep into these in section 5.3.
  5. RBAC scoping: a Role and RoleBinding giving dev-a real permissions inside team-a and zero access anywhere else. Full breakdown in section 5.1.
Admission order decides who rejects you

Admission always runs mutating plugins first (LimitRanger injects defaults, Kyverno mutates labels) and validating plugins second (PSS, ResourceQuota, Kyverno/Gatekeeper validate). That means a pod with no resources block passes cleanly because LimitRange fills them in first, so a validating policy requiring requests will never reject a pod inside a namespace that has a LimitRange. Section 5.2 builds a whole exercise around this; for now, remember: mutation can satisfy a validation rule the user never wrote.

Decoding the refusal message

Message containsWho refusedFix direction
exceeded quota: team-a-quota, requested: …, used: …, limited: …ResourceQuotatrim requests, reduce replicas, or raise the quota
maximum cpu usage per Container is 1, but limit is 2LimitRangebring container values inside the bounds
violates PodSecurity "baseline:latest"PSS admissiontighten the pod's securityContext
admission webhook "…kyverno…" denied the requestpolicy enginesatisfy the policy or add an approved exception
is forbidden: User "dev-a" cannot create …RBACmissing Role rule, missing Binding, or wrong namespace

Recognizing the culprit from a single error line saves you from poking the wrong object under time pressure.

Run the admission math yourself: push replicas up to see which quota line hits the ceiling first, and watch what shifts when a pod declares explicit resources instead of inheriting LimitRange defaults:

Quota's hidden error location

ResourceQuota runs at pod admission, not Deployment admission. That means a Deployment applies cleanly while its ReplicaSet silently fails to create pods below the target count. Always check kubectl describe rs or namespace events rather than staring at the Deployment. PSS does the exact same thing (section 5.3). Recognizing this two-level indirection pays off across the entire exam.

Fairness beyond quota

the "optimizing" half of the competency

Quotas cap worst-case sprawl, but they don't make a shared cluster efficient. Four other mechanisms do the heavy lifting:

  • Priority and preemption: PriorityClass decides who stays standing when nodes fill up. Platform infrastructure (ingress, monitoring, CNI) must outrank tenant apps, because a tenant workload that can evict Prometheus can blind your whole cluster. Pair it with a scopeSelector quota so tenants can't sneak into the high-priority lane.
  • Overcommit ratios: setting limits comfortably above requests drives high density, at the risk of node OOMs if every tenant spikes simultaneously. Our lab's LimitRange (50m request / 200m limit) chooses a deliberate 4× burst ratio.
  • Tainted node pools: when workloads can't share a kernel, GPU, or software license, taint dedicated nodes and match them with nodeAffinity. The cost is stranded idle capacity inside each pool.
  • Idle reclamation: the gap between requested resources and actual usage is the hidden tax of multi-tenancy, and OpenCost puts a dollar figure on it in section 1.5. Optimizing multi-tenancy really means shrinking that gap without breaking your isolation guardrails.

Two practical pieces people often forget in exam prep: keep the default ServiceAccount powerless (so pods don't accidentally inherit API permissions), and quota objects that cost real money outside the cluster: LoadBalancers, PVCs, and NodePorts. That's why team-a caps services.loadbalancers at 1: quotas are a spend control as much as a fairness guardrail.

Quotas beyond CPU and memory

  • Object counts: count/<resource>.<group> caps any resource kind, including your own CRDs (count/widgets.example.com), alongside built-ins like pods, services, secrets, configmaps, persistentvolumeclaims, services.loadbalancers, and services.nodeports. These shield both etcd and your cloud bill.
  • Scopes: scopeSelector narrows a quota to BestEffort/NotBestEffort, Terminating/NotTerminating (pods with activeDeadlineSeconds), CrossNamespacePodAffinity, or specific PriorityClass names. A quota matching PriorityClass In [platform-critical] with pods: "0" cleanly locks tenants out of the platform lane.
  • Per-class storage: <class>.storageclass.storage.k8s.io/requests.storage and .../persistentvolumeclaims (section 1.3).
  • Ephemeral storage: requests.ephemeral-storage and limits.ephemeral-storage; container logs count here too, which is how a runaway logger gets evicted for disk pressure.

Keep the concrete field names handy: LimitRange.spec.limits[].maxLimitRequestRatio caps per-container burst ratios (4 means limits can't exceed 4× requests); PriorityClass and preemptionPolicy settle eviction ties; a PriorityClass-scoped quota fences off critical lanes; and OpenCost's per-namespace efficiency (1.5) exposes which teams are hoarding requests. Actual bin-packing belongs to the node autoscaler (1.2), which only ever looks at requests.

Tenancy models and the tools behind them

namespaces-as-a-service · virtual control planes · clusters · HNC, Capsule, vcluster

Kubernetes' official multi-tenancy guide divides isolation into control plane (namespaces, RBAC, quotas) and data plane (network policies, storage, sandboxing, node isolation), and compares two shared-cluster architectures: namespace-per-tenant vs. virtual control plane per tenant. Expect scenario prompts to use those exact terms.

ModelTenant getsCannot isolateCostTools
Namespace per tenant (namespaces-as-a-service)one or more namespaces with quota, LimitRange, NetworkPolicy, PSS, and RBACanything cluster-scoped: CRDs, StorageClasses, webhooks, ClusterRoles, API versionsnear zeroplain Kubernetes; HNC or Capsule at scale
Virtual control plane per tenantits own API server, CRDs, and cluster-scoped objects; pods still share worker nodesthe Linux kernel and node-level blast radius; cross-tenant sharing gets trickierone control plane pod per tenantvcluster
Cluster per tenanttotal isolation, optionally dedicated hardwarenothing, though you share nothing eitherfull duplication and fleet management overheadCluster API, managed cloud clusters

The three ecosystem tools to know by name

  • Hierarchical Namespace Controller (HNC): arranges namespaces into parent-child trees so RBAC, NetworkPolicies, and other objects automatically propagate downward (labeled hnc.x-k8s.io/inherited-from). Users with permissions in a parent can create subnamespaces (kubectl hns create dev -n team-a) without cluster-wide namespace creation rights. Tree labels (team-a.tree.hnc.x-k8s.io/depth) let NetworkPolicies target "the whole team," and HierarchicalResourceQuota caps an entire subtree (beta in HNC 1.1).
  • Capsule: introduces a cluster-scoped Tenant CRD grouping namespaces under an owner or group. Quotas, LimitRanges, NetworkPolicies, RBAC, allowed StorageClasses/IngressClasses, node selectors, and image registries defined once on the Tenant automatically stamp onto every namespace the owner creates, enforced by Capsule's admission webhook.
  • vcluster: runs a lightweight tenant control plane (API server, controller manager, and SQLite or etcd) inside a single pod in a host namespace, paired with a syncer that schedules the tenant's pods, Services, ConfigMaps, and Secrets down into the host cluster. Tenants install their own CRDs and webhooks freely. With shared nodes you get control-plane isolation; attach private nodes and it behaves like a full dedicated cluster.

Data-plane guardrails teams often forget

  • Storage: stick to dynamic provisioning, offer per-tenant StorageClasses where needed, and set reclaimPolicy: Delete on shared classes so one tenant's released PV can't accidentally rebind to another tenant.
  • Sandboxing: run untrusted workloads under a RuntimeClass (gVisor or Kata), since standard containers still share the host kernel.
  • Node isolation: taint a tenant's dedicated node pool and let a mutating webhook (or Kyverno mutate rule) inject the toleration and nodeAffinity automatically so devs never hand-write scheduling boilerplate.
  • DNS: CoreDNS answers cross-namespace lookups by default; add a CoreDNS policy plugin rule if your tenancy model forbids namespace discovery over DNS.
  • API Priority and Fairness: FlowSchema and PriorityLevelConfiguration keep one tenant's runaway controller from starving the API server for everyone else.
Decision rule

Match the model to what the tenant actually needs to own: just workloads → namespaces; their own CRDs and webhooks → a virtual control plane; their own kernel and upgrade schedule → a dedicated cluster. Pick the lightest rung that satisfies the real threat model.

Exercises

tick the dot when its check passes
kubectl -n team-a get resourcequota team-a-quota -o yaml   # read used vs hard
kubectl -n team-a create deploy filler --image=ghcr.io/nginxinc/nginx-unprivileged:1.27-alpine --replicas=25
kubectl -n team-a get rs -l app=filler -o jsonpath='{.items[0].status.replicas}'
kubectl -n team-a get events --sort-by=.lastTimestamp | grep -i quota | tail -3
outputcaptured 2026-08-26
$ kubectl -n team-a get resourcequota team-a-quota -o yaml   # read used vs hard
apiVersion: v1
kind: ResourceQuota
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"ResourceQuota","metadata":{"annotations":{},"name":"team-a-quota","namespace":"team-a"},"spec":{"hard":{"limits.cpu":"4","limits.memory":"8Gi","persistentvolumeclaims":"4","pods":"20","requests.cpu":"2","requests.memory":"4Gi","services.loadbalancers":"1"}}}
  creationTimestamp: "2026-08-27T02:06:44Z"
  name: team-a-quota
  namespace: team-a
  resourceVersion: "18561"
  uid: 1e256ecb-ab19-4f1f-bce7-0ae59563b845
spec:
  hard:
    limits.cpu: "4"
    limits.memory: 8Gi
    persistentvolumeclaims: "4"
    pods: "20"
    requests.cpu: "2"
    requests.memory: 4Gi
    services.loadbalancers: "1"
status:
  hard:
    limits.cpu: "4"
    limits.memory: 8Gi
    persistentvolumeclaims: "4"
    pods: "20"
    requests.cpu: "2"
    requests.memory: 4Gi
    services.loadbalancers: "1"
  used:
    limits.cpu: "0"
    limits.memory: "0"
    persistentvolumeclaims: "0"
    pods: "0"
    requests.cpu: "0"
    requests.memory: "0"
    services.loadbalancers: "0"
$ kubectl -n team-a create deploy filler --image=ghcr.io/nginxinc/nginx-unprivileged:1.27-alpine --replicas=25
Warning: would violate PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "nginx-unprivileged" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "nginx-unprivileged" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "nginx-unprivileged" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "nginx-unprivileged" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")
deployment.apps/filler created
$ kubectl -n team-a get rs -l app=filler -o jsonpath='{.items[0].status.replicas}'
20
$ kubectl -n team-a get events --sort-by=.lastTimestamp | grep -i quota | tail -3
21s         Warning   FailedCreate        replicaset/filler-6d6c49db66   Error creating: pods "filler-6d6c49db66-b9qs8" is forbidden: exceeded quota: team-a-quota, requested: limits.cpu=200m,pods=1, used: limits.cpu=4,pods=20, limited: limits.cpu=4,pods=20
21s         Warning   FailedCreate        replicaset/filler-6d6c49db66   Error creating: pods "filler-6d6c49db66-vlnj4" is forbidden: exceeded quota: team-a-quota, requested: limits.cpu=200m,pods=1, used: limits.cpu=4,pods=20, limited: limits.cpu=4,pods=20
11s         Warning   FailedCreate        replicaset/filler-6d6c49db66   (combined from similar events): Error creating: pods "filler-6d6c49db66-9ktm7" is forbidden: exceeded quota: team-a-quota, requested: limits.cpu=200m,pods=1, used: limits.cpu=4,pods=20, limited: limits.cpu=4,pods=20

Do the arithmetic before peeking: the LimitRange injects 50m requests and 200m limits per container, so requests.cpu: "2" allows 40 pods but limits.cpu: "4" allows exactly 20, tying with pods: "20". Whichever line the event names, you should be able to derive why.

verify: replicas stall below 25, and the ReplicaSet events say exactly which quota line refused. The skill is reading exceeded quota: team-a-quota, requested: ..., used: ..., limited: ... fluently. Clean up with kubectl -n team-a delete deploy filler.

Run a pod with no resources block and read what it got:

kubectl -n team-a run bare --image=busybox:1.37 --restart=Never -- sleep 300
kubectl -n team-a get pod bare -o jsonpath='{.spec.containers[0].resources}' | jq
outputcaptured 2026-08-26
$ kubectl -n team-a run bare --image=busybox:1.37 --restart=Never -- sleep 300
Warning: would violate PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "bare" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "bare" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "bare" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "bare" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")
pod/bare created
$ kubectl -n team-a get pod bare -o jsonpath='{.spec.containers[0].resources}' | jq
{
  "limits": {
    "cpu": "200m",
    "memory": "256Mi"
  },
  "requests": {
    "cpu": "50m",
    "memory": "64Mi"
  }
}
verify: requests 50m/64Mi and limits 200m/256Mi, injected by team-a-limits, matching nothing you typed. Then try to exceed the max: set limits.cpu: "2" on a pod and confirm admission rejects it with a LimitRange error, not a quota error.

team-b exists with the same guardrails:

kubectl -n team-b run web --image=ghcr.io/nginxinc/nginx-unprivileged:1.27-alpine --port=8080 --expose
kubectl -n team-a run poke --image=curlimages/curl:8.11.1 --restart=Never -- \
  curl -s -m 5 -o /dev/null -w '%{http_code}' http://web.team-b.svc:8080
kubectl -n team-a wait --for=jsonpath='{.status.phase}'=Failed pod/poke --timeout=60s \
  || kubectl -n team-a get pod poke -o jsonpath='{.status.containerStatuses[0].state.terminated.exitCode}'
outputcaptured 2026-08-26
$ kubectl -n team-b run web --image=ghcr.io/nginxinc/nginx-unprivileged:1.27-alpine --port=8080 --expose
Warning: would violate PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "web" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "web" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "web" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "web" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")
service/web created
pod/web created
$ kubectl -n team-a run poke --image=curlimages/curl:8.11.1 --restart=Never -- \
  curl -s -m 5 -o /dev/null -w '%{http_code}' http://web.team-b.svc:8080
Warning: would violate PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "poke" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "poke" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "poke" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "poke" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")
pod/poke created
$ kubectl -n team-a wait --for=jsonpath='{.status.phase}'=Failed pod/poke --timeout=60s \
  || kubectl -n team-a get pod poke -o jsonpath='{.status.containerStatuses[0].state.terminated.exitCode}'
pod/poke condition met
verify: the curl times out (exit 28). Then write the pair of policies that would allow exactly this one flow, an egress rule in team-a and an ingress rule in team-b, apply them, and rerun until you get a 200. Both ends must open.

FAULT=netpol make break strips the DNS egress rule. Diagnose it without the answer, but remember drops only show when something tries: the resident nginx pods never resolve anything, so generate the evidence yourself with kubectl -n team-a exec deploy/<whatever runs there> -- nslookup kubernetes.default (or run a busybox pod), then read hubble observe --namespace team-a --verdict DROPPED and see port 53 dying. make break-answer to confirm, make break-fix to restore.

verify: the same nslookup now succeeds.

A scoped quota counts a subset of the namespace rather than all of it, which is how a platform team forbids one class of workload without capping the tenant. The rejection names the quota, so the tenant learns what they hit.

kubectl apply -f - <<'EOF'
apiVersion: v1
kind: ResourceQuota
metadata: { name: no-critical, namespace: team-a }
spec:
  hard: { pods: "0" }
  scopeSelector:
    matchExpressions:
      - scopeName: PriorityClass
        operator: In
        values: [system-cluster-critical]
EOF
kubectl -n team-a run critical --image=nginx:1.27-alpine --restart=Never --overrides='{"spec":{"priorityClassName":"system-cluster-critical","containers":[{"name":"critical","image":"nginx:1.27-alpine","resources":{"requests":{"cpu":"50m","memory":"64Mi"},"limits":{"cpu":"100m","memory":"128Mi"}}}]}}'
kubectl -n team-a run ordinary --image=nginx:1.27-alpine --restart=Never --overrides='{"spec":{"containers":[{"name":"ordinary","image":"nginx:1.27-alpine","resources":{"requests":{"cpu":"50m","memory":"64Mi"},"limits":{"cpu":"100m","memory":"128Mi"}}}]}}'
kubectl -n team-a get pods ordinary
kubectl -n team-a delete pod ordinary --ignore-not-found
kubectl -n team-a delete resourcequota no-critical
outputcaptured 2026-09-13
$ kubectl apply -f - <<'EOF'
apiVersion: v1
kind: ResourceQuota
metadata: { name: no-critical, namespace: team-a }
spec:
  hard: { pods: "0" }
  scopeSelector:
    matchExpressions:
      - scopeName: PriorityClass
        operator: In
        values: [system-cluster-critical]
EOF
resourcequota/no-critical created
$ kubectl -n team-a run critical --image=nginx:1.27-alpine --restart=Never --overrides='{"spec":{"priorityClassName":"system-cluster-critical","containers":[{"name":"critical","image":"nginx:1.27-alpine","resources":{"requests":{"cpu":"50m","memory":"64Mi"},"limits":{"cpu":"100m","memory":"128Mi"}}}]}}'
Warning: would violate PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "critical" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "critical" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "critical" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "critical" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")
Error from server (Forbidden): pods "critical" is forbidden: exceeded quota: no-critical, requested: pods=1, used: pods=0, limited: pods=0
$ kubectl -n team-a run ordinary --image=nginx:1.27-alpine --restart=Never --overrides='{"spec":{"containers":[{"name":"ordinary","image":"nginx:1.27-alpine","resources":{"requests":{"cpu":"50m","memory":"64Mi"},"limits":{"cpu":"100m","memory":"128Mi"}}}]}}'
Warning: would violate PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "ordinary" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "ordinary" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "ordinary" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "ordinary" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")
pod/ordinary created
$ kubectl -n team-a get pods ordinary
NAME       READY   STATUS    RESTARTS   AGE
ordinary   0/1     Pending   0          0s
$ kubectl -n team-a delete pod ordinary --ignore-not-found
pod "ordinary" deleted from team-a namespace
$ kubectl -n team-a delete resourcequota no-critical
resourcequota "no-critical" deleted from team-a namespace
verify: the critical pod is refused with an "exceeded quota" message naming no-critical, and the ordinary pod is admitted under the tenant's existing quota. One namespace, two answers, decided by a scope.

Quota is not only cpu and memory. count/<resource>.<group> caps any kind the API server knows about, including the CRDs your platform ships, which is the cheapest guardrail against a tenant looping on create.

kubectl create quota objs -n team-a --hard=count/configmaps=3,count/analysistemplates.argoproj.io=1
kubectl -n team-a get quota objs -o jsonpath='{.status}' | jq
kubectl -n team-a create configmap one --from-literal=a=1
kubectl -n team-a create configmap two --from-literal=a=1
kubectl -n team-a create configmap three --from-literal=a=1
kubectl -n team-a get quota objs -o jsonpath='{.status.used}' | jq
kubectl -n team-a delete configmap one two three --ignore-not-found
kubectl -n team-a delete quota objs
outputcaptured 2026-11-18
$ kubectl create quota objs -n team-a --hard=count/configmaps=3,count/analysistemplates.argoproj.io=1
resourcequota/objs created
$ kubectl -n team-a get quota objs -o jsonpath='{.status}' | jq
{
  "hard": {
    "count/analysistemplates.argoproj.io": "1",
    "count/configmaps": "3"
  },
  "used": {
    "count/analysistemplates.argoproj.io": "0",
    "count/configmaps": "1"
  }
}
$ kubectl -n team-a create configmap one --from-literal=a=1
configmap/one created
$ kubectl -n team-a create configmap two --from-literal=a=1
configmap/two created
$ kubectl -n team-a create configmap three --from-literal=a=1
error: failed to create configmap: configmaps "three" is forbidden: exceeded quota: objs, requested: count/configmaps=1, used: count/configmaps=3, limited: count/configmaps=3
$ kubectl -n team-a get quota objs -o jsonpath='{.status.used}' | jq
{
  "count/analysistemplates.argoproj.io": "0",
  "count/configmaps": "3"
}
$ kubectl -n team-a delete configmap one two three --ignore-not-found
configmap "one" deleted from team-a namespace
configmap "two" deleted from team-a namespace
$ kubectl -n team-a delete quota objs
resourcequota "objs" deleted from team-a namespace
verify: status.used tracks both keys the moment the quota is created: count/configmaps at 1, because team-a already holds kube-root-ca.crt before you create anything, and count/analysistemplates.argoproj.io at 0 (it reads 1 once 2.5's success-rate template exists). So the limit of 3 leaves room for two, one and two are created and three is refused with a message naming objs and both numbers. Count quotas are charged against what is already there, not against what you add.

The lab does not install HNC, so this block installs it first and removes it at the end. Do it once to see what namespace inheritance produces, then decide whether you would run it.

The kubectl hns plugin is not part of the lab's tool set either, so this uses the CRs directly: a SubnamespaceAnchor is what the plugin creates for you.

kubectl apply -f https://github.com/kubernetes-sigs/hierarchical-namespaces/releases/download/v1.1.0/default.yaml
kubectl -n hnc-system rollout status deploy/hnc-controller-manager --timeout=180s
kubectl -n team-a create rolebinding tenant-view --clusterrole=view --user=dev-a
kubectl apply -f - <<'EOF'
apiVersion: hnc.x-k8s.io/v1alpha2
kind: SubnamespaceAnchor
metadata: { name: dev, namespace: team-a }
EOF
sleep 20
kubectl get ns dev
kubectl get hierarchyconfiguration -n dev -o jsonpath='{.items[0].status}' | jq
kubectl get rolebinding -n dev --show-labels
kubectl delete subnamespaceanchor dev -n team-a
kubectl -n team-a delete rolebinding tenant-view
kubectl delete -f https://github.com/kubernetes-sigs/hierarchical-namespaces/releases/download/v1.1.0/default.yaml
outputcaptured 2026-09-13
$ kubectl apply -f https://github.com/kubernetes-sigs/hierarchical-namespaces/releases/download/v1.1.0/default.yaml
namespace/hnc-system created
customresourcedefinition.apiextensions.k8s.io/hierarchicalresourcequotas.hnc.x-k8s.io created
customresourcedefinition.apiextensions.k8s.io/hierarchyconfigurations.hnc.x-k8s.io created
customresourcedefinition.apiextensions.k8s.io/hncconfigurations.hnc.x-k8s.io created
customresourcedefinition.apiextensions.k8s.io/subnamespaceanchors.hnc.x-k8s.io created
role.rbac.authorization.k8s.io/hnc-leader-election-role created
clusterrole.rbac.authorization.k8s.io/hnc-admin-role created
clusterrole.rbac.authorization.k8s.io/hnc-manager-role created
rolebinding.rbac.authorization.k8s.io/hnc-leader-election-rolebinding created
clusterrolebinding.rbac.authorization.k8s.io/hnc-manager-rolebinding created
secret/hnc-webhook-server-cert created
service/hnc-controller-manager-metrics-service created
service/hnc-webhook-service created
deployment.apps/hnc-controller-manager created
mutatingwebhookconfiguration.admissionregistration.k8s.io/hnc-mutating-webhook-configuration created
validatingwebhookconfiguration.admissionregistration.k8s.io/hnc-validating-webhook-configuration created
$ kubectl -n hnc-system rollout status deploy/hnc-controller-manager --timeout=180s
Waiting for deployment "hnc-controller-manager" rollout to finish: 0 of 1 updated replicas are available...
deployment "hnc-controller-manager" successfully rolled out
$ kubectl -n team-a create rolebinding tenant-view --clusterrole=view --user=dev-a
rolebinding.rbac.authorization.k8s.io/tenant-view created
$ kubectl apply -f - <<'EOF'
apiVersion: hnc.x-k8s.io/v1alpha2
kind: SubnamespaceAnchor
metadata: { name: dev, namespace: team-a }
EOF
subnamespaceanchor.hnc.x-k8s.io/dev created
$ sleep 20
$ kubectl get ns dev
NAME   STATUS   AGE
dev    Active   20s
$ kubectl get hierarchyconfiguration -n dev -o jsonpath='{.items[0].status}' | jq
{}
$ kubectl get rolebinding -n dev --show-labels
NAME          ROLE               AGE   LABELS
developer     Role/developer     1s    app.kubernetes.io/managed-by=hnc.x-k8s.io,hnc.x-k8s.io/inherited-from=team-a
pg            Role/pg            1s    app.kubernetes.io/managed-by=hnc.x-k8s.io,cnpg.io/cluster=pg,hnc.x-k8s.io/inherited-from=team-a
tenant-view   ClusterRole/view   1s    app.kubernetes.io/managed-by=hnc.x-k8s.io,hnc.x-k8s.io/inherited-from=team-a
$ kubectl delete subnamespaceanchor dev -n team-a
subnamespaceanchor.hnc.x-k8s.io "dev" deleted from team-a namespace
$ kubectl -n team-a delete rolebinding tenant-view
rolebinding.rbac.authorization.k8s.io "tenant-view" deleted from team-a namespace
$ kubectl delete -f https://github.com/kubernetes-sigs/hierarchical-namespaces/releases/download/v1.1.0/default.yaml
namespace "hnc-system" deleted
customresourcedefinition.apiextensions.k8s.io "hierarchicalresourcequotas.hnc.x-k8s.io" deleted
customresourcedefinition.apiextensions.k8s.io "hierarchyconfigurations.hnc.x-k8s.io" deleted
customresourcedefinition.apiextensions.k8s.io "hncconfigurations.hnc.x-k8s.io" deleted
customresourcedefinition.apiextensions.k8s.io "subnamespaceanchors.hnc.x-k8s.io" deleted
role.rbac.authorization.k8s.io "hnc-leader-election-role" deleted from hnc-system namespace
clusterrole.rbac.authorization.k8s.io "hnc-admin-role" deleted
clusterrole.rbac.authorization.k8s.io "hnc-manager-role" deleted
rolebinding.rbac.authorization.k8s.io "hnc-leader-election-rolebinding" deleted from hnc-system namespace
clusterrolebinding.rbac.authorization.k8s.io "hnc-manager-rolebinding" deleted
secret "hnc-webhook-server-cert" deleted from hnc-system namespace
service "hnc-controller-manager-metrics-service" deleted from hnc-system namespace
service "hnc-webhook-service" deleted from hnc-system namespace
deployment.apps "hnc-controller-manager" deleted from hnc-system namespace
mutatingwebhookconfiguration.admissionregistration.k8s.io "hnc-mutating-webhook-configuration" deleted
validatingwebhookconfiguration.admissionregistration.k8s.io "hnc-validating-webhook-configuration" deleted
verify: the dev namespace appears without anyone creating it, and the RoleBinding you made in team-a is copied into it carrying an hnc.x-k8s.io/inherited-from label. That label is the whole argument for and against the model: propagation you did not ask for, visible in the object.

API Priority and Fairness is already running on every cluster you will be handed, with objects you can read. A tenant hammering the API server is a fairness question before it is a quota question.

kubectl get flowschema
kubectl get prioritylevelconfiguration
kubectl get flowschema -o custom-columns=NAME:.metadata.name,PL:.spec.priorityLevelConfiguration.name,MATCH:.spec.rules[0].subjects[0].kind | head -20
kubectl get --raw /debug/api_priority_and_fairness/dump_priority_levels | head -20
outputcaptured 2026-09-12
$ kubectl get flowschema
NAME                           PRIORITYLEVEL     MATCHINGPRECEDENCE   DISTINGUISHERMETHOD   AGE   MISSINGPL
exempt                         exempt            1                    <none>                47m   False
probes                         exempt            2                    <none>                47m   False
system-leader-election         leader-election   100                  ByUser                47m   False
system-node-high               node-high         400                  ByUser                47m   False
system-nodes                   system            500                  ByUser                47m   False
kube-controller-manager        workload-high     800                  ByNamespace           47m   False
kube-scheduler                 workload-high     800                  ByNamespace           47m   False
kube-system-service-accounts   workload-high     900                  ByNamespace           47m   False
service-accounts               workload-low      9000                 ByUser                47m   False
global-default                 global-default    9900                 ByUser                47m   False
catch-all                      catch-all         10000                ByUser                47m   False
$ kubectl get prioritylevelconfiguration
NAME              TYPE      NOMINALCONCURRENCYSHARES   QUEUES   HANDSIZE   QUEUELENGTHLIMIT   AGE
catch-all         Limited   5                          <none>   <none>     <none>             47m
exempt            Exempt    <none>                     <none>   <none>     <none>             47m
global-default    Limited   20                         128      6          50                 47m
leader-election   Limited   10                         16       4          50                 47m
node-high         Limited   40                         64       6          50                 47m
system            Limited   30                         64       6          50                 47m
workload-high     Limited   40                         128      6          50                 47m
workload-low      Limited   100                        128      6          50                 47m
$ kubectl get flowschema -o custom-columns=NAME:.metadata.name,PL:.spec.priorityLevelConfiguration.name,MATCH:.spec.rules[0].subjects[0].kind | head -20
NAME                           PL                MATCH
catch-all                      catch-all         Group
exempt                         exempt            Group
global-default                 global-default    Group
kube-controller-manager        workload-high     User
kube-scheduler                 workload-high     User
kube-system-service-accounts   workload-high     ServiceAccount
probes                         exempt            Group
service-accounts               workload-low      Group
system-leader-election         leader-election   User
system-node-high               node-high         Group
system-nodes                   system            Group
$ kubectl get --raw /debug/api_priority_and_fairness/dump_priority_levels | head -20
PriorityLevelName, ActiveQueues, IsIdle, IsQuiescing, WaitingRequests, ExecutingRequests, DispatchedRequests, RejectedRequests, TimedoutRequests, CancelledRequests
catch-all,         0,            true,   false,       0,               0,                 59,                 0,                0,                0
exempt,            0,            true,   false,       0,               0,                 6418,               0,                0,                0
global-default,    0,            false,  false,       0,               1,                 4449,               0,                0,                0
leader-election,   0,            true,   false,       0,               0,                 4063,               0,                0,                0
node-high,         0,            true,   false,       0,               0,                 965,                0,                0,                0
system,            0,            true,   false,       0,               0,                 6670,               0,                0,                0
workload-high,     0,            true,   false,       0,               0,                 12303,              0,                0,                0
workload-low,      0,            true,   false,       0,               0,                 48013,              0,                0,                0
verify: you can name the flow schema a request from a tenant ServiceAccount would land in, and the priority level it maps to. The dump endpoint is the one to reach for when the complaint is "the API server is slow for us only".

Self-check

answer before opening
A tenant applies a Deployment. It is accepted, and no pods appear. Where is the error?

One level down on the ReplicaSet. Quotas and PSS are enforced at pod creation, so the Deployment itself applies cleanly while the ReplicaSet logs the rejection in its events and conditions. Run kubectl -n <ns> describe rs -l app=<x> or check namespace events. This indirection comes up constantly on the exam.

Why does adding a LimitRange sometimes make previously-working pods fail?

Because LimitRanges enforce min/max bounds in addition to injecting defaults. Already-running pods stay untouched (admission isn't retroactive), but the next new pod whose explicit requests fall outside those bounds gets rejected with a LimitRange error.

Quota says requests.cpu: "2". A tenant asks why they cannot run 40 pods when the LimitRange injects 50m each.

Another quota ceiling hits first: limits.cpu: "4" divided by the 200m default limit caps them at 20 pods, tying with pods: "20". Every line in a ResourceQuota must pass simultaneously, so the tightest limit always wins.

Name the isolation ladder and one cost of each rung.

Namespaces + quotas + policies (near-zero overhead, but shared kernel and shared API server) → tainted dedicated node pools (isolated kernels, but stranded capacity per pool) → virtual clusters (own API server and CRDs, more control-plane moving parts) → dedicated clusters (strongest boundary, highest operational and idle-capacity cost). Always pick the lightest rung that meets your threat model.

Why is services.loadbalancers: "1" in a tenant quota?

Because cloud LoadBalancers bill continuously whether traffic flows or not. Putting a cap in the tenant quota turns Kubernetes into a spend guardrail, just like per-StorageClass quotas do for expensive disks.

A tenant needs to install its own CRDs and admission webhooks but you cannot afford a cluster per tenant. Which model?

A virtual control plane per tenant, such as vcluster. Each tenant gets an isolated API server for their own CRDs and webhooks while their pods still share the host cluster's worker nodes through the syncer. Plain namespaces can't isolate cluster-scoped APIs, and full clusters cost too much duplication.

What does HNC add to plain namespaces, in two sentences?

HNC organizes namespaces into parent-child hierarchies so RBAC, NetworkPolicies, and other chosen resources propagate automatically downward, while letting tenant admins spin up subnamespaces without cluster-wide permissions. It also stamps tree labels onto every namespace for team-wide selectors and supports HierarchicalResourceQuota across subtrees.

Tenants keep launching pods with the PriorityClass reserved for platform components. Fix with a quota.

Add a ResourceQuota in each tenant namespace with scopeSelector: { matchExpressions: [{ scopeName: PriorityClass, operator: In, values: [platform-critical] }] } and hard: { pods: "0" }. Admission immediately rejects any pod claiming that PriorityClass while leaving normal workloads untouched.

Why should a StorageClass shared between tenants use reclaimPolicy Delete?

Because PVs are cluster-scoped. A Retain PV released by one tenant keeps its old data around, and once claimRef is cleared, a claim from another namespace could bind to it. Delete destroys the backend volume alongside the claim so data can't leak across tenants (or give sensitive tenants their own StorageClasses).

Docs to know your way around

study time, not exam time
  • kubernetes.io: Resource Quotas (the full list of countable resources), Limit Ranges, Network Policies.
  • kubernetes.io Concepts → Security → Multi-tenancy: reads like it was written for this competency; the isolation-ladder framing above is theirs.
  • Offline: kubectl explain resourcequota.spec.hard, kubectl explain limitrange.spec.limits, and kubectl describe quota -n <ns> for the used/hard table.
  • kubernetes.io Concepts → Security → Multi-tenancy, "Implementations": namespace-per-tenant versus virtual control plane, and the data-plane list (network, storage, sandboxing, node isolation).
  • github.com/kubernetes-sigs/hierarchical-namespaces (user guide): subnamespaces, propagation, tree labels and HRQ; projectcapsule.dev for the Tenant CRD; vcluster.com/docs architecture page for the syncer and shared vs private nodes.
  • kubernetes.io: Resource Quotas, "Quota scopes" and "Object count quota": the scopeSelector operators and the count/ syntax that also covers custom resources.
free before 1.5make down-sec