⚡ ~/naveed Interview Prep
⚡ Portfolio Home 👤 About Naveed Bio & Credentials 📫 Contact Naveed Get In Touch ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 1,000+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →
← Back to All Kubernetes Interview Questions Scenario 155 of 207 in Kubernetes
Staff SRE / Principal Architect [L3] Kubernetes Additional Kubernetes Scenarios (Q101-Q200) Staff SRE Scenario [L3]
🎯 Target Role / Context: Kubernetes Scenario #145 (L3) · Additional Kubernetes Scenarios (Q101-Q200)

Q: What is an Admission Controller and how does Kubernetes use them?

An admission controller is a piece of API server code that intercepts a request after authentication and authorization but before the object is persisted to etcd, and can modify it, reject it, or both.

#Kubernetes #L3 #Container Orchestration #K8s #etcd
🎙️ Candidate Opening & Architectural Context
"An <strong>admission controller</strong> is a piece of API server code that intercepts a request after authentication and authorization but before the object is persisted to etcd, and can modify it, reject it, or both. Kubernetes uses admission controllers to enforce defaults and policy: injecting sidecars, applying quotas, enforcing Pod Security Standards and blocking non-compliant manifests. Interviewers ask this to see whether you understand the request lifecycle, the difference between mutating and validating stages, and the operational risk of a misconfigured webhook, which can block every deployment in a cluster. A strong answer also covers the newer in-process ValidatingAdmissionPolicy that reduces the need for webhooks."
Advertisement
⚡ Recommended Practice Lab

Want to master this scenario in a live sandbox? KodeKloud's CKA & CKAD Hands-On Certification Track covers this exact problem with hands-on terminal drills.

🛠️ Production Runbook & Step-by-Step Resolution

Direct Answer: An <strong>admission controller</strong> is a piece of API server code that intercepts a request after authentication and authorization but before the object is persisted to etcd, and can modify it, reject it, or both. Kubernetes uses admission controllers to enforce defaults and policy: injecting sidecars, applying quotas, enforcing Pod Security Standards and blocking non-compliant manifests. Interviewers ask this to see whether you understand the request lifecycle, the difference between mutating and validating stages, and the operational risk of a misconfigured webhook, which can block every deployment in a cluster. A strong answer also covers the newer in-process ValidatingAdmissionPolicy that reduces the need for webhooks.

1️⃣

Mental model: where an admission controller sits

Every write to the API server passes through a fixed pipeline, and admission is the last gate before persistence.

  • Pipeline order: authentication, authorization (RBAC), mutating admission, object schema validation, validating admission, then the write to etcd. Reads (get, list, watch) are never admitted.
  • Mutating: may change the object, for example adding a default StorageClass, injecting a sidecar container or setting resource requests. Mutating plugins run first so validation sees the final object.
  • Validating: may only accept or reject. Examples are ResourceQuota, PodSecurity and your own policy checks. Any single rejection fails the whole request with a clear error message.
  • Scope: admission acts on create, update, delete and connect (exec, port-forward) operations. It does not retroactively fix objects that already exist in etcd.
Pro Tip: Authorization answers <em>can this user do this?</em> Admission answers <em>is this specific object acceptable?</em> Both must pass.
2️⃣

Hands-on: inspect built-in admission controllers

Built-in plugins compile into kube-apiserver and are toggled by flags, while dynamic ones are registered through API objects.

# See which plugins a kubeadm-style apiserver enables (flag may be absent = defaults)
kubectl -n kube-system get pod -l component=kube-apiserver -o yaml | grep -i admission

# List dynamic webhooks registered in the cluster
kubectl get mutatingwebhookconfigurations
kubectl get validatingwebhookconfigurations

# Server-side dry run triggers admission without persisting anything
kubectl apply -f deploy.yaml --dry-run=server
  • Built-in examples: NamespaceLifecycle, LimitRanger, ServiceAccount, ResourceQuota, DefaultStorageClass, NodeRestriction and PodSecurity (stable since 1.25, replacing PodSecurityPolicy).
  • Configure: on self-managed control planes use --enable-admission-plugins and --disable-admission-plugins on the kube-apiserver manifest. Managed services (EKS, GKE, AKS) usually do not let you change these.
  • Dynamic: MutatingWebhookConfiguration and ValidatingWebhookConfiguration point the API server at an HTTPS service you run, which receives an AdmissionReview and replies with allowed true or false plus optional JSON patches.
  • Defaults vary: the enabled-by-default list changes between minor versions, so confirm against your cluster instead of memorising it.
Advertisement
3️⃣

Hands-on: ValidatingAdmissionPolicy with CEL

Since Kubernetes 1.30 ValidatingAdmissionPolicy is GA, letting you express rules in CEL inside the API server with no webhook to run.

apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
  name: require-replicas-limit
spec:
  failurePolicy: Fail
  matchConstraints:
    resourceRules:
    - apiGroups: ["apps"]
      apiVersions: ["v1"]
      operations: ["CREATE","UPDATE"]
      resources: ["deployments"]
  validations:
  - expression: "object.spec.replicas <= 10"
    message: "replicas must be 10 or fewer"
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicyBinding
metadata:
  name: require-replicas-limit-binding
spec:
  policyName: require-replicas-limit
  validationActions: ["Warn","Audit"]   # switch to ["Deny"] once clean
  • Policy: a ValidatingAdmissionPolicy holds matchConstraints and a list of CEL validations with messages.
  • Binding: a ValidatingAdmissionPolicyBinding activates the policy, selects namespaces and sets validationActions such as Deny, Warn or Audit.
  • Rollout tip: start with Warn and Audit to see what would break, then switch to Deny.
  • Older clusters: on 1.28 and 1.29 the feature is beta and may need to be enabled; check your version before relying on it.
4️⃣

Verify what admission did to a request

When an apply is rejected or an object looks different from your manifest, confirm which stage acted.

  • Read the error: rejections name the source, for example admission webhook "x.example.com" denied the request or exceeded quota. The name points at the exact webhook configuration.
  • Compare objects: kubectl get pod my-pod -o yaml against your manifest shows mutations such as injected containers, default tolerations or added annotations.
  • Audit logs: API audit events and the apiserver metric apiserver_admission_webhook_rejection_count show which webhooks reject and how often.
  • Test safely: --dry-run=server runs the full admission chain, while --dry-run=client skips it, so only the server variant is a valid policy test.
5️⃣

Failure modes and production practice

Webhooks sit on the critical path of every write, so their reliability directly becomes cluster reliability.

  • failurePolicy: Fail blocks requests when the webhook is unreachable; Ignore lets them through. Security policies usually use Fail, but only with highly available webhook pods and a short timeoutSeconds.
  • Self-deadlock: a webhook that matches the pods or namespaces of its own deployment, or kube-system, can stop itself from restarting. Exclude them with namespaceSelector or objectSelector.
  • Side effects and ordering: declare sideEffects: None where true so dry-run works, and remember mutating webhooks can be re-invoked via reinvocationPolicy when another one changes the object.
  • Operate it: keep webhooks in GitOps, rotate serving certificates (cert-manager is common), alert on latency and rejection metrics, and prefer built-in plugins or CEL policies over custom webhooks when they can express the rule.
Pro Tip: If the API server cannot call a Fail-closed webhook, even <code>kubectl delete</code> of the webhook configuration may be needed to recover; keep that break-glass procedure documented.
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: Roll out any new admission policy in Warn/Audit mode first and exclude kube-system and the webhook own namespace, because a Fail-closed webhook that cannot start itself can freeze deployments cluster-wide."
⚡ 60-Second Elevator Pitch Talking Points
  • An admission controller is API server logic that runs after authN/authZ and before etcd persistence, mutating or validating each write request.
  • I verify behaviour with kubectl apply --dry-run=server, by diffing the live object against my manifest, and by checking webhook rejection metrics.
  • I automate policy as code, using ValidatingAdmissionPolicy or a policy engine in GitOps, rolled out in Warn mode with HA webhooks and tight failurePolicy settings.
⛔ Critical Candidate Mistakes to Avoid in This Scenario

Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:

  1. Confusing admission with RBAC RBAC decides who may act; admission inspects the object itself. A user with full RBAC rights can still be rejected by quota or policy.
  2. Letting a webhook match its own namespace If the webhook pods go down and the policy is Fail-closed, they cannot be recreated because their own creation request is blocked.
  3. Testing policy with client-side dry run --dry-run=client never contacts the API server, so no admission plugin or webhook runs and the test proves nothing.
  4. Using Fail with a single webhook replica and long timeout A slow or crashed replica stalls every matching write until the timeout, turning a policy tool into a cluster-wide outage.
Advertisement
📥 FREE DOWNLOAD · 101-PAGE COMPANION HANDBOOK
Studying for Kubernetes & SRE Technical Rounds?
Download the complete 100-question PDF field guide covering all 11 core modules with offline diagnostic runbooks.
📥 Download PDF (Free) Read Online Guide →
Want more Kubernetes scenarios?
Explore our complete collection of scenario-based Kubernetes interview runbooks.
Browse All Kubernetes Questions →