Tech Interview RoomStudy guides

Kubernetes

Explain the Kubernetes architecture. What happens when you run kubectl apply on a Deployment?

Intermediate · 2 min read · Lesson 1 of 7 in Kubernetes

Control plane

  • kube-apiserver: the only component that talks to etcd; validates, authenticates and authorises every request (RBAC), runs admission controllers and webhooks, and serves watches.
  • etcd: a consistent, Raft-replicated key-value store holding all cluster state. Back it up.
  • kube-scheduler: assigns unscheduled pods to nodes by filtering (resources, node selectors, taints and tolerations, affinity) and scoring.
  • kube-controller-manager: runs controllers (Deployment, ReplicaSet, Node, Job, EndpointSlice...), each a loop that drives actual state towards desired state.
  • cloud-controller-manager: integrates with the cloud (load balancers, node lifecycle, routes).

Nodes

  • kubelet: watches pods assigned to its node, asks the container runtime (containerd, CRI-O) to run them, mounts volumes, runs probes and reports status.
  • kube-proxy (or an eBPF CNI such as Cilium): implements Service virtual IPs.
  • CNI plugin: pod networking; CSI drivers: storage.

The core idea: declarative reconciliation

You declare desired state; independent controllers watch the API server and continuously reconcile. Nothing is a one-off imperative command.

kubectl apply -f deployment.yaml

  1. kubectl sends the manifest to the API server; authentication, RBAC and admission (mutating then validating webhooks, for example policy engines injecting defaults or sidecars) run; the Deployment is stored in etcd.
  2. The Deployment controller sees it and creates a ReplicaSet for the pod template hash.
  3. The ReplicaSet controller creates N Pod objects (with no node yet).
  4. The scheduler binds each pod to a node.
  5. The kubelet on that node pulls the image, creates the containers via CRI, sets up networking (CNI) and volumes (CSI), and starts probes.
  6. When readiness probes pass, the EndpointSlice controller adds the pod IPs to the Service, and traffic starts flowing.
  7. On a later image change, the Deployment controller creates a new ReplicaSet and scales new up and old down according to the rollout strategy.

Follow-up questions interviewers ask

Try answering each one before you open it.

What happens if a node dies?

The node controller marks it NotReady when heartbeats (node leases) stop; after a grace period (about 5 minutes by default via taint-based eviction) the pods are marked for deletion, and the ReplicaSet controller creates replacements, which the scheduler places on healthy nodes. StatefulSet pods are not replaced until the old pod is confirmed gone, to avoid two pods with the same identity. Use PodDisruptionBudgets and topology spread so that one node failure never removes all replicas.