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.

Read
42 min
Practice MCQs
25
Interview Q&A
25
Edition
v3
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.

Curated: · Written: · Reviewed:

25 questions

MCQ-1A team installs a CRD for a `Database` kind and nothing else: no controller, no webhook. Which capability does the CRD alone provide?
MCQ-3A team ships a `Database` operator. Users set `replicas` and `version` with `kubectl apply`; the operator must publish the observed endpoint and ready-replica count so `kubectl get database` shows them, and a user's edit must survive the next reconcile. Where should the user-set `replicas` and `version` live?
MCQ-2A PostgresCluster operator manages an orders-db resource with spec.instances: 3. Its controller watches PostgresCluster objects and the StatefulSet it owns, and each reconcile makes the StatefulSet's spec.replicas match spec.instances. At 09:00, with all 3 pods Ready, an on-call engineer frees node capacity by running kubectl scale statefulset orders-db --replicas=1. Nobody edits the PostgresCluster. What happens next?
MCQ-4A Kubernetes controller watches a custom resource through an informer. The watch connection drops for two minutes; on reconnect the informer delivers a single event for an object whose spec changed three times during the gap, and the reconcile function runs once with that event. What should the reconcile function do?
MCQ-21A Deployment controller watches a ConfigMap named `app-config`. On each reconcile it GETs the object, computes a new value for the key `maxConnections`, and PUTs the whole object back with the `resourceVersion` it read. This time the GET returned `resourceVersion: 4821`; the PUT came back `409 Conflict`. Between the two calls an operator ran `kubectl edit` and changed only `logLevel` from `info` to `debug`, taking the object to `resourceVersion: 4830`. The controller's `maxConnections` value does not depend on `logLevel`, and the operator's change must survive. What should the controller do?
MCQ-7A controller's ServiceAccount is bound to a Role granting `update` on `widgets` in namespace `prod` and nothing else. The controller GETs widget `w-1`, sets `.spec.replicas` to 5 and `.status.phase` to `Ready`, then sends one PUT to `/apis/example.com/v1/namespaces/prod/widgets/w-1` carrying the full object. The `widgets` CRD has the status subresource enabled. What does the API server return, and what is stored?
MCQ-6An operator manages a `Queue` custom resource. A user patches `spec.maxWorkers` from 8 to 16. `kubectl get queue orders -o yaml` then shows `metadata.generation: 7`, `spec.maxWorkers: 16`, `status.observedGeneration: 6`, and a `Ready` condition with `status: "True"`, `reason: Reconciled`, `lastTransitionTime: 2024-05-01T10:00:00Z`. The patch was applied at 10:05. What does this state tell you?
MCQ-8An operator provisions a database and must (a) tell a downstream billing service when provisioning finished, the notification may be consumed days later, and (b) explain to an on-call engineer why an attempt failed when the operator's call to the database API timed out. Which use of Kubernetes Events is appropriate?
MCQ-10A controller creates a ConfigMap in namespace `payments` and sets a single ownerReference on it. The ConfigMap is garbage-collected while the referenced owner still exists. Which ownerReference explains that?
MCQ-9A controller in namespace `prod` creates a `ConfigMap` named `app-config` and sets a single entry in `metadata.ownerReferences`: `{apiVersion: example.com/v1, kind: App, name: web, uid: 9c1e4b7a-...}`. The `App` CRD is installed and served, but no `App` object named `web` exists in `prod`: the controller creates the `App` only after the `ConfigMap`. The `ConfigMap` is created successfully and is visible with `kubectl get configmap app-config`, but a few seconds later it is gone, and the controller never issued a delete. What removed it?
MCQ-11A `Database` custom resource carries the finalizer `db.example.com/deprovision`. Its controller deprovisions an external RDS instance through a cloud API that is idempotent and returns `200` with `status: deleting` immediately; the instance is actually gone about 90 seconds later, after which a describe call returns `NotFound`. The controller reconciles every 10 seconds. A user deletes the object at T0, and at T0+10s the controller's deprovision call returns `200` with `status: deleting`. What should the controller do at T0+10s?
MCQ-12A `Backup` custom resource (`backup.example.com/v1`) carries the finalizer `backup.example.com/snapshot-cleanup`. Its controller deletes the 200 GB EBS snapshot the object references, then removes the finalizer. The controller was uninstalled during a migration, and 12 `Backup` objects: 2.4 TB of snapshots in total: have sat in `Terminating` for three days. An engineer runs: ``` kubectl patch backup nightly -p '{"metadata":{"finalizers":[]}}' --type=merge ``` What is the result for the `nightly` object?
MCQ-5A controller for a `Database` custom resource provisions a cloud instance and then patches `status.instanceID` with the ID the API returns. The provision call takes 4 s end to end; the controller's HTTP client timeout is 3 s. The API creates the instance at t=2 s and sends its response at t=4 s, but the client gave up at t=3 s, so the reconcile returns an error and the workqueue requeues the key. One second later the next reconcile reads `status.instanceID`, finds it empty, and calls provision again. Which change makes repeated reconciles converge on exactly one instance?
MCQ-25A `backup-operator` reconciles `Backup` custom resources. Each reconcile performs exactly two writes: it calls `Create` on a `batch/v1 Job` whose metadata sets `GenerateName: "backup-"` and an `ownerReference` to the `Backup`, then patches `status.jobName` with the name the API server returned. The operator decides whether a Job already exists by reading `status.jobName` and nothing else. A test harness runs the manager under `envtest`, lets one `Backup` reconcile, sends `SIGKILL` to the manager in the window after `Create` returns but before the status patch is issued, restarts the manager, and waits 30 s. How many Jobs carrying that `Backup`'s owner reference exist when the test finishes?
MCQ-13A controller creates one provider load balancer per custom resource. Each create request carries the label cr-uid=<uid>, and the provider does not enforce uniqueness on object names, so a second create with the same name is accepted and provisions a second load balancer. The provider's list call filters by label and is read-after-write consistent in the region, but it returns only objects that have finished provisioning. During a four-minute provider slowdown, accepted creates finished 40 to 200 s after the request arrived, the client deadline is 10 s, and the client reports the same 'deadline exceeded' error whether or not the request reached the provider. One worker handles a given CR, so at most one create is in flight per CR, and a 200 s delay before a first successful create is acceptable for these resources. The naive loop retried on the next reconcile with a new random name, and the account ended up with 11 load balancers for 4 custom resources. Which handling of a create timeout removes the duplication?
MCQ-14A CRD defines two versions: v1 (served: true, storage: true) and v2 (served: true, storage: false). A client sends a create request to the v2 endpoint with an object that satisfies the v2 schema. The API server accepts the request. Which version's schema validates the object, and which version is written to etcd?
MCQ-16A `Widget` CRD serves `v1alpha1` and `v1`, with `v1` as the storage version. `v1` has `spec.size` and `spec.priority`; `v1alpha1` has only `spec.replicas`, which the webhook maps to `spec.size`. The `v1alpha1`→`v1` conversion sets `spec.priority` to `0` because `v1alpha1` has no field for it. A `v1` client creates a Widget with `priority: 10`. A `v1alpha1` client then reads it, changes `replicas` from `3` to `5`, and writes it back. The next `v1` read shows `priority: 0`. Which change prevents the `v1alpha1` write from resetting `priority`?
MCQ-15A CRD `widgets.example.com` serves v1alpha1 and v1beta1, with v1alpha1 marked `storage: true`. All 40,000 Widget objects were created through v1alpha1, so `status.storedVersions` is `["v1alpha1"]`. The team sets `storage: true` on v1beta1 and then removes v1alpha1 from `spec.versions`; the API server rejects the update because v1alpha1 is still in `status.storedVersions`. The API cannot be taken down and no Widget data can be lost. What has to happen before v1alpha1 can be removed?
MCQ-18A mutating admission webhook for a `Database` custom resource calls the cloud provider's API to create the backing database before the object is admitted. The webhook's `timeoutSeconds` is 10. When the provider's API began taking 30 s per call, every `kubectl apply` of a `Database` started failing with `failed calling webhook` errors after the 10 s timeout. Which responsibility should be moved out of the admission path?
MCQ-17A platform team's `Widget` CRD is validated by a webhook with a p99 of 180 ms; the webhook was unreachable for 40 minutes last month and three Widgets with `replicas > maxReplicas` were admitted. They add this to the CRD and plan to delete the webhook: ```yaml x-kubernetes-validations: - rule: "self.spec.replicas <= self.spec.maxReplicas" message: "replicas must not exceed maxReplicas" ``` They also need to reject a Widget whose `spec.ownerTeam` does not match the `team` label on the Namespace it is created in. After the CRD is applied, what should they expect?
MCQ-19A cluster runs two mutating admission webhooks. `inject-sidecar` appends a container named `envoy-sidecar` to `spec.containers` of every Pod; it is registered with `reinvocationPolicy: IfNeeded` and the default `failurePolicy: Fail`. `add-defaults` runs after it and adds the annotation `defaults.example.com/applied: "true"` and a `nodeSelector` that `inject-sidecar` reads to choose the sidecar image. Pod creation now fails with `spec.containers[1].name: Duplicate value: "envoy-sidecar"`, and the audit log shows `inject-sidecar` mutating each failing Pod twice. Which change makes Pod creation succeed while keeping the sidecar image selection working?
MCQ-20A controller reconciles 4,000 Deployments on a 30-second resync. Each pass builds a desired child Service in Go with only the fields it manages (selector, ports, ownerReferences) and writes it with `Update` against the object from the informer cache. The apiserver records ~133 Service writes/s, and the controller's own watch on Services re-enqueues the parents, so the loop never settles. The team adds a guard: ```go if !equality.Semantic.DeepEqual(desired.Spec, live.Spec) { client.Update(ctx, desired) } ``` The write rate is unchanged. Which change makes the guard suppress the writes?
MCQ-22`tenant-operator` runs in the `platform` namespace. It reconciles the cluster-scoped `Tenant` custom resource: for each Tenant it creates a Deployment and a Service in that tenant's namespace and writes back to `Tenant.status`. Tenant namespaces are created by a separate provisioning pipeline, so the operator does not know their names at build time. It holds a leader-election Lease named `tenant-operator-lock` in `platform`. A security review asks you to replace its current cluster-admin binding. Which RBAC set is both sufficient and least-privilege?
MCQ-23Three replicas of a controller elect a leader with a Kubernetes Lease (leaseDuration 15s, renewDeadline 10s, retryPeriod 2s); NTP keeps the nodes within 50 ms of each other. Leader A issues a create-load-balancer call at t=1s and is then frozen by a 90-second stop-the-world pause; the provider creates the load balancer at t=2s. A's lease expires at t=15s, B acquires it at t=16s and creates a second load balancer, and A's call returns at t=90s. Which statement explains why the lease did not prevent the duplicate?
MCQ-24A `Database` operator reconciles every 10 seconds and rewrites the whole `Ready` condition on each pass, including `lastTransitionTime`. The CRD's status schema declares every condition field, and the series `db_condition_last_transition_time{type="Ready",status="False"}` is present in every scrape. The alert rule is `time() - db_condition_last_transition_time{type="Ready",status="False"} > 300`. A database's connection has failed continuously for two hours, and every reconcile has written `status: "False"` with the current error in `message`. The alert has never fired. Why?