Skip to content
Tech Interview Prep
Technical interview guide

Kubernetes Operators & CRDs

Extending Kubernetes with custom resources and controllers to automate operational knowledge, not just deployment.

Minutes to read
3
Practice MCQs
25
Interview Q&A
25
Edition
v4
Editorial status
Reviewed
Relevant for
Platform Engineer

Scope: Kubernetes documentation and apiextensions.k8s.io/v1 behavior current 2026-08-31; verify feature-state notes against the target cluster version.

Overview

Curated: · Written: · Reviewed:

Kubernetes Operators & CRDs

In one line

A CRD adds a typed resource to the API server. An operator is the controller that reads that spec and converges real state toward it. Reach for both when users need a long-lived domain object with lifecycle automation, not a one-shot command.

Key definitions

  • CRD: registers a resource kind with a structural schema, storage, discovery, RBAC and watch. Does no work by itself.
  • Controller: a level-triggered loop that re-reads spec and observed state, then acts.
  • Status subresource: a separate /status endpoint. Main-resource writes ignore status.
  • Finalizer: an entry in metadata.finalizers that blocks deletion until the controller removes it.
  • ownerReference: links dependents to an owner so garbage collection deletes them when the owner is gone.
  • storedVersions: the versions that may still exist in etcd. Migrate objects before removing a version.

How it works

User applies spec API server bumps generation Informer event wakes loop Reconcile re-reads CR and external state Idempotent side effects keyed on UID Write status and observedGeneration
  • Events only wake the loop. Reconcile never acts on the event payload, because a dropped watch can hide several changes.
  • Every side effect is keyed on a stable identifier such as the CR UID, so a repeat adopts the existing resource instead of creating another.
  • Set observedGeneration only after side effects succeed.
  • A timeout means the outcome is unknown, not failed. Look up before retrying.
  • On delete, the finalizer holds the object. The controller cleans up, then removes only its own finalizer.

When to use and when not to

SituationCRD plus controllerPrefer instead
Long-lived domain object users observe and reconcileYes
Transient command such as a migration runNoJob
Config a Deployment plus HPA already expressesNoBuilt-in resources
Custom storage, protocol or API semanticsNoAggregated API server
Only object-local rulesNoCEL rules in the CRD schema

Traps interviewers probe

  1. Removing a finalizer to unstick deletion. The object disappears and external resources leak. Fix: let the controller finish cleanup. Force-removal is an audited runbook step that records impact.
  2. Acting on the event payload. After a dropped watch, one event can stand for three spec changes. Fix: re-read the current object and converge.
  3. Retrying a timed-out create under a new name. The first call may have succeeded. Fix: treat the timeout as unknown, look up by the UID label, and reuse a deterministic identity.
  4. Calling slow external APIs in a webhook. A 30 s provider call blocks every apply and times out at 10 s. Fix: validate and default in admission, and provision in the controller.
  5. Assuming a leader lease fences side effects. An old leader paused mid-call still lands its request. Fix: make the external call idempotent and carry a fencing token.

Interview tips

Open with the split: "Kubernetes gives me the API, storage and watch. I own the control loop that converges state."

Follow-ups to expect:

  • What a CRD gives you for free: storage, validation, discovery, RBAC, watch, garbage collection. Not automation.
  • The controller crashes mid-reconcile: the level-triggered re-read makes it safe.
  • Cloud cleanup on delete: finalizer, UID binding, idempotent delete, status progress.
  • Adding v1 after v1alpha1: a lossless conversion, the storage version, and a migrated storedVersions before removal.
  • Who may create the CR: the confused-deputy question. The controller must not turn create permission into unrestricted infrastructure authority.
  • Status: write it through /status, retry conflicts with a fresh read, and compare generation to observedGeneration.

30-second outline:

  1. Name the domain object and its spec/status split.
  2. Say reconcile is level-triggered and re-reads state.
  3. Name the idempotency key (UID) and how a lost response is handled.
  4. Describe deletion: finalizer, cleanup, then removal of only your finalizer.
  5. Name the failure you watch for: stuck Terminating, reconcile errors, stale generations.
  6. Close with scale: bounded workers, backoff with jitter, leader election plus idempotent work.

Verify feature-state notes against the target cluster version.

Feedback on this overview

Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.