What is the kubelet responsible for on a Kubernetes worker node, and what does its pod sync loop actually do?
answer
- node agent: PodSpec -> running containers
- 3 pod sources: apiserver watch, manifest dir, HTTP
- sync loop: admit, mount, pull, sandbox, init, probes
- reports pod status + node conditions + Lease
- no scheduling, no replicas, no etcd
basics
~20 sThe kubelet is the node agent. It watches the API server for Pods assigned to its node, tells the container runtime to create the containers described in each PodSpec, mounts volumes, runs probes, and reports Pod and node status back. It manages Pods only, not Deployments or ReplicaSets.
solid answer
~50 sThe kubelet is the per-node agent that makes reality match the PodSpecs assigned to that node. Its loop: it receives Pods from three sources — the API server (a watch filtered by `spec.nodeName`), static-pod manifest files on disk, and an HTTP endpoint — merges them into a desired set, and compares that against what is actually running via the Container Runtime Interface. For each difference it acts: pull images (respecting `imagePullPolicy` and pull secrets), set up volumes, ask the runtime to create the pod sandbox and containers, apply resource limits, run init containers in order, then run liveness/readiness/startup probes and restart containers per `restartPolicy`. It also **reports**: patching Pod status and, for the node, capacity, conditions and a renewed Lease object as a lightweight heartbeat. What it does *not* do: it never creates Pods on its own to satisfy a Deployment, never schedules, and never talks to etcd.
code
bash · 7 linessystemctl status kubelet
journalctl -u kubelet -f
# the kubelet's own view of running pods
curl -sk https://localhost:10250/pods --cert /var/lib/kubelet/pki/kubelet-client-current.pem
kubectl describe pod web-7d9f # the Events section is written by the kubeletgo deeper
Say clearly that kubelet is the node agent that runs and watches the containers of Pods assigned to its node and reports their status.
Describe the sync loop concretely — pod sources, admission, volumes, image pull, sandbox, init containers, probes, status — and the kubelet/controller division of labour.
Bring in node-level duties: registration, Lease heartbeats, node-pressure eviction, image and container GC, and how you debug through kubelet events and journal logs.
Discuss the kubelet as the trust and blast-radius boundary of a node — what a node may assert about itself, NodeRestriction, port 10250 exposure, and how much autonomy nodes should have when the control plane is unreachable.
## The kubelet's job Every Kubernetes node runs a kubelet. It is the component that turns declarative Pod objects into running containers on that specific machine. It is deliberately narrow: it understands Pods and nothing above them. Deployments, ReplicaSets, StatefulSets and Jobs are controller-manager concerns; by the time the kubelet sees anything, the scheduler has already set `spec.nodeName` and the object is just "a Pod that belongs to me". ## Where Pods come from The kubelet merges three pod sources into one desired state: 1. **The API server** — a watch for Pods whose `spec.nodeName` equals this node. The normal path. 2. **A manifest directory on disk** (commonly `/etc/kubernetes/manifests`) — static pods, run without any control-plane involvement. 3. **An HTTP endpoint** — rarely used. ## The sync loop The kubelet runs a reconciliation loop driven by pod-source updates, periodic resyncs and runtime events. For each pod it computes what is needed to make the node match the PodSpec: - **Admit the pod**: does the node have the resources, do node selectors and taints still hold, are required devices present? A rejected pod ends in phase Failed with a reason such as `OutOfmemory`. - **Set up volumes**: attach and mount via the volume manager and CSI drivers; fetch ConfigMap and Secret contents and project them into files. - **Pull images**: honoring `imagePullPolicy` (`IfNotPresent`, `Always`, `Never`) and image pull secrets. Failures surface as `ErrImagePull` and `ImagePullBackOff`. - **Create the pod sandbox**: the shared network and IPC context for the pod, which is when the CNI plugin is invoked to give the pod its IP. - **Run init containers** sequentially to completion, then start the main containers with their commands, environment, resource requests and limits, and security context. - **Enforce lifecycle**: run startup, liveness and readiness probes; restart failed containers per `restartPolicy` with exponential backoff (the familiar `CrashLoopBackOff`); run preStop hooks and honor `terminationGracePeriodSeconds` on deletion. - **Report status**: update the Pod's `status` (phase, container statuses, conditions, pod IP) through the API server so controllers and Services react. An important consequence: **the kubelet enforces the PodSpec, it does not negotiate with it.** A Pod is effectively immutable in the fields that matter, so "updating" a workload means a controller creates a new Pod and deletes the old one. The kubelet just enforces whatever spec it holds. ## Node-level duties Beyond pods, the kubelet: - **Registers the node** on startup, creating the Node object with capacity, labels and runtime version. - **Heartbeats** by renewing a Lease object in the `kube-node-lease` namespace every few seconds, and updates Node conditions (Ready, MemoryPressure, DiskPressure, PIDPressure) less often. - **Evicts pods under node pressure** when memory or disk cross configured thresholds, choosing victims by QoS class and usage relative to requests. - **Garbage-collects** dead containers and unused images to keep disk usage bounded. - **Serves its own API** on port 10250 for `kubectl logs`, `exec`, `attach` and `port-forward`, and exposes container metrics. ## What it is not Worth stating explicitly in an interview: - The kubelet does **not** schedule. It does not choose which node a pod runs on; it runs what is assigned. - It does **not** manage replicas. Delete a container by hand and the kubelet restarts it because the PodSpec says so; delete the whole Pod and recreating it is the ReplicaSet controller's job. - It does **not** talk to etcd, and it does **not** program Service routing — that is kube-proxy or a CNI dataplane on the same node. - It is normally **not itself a container**: kubelet runs as a host process (usually a systemd unit), which is exactly what lets it bootstrap the rest of the control plane as static pods. ## Diagnosing through the kubelet When a Pod is stuck, the kubelet is where the truth lives: `kubectl describe pod` shows kubelet-written events (image pull failures, mount failures, failed probes, admission rejections), and `journalctl -u kubelet` on the node shows the rest. A node that is NotReady while its Pods still serve traffic usually means the kubelet stopped heartbeating, not that the workloads died.
- If you stop the kubelet on a node, what happens to the Pods already running there?They keep running — the container runtime is a separate process and nothing tells it to stop. What breaks is management: no probes, no restarts, no status updates, and no Lease renewal, so the node goes NotReady after the grace period and the node controller begins evicting its Pods in the API. The containers linger until the kubelet returns and reconciles, or someone cleans them up on the host.
- A container in a Pod is killed manually on the node with `crictl stop`. Who restarts it, and what if the whole Pod object is deleted instead?The kubelet restarts the container, because the PodSpec it holds still says that container should run, subject to restartPolicy and backoff. If the Pod object itself is deleted, the kubelet tears everything down and does not recreate it — creating a replacement replica is the ReplicaSet or other workload controller's job in the control plane.
The kubelet is the site foreman: head office decides which building goes on which lot; the foreman only makes that lot match the blueprint and phones in progress.
saying these in an interview costs you the question
- Saying the kubelet schedules Pods onto nodes
- Claiming the kubelet recreates a deleted Pod (that is the workload controller)
- Saying the kubelet talks to etcd directly
- Confusing kubelet with kube-proxy and giving it Service routing duties
- Believing the kubelet manages Deployments or ReplicaSets