Kubernetes interview question · Most asked
What is the reconciliation loop, and why is Kubernetes called declarative?
Summary
You declare the desired state of objects (three replicas of this image), and controllers run loops that observe the actual state, compare it with the desired state, and act to close the gap. You do not issue step-by-step commands; you change the desired state and the system converges.
Longer Answer
A Deployment controller creates a ReplicaSet; the ReplicaSet controller creates or deletes pods until the count matches; the scheduler binds unscheduled pods to nodes; the kubelet starts their containers. If a node dies, the pods disappear and the ReplicaSet controller creates replacements, with no human involved.
Consequences: operations should be idempotent and retried; kubectl apply of manifests from Git (GitOps) fits naturally; and manual kubectl edit changes drift from the source of truth and get overwritten. Operators extend the same pattern to your own resources.
Key Points
- Desired state stored in the API.
- Controllers observe, diff, act, repeat.
- Self-healing comes from reconciliation.
- Operators apply the pattern to custom resources.
More most-asked Kubernetes questions
- What happens, step by step, when you run kubectl apply for a Deployment?
- How does the scheduler place pods? Explain resource requests, node affinity, taints and tolerations.
- How do rolling updates work in a Deployment, and how do you roll back?
- Explain the Service types: ClusterIP, NodePort, LoadBalancer, ExternalName and headless.
- Deployment, StatefulSet, DaemonSet, Job and CronJob: when do you use each?
- Describe the Kubernetes architecture: what runs on the control plane and what runs on the nodes?
- ConfigMaps and Secrets: how do they differ, and how should secrets really be handled?
- What is the difference between resource requests and limits, and what are the QoS classes?