Kubernetes architecture

Mid-level Always asked 7 min

On this page

The question

What are the components of the Kubernetes control plane, and what does each one do?

30-second answer

Four main ones. The API server is the front door: every client and component talks to it, and it validates and stores objects. etcd is the consistent key-value store that holds the whole cluster state; only the API server touches it. The scheduler assigns new Pods to nodes, by their resource requests and constraints. The controller manager runs control loops, Deployment, ReplicaSet, node and others, that keep the actual state matching the desired one. A cloud controller manager adds load balancers and volumes from the cloud provider.

Understand it

Control plane and nodes

Tap the parts

Select a part to see what it does.

Tap a component. The left column is the control plane, which stores and decides; the right one is a worker node, which runs your Pods.

View as text

A cluster in two columns joined by one line: every component talks to the API server. On the left, the control plane: API server, etcd, scheduler and controller manager. On the right, one worker node: the kubelet, the container runtime, kube-proxy and the Pods it runs. A real cluster has several nodes, and usually three control plane machines.

API server: kube-apiserver is the front door: kubectl, controllers, the scheduler and every kubelet talk only to it.

etcd: etcd is a consistent key-value store, replicated with the Raft protocol, that holds every object: Deployments, Pods, Secrets, nodes.

Scheduler: kube-scheduler watches for Pods with no node.

Controllers: kube-controller-manager runs the control loops: Deployment, ReplicaSet, node, Job and more.

kubelet: The kubelet is the agent on every node.

Runtime: The container runtime, usually containerd or CRI-O, pulls images and runs containers.

kube-proxy: kube-proxy programs the node’s iptables or IPVS rules so that traffic to a Service’s virtual IP reaches one of its ready Pods.

Pods: Pods are where your containers run, each with its own IP from the CNI (Container Network Interface) plugin.

A cluster in two columns joined by one line: every component talks to the API server. On the left, the control plane: API server, etcd, scheduler and controller manager. On the right, one worker node: the kubelet, the container runtime, kube-proxy and the Pods it runs. A real cluster has several nodes, and usually three control plane machines.

API server: kube-apiserver is the front door: kubectl, controllers, the scheduler and every kubelet talk only to it.

etcd: etcd is a consistent key-value store, replicated with the Raft protocol, that holds every object: Deployments, Pods, Secrets, nodes.

Scheduler: kube-scheduler watches for Pods with no node.

Controllers: kube-controller-manager runs the control loops: Deployment, ReplicaSet, node, Job and more.

kubelet: The kubelet is the agent on every node.

Runtime: The container runtime, usually containerd or CRI-O, pulls images and runs containers.

kube-proxy: kube-proxy programs the node’s iptables or IPVS rules so that traffic to a Service’s virtual IP reaches one of its ready Pods.

Pods: Pods are where your containers run, each with its own IP from the CNI (Container Network Interface) plugin.

Takeaway: The control plane decides: the API server stores desired state in etcd, the scheduler places Pods and controllers keep reality matching. Each node executes: the kubelet runs Pods through the container runtime, and kube-proxy routes Service traffic.

What happens on kubectl apply

Step by step

kubectl apply sends the Deployment orders, 3 replicas, to the API server, which authenticates you, checks RBAC (role-based access control) permissions, runs admission and validates it.

Step 1 of 6
View as text

Six components around the API server: kubectl, the controller manager, the scheduler, etcd and a kubelet. Every arrow starts or ends at the API server; a line below says what etcd holds.

kubectl apply sends the Deployment orders, 3 replicas, to the API server, which authenticates you, checks RBAC (role-based access control) permissions, runs admission and validates it.

The API server writes the Deployment to etcd and answers deployment.apps/orders created. Nothing runs yet: only the desired state is recorded.

The Deployment controller, watching the API server, creates a ReplicaSet; the ReplicaSet controller creates 3 Pod objects. They have no node yet, so they are Pending.

The scheduler sees Pods without a node, keeps the nodes with enough free CPU and memory for their requests, scores them, and binds each Pod to one.

The kubelet on node-1 sees Pods bound to its node. Through the CRI (Container Runtime Interface) it has containerd pull the image and start the containers.

Each kubelet reports status back through the API server: Running, then Ready once the readiness probe passes. Actual state now matches desired state, until something changes.

Six components around the API server: kubectl, the controller manager, the scheduler, etcd and a kubelet. Every arrow starts or ends at the API server; a line below says what etcd holds.

kubectl apply sends the Deployment orders, 3 replicas, to the API server, which authenticates you, checks RBAC (role-based access control) permissions, runs admission and validates it.

The API server writes the Deployment to etcd and answers deployment.apps/orders created. Nothing runs yet: only the desired state is recorded.

The Deployment controller, watching the API server, creates a ReplicaSet; the ReplicaSet controller creates 3 Pod objects. They have no node yet, so they are Pending.

The scheduler sees Pods without a node, keeps the nodes with enough free CPU and memory for their requests, scores them, and binds each Pod to one.

The kubelet on node-1 sees Pods bound to its node. Through the CRI (Container Runtime Interface) it has containerd pull the image and start the containers.

Each kubelet reports status back through the API server: Running, then Ready once the readiness probe passes. Actual state now matches desired state, until something changes.

Takeaway: kubectl apply only stores desired state. Controllers, the scheduler and the kubelet each watch the API server and do one part: create Pods, bind them to nodes, start their containers. Nobody talks to etcd but the API server.

Every component talks to the API server, and only it talks to etcdkubectl, the scheduler, the controller manager and the kubelet on each node all talk to the API server, which alone reads and writes etcd. On each node, the kubelet drives the container runtime, which runs the Pods, and kube-proxy routes Service traffic to them.Each worker nodeControl planeAPI serveretcdSchedulerControllermanagerkubectlkubeletContainerruntimePodskube-proxy
Every component talks to the API server, and only it talks to etcdkubectl, the scheduler, the controller manager and the kubelet on each node all talk to the API server, which alone reads and writes etcd. On each node, the kubelet drives the container runtime, which runs the Pods, and kube-proxy routes Service traffic to them.Each worker nodeControl planeAPI serveretcdSchedulerControllermanagerkubectlkubeletContainerruntimePodskube-proxy
Every component talks to the API server, and only it talks to etcd

In code

kubectl get pods -n kube-system
# etcd-vip-verify-control-plane                      Running   <- the cluster's database
# kube-apiserver-vip-verify-control-plane            Running
# kube-controller-manager-vip-verify-control-plane   Running
# kube-scheduler-vip-verify-control-plane            Running
# kube-proxy-jsf97                                   Running   <- one per node
# coredns-7c65d6cfc9-bggz7                           Running   <- cluster DNS (Domain Name System)
kubectl get nodes -o wide            # each node's kubelet version and container runtime
The control plane is itself a set of Pods, here on a kind cluster
apiVersion: apps/v1
kind: Deployment
metadata:
  name: orders
spec:
  replicas: 3
  selector:
    matchLabels:
      app: orders
  template:
    metadata:
      labels:
        app: orders
    spec:
      containers:
        - name: orders
          image: registry.example.com/orders:1.4.2
          ports:
            - containerPort: 8080
          resources:
            requests:
              cpu: 250m
              memory: 512Mi
deployment.yaml: desired state, not instructions
kubectl apply -f deployment.yaml     # deployment.apps/orders created: stored, nothing runs yet
kubectl get events --sort-by=.lastTimestamp
# ScalingReplicaSet  orders                    Scaled up replica set orders-56fff5d9f5 to 3   <- Deployment controller
# SuccessfulCreate   orders-56fff5d9f5         Created pod: orders-56fff5d9f5-9jtpw           <- ReplicaSet controller
# Scheduled          orders-56fff5d9f5-9jtpw   Successfully assigned default/... to node-1    <- scheduler
# Pulling            orders-56fff5d9f5-9jtpw   Pulling image "registry.example.com/orders:1.4.2"  <- kubelet
# Started            orders-56fff5d9f5-9jtpw   Started container orders                       <- kubelet
Watch each component do its part, through the events it records
# Fixed by hand in production: the next deploy from Git silently undoes it
 Wrong kubectl scale deployment orders --replicas=5
 Wrong kubectl set image deployment/orders orders=registry.example.com/orders:1.4.3

# Change the file, commit it, apply it: Git and the cluster agree
 Right kubectl diff -f deployment.yaml
 Right kubectl apply -f deployment.yaml
Imperative changes drift from Git; apply the file instead
kubectl apply, one watch at a timekubectl sends the Deployment to the API server, which stores it in etcd and answers created. The controller manager, watching, creates a ReplicaSet and three Pods through the API server. The scheduler, watching unscheduled Pods, binds each to a node. The kubelet on that node, watching its Pods, starts the containers and reports their status.kubeletSchedulerControllersetcdAPI serverkubectlapply Deploymentstorecreatedcreate ReplicaSet, 3 Podsbind each Pod to a nodewatch: Pods for my nodestatus Running, Ready
kubectl apply, one watch at a timekubectl sends the Deployment to the API server, which stores it in etcd and answers created. The controller manager, watching, creates a ReplicaSet and three Pods through the API server. The scheduler, watching unscheduled Pods, binds each to a node. The kubelet on that node, watching its Pods, starts the containers and reports their status.kubeletSchedulerControllersetcdAPI serverkubectlapply Deploymentstorecreatedcreate ReplicaSet, 3 Podsbind each Pod to a nodewatch: Pods for my nodestatus Running, Ready
kubectl apply, one watch at a time

Solve it

The Pods stay Pending after kubectl apply

You apply a Deployment of 3 replicas and kubectl apply says created. Ten minutes later kubectl get pods still shows all three as Pending, with no restarts and no logs. The cluster has three nodes with 4 CPUs each. Find which component is stuck and fix it.

  1. Place Pending. Pending means the Pod object exists, so the API server, etcd and the controllers did their part. Either no node was chosen, which is the scheduler’s job, or the kubelet cannot pull the image.
  2. Read the events. kubectl describe pod ends with the events. Here it says FailedScheduling: 0/3 nodes are available: 3 Insufficient cpu. The scheduler found no node with enough unrequested CPU.
  3. Compare requests with what is free. The Deployment requests cpu: 6 per Pod, more than any node has. Scheduling counts requests, not actual usage, so even idle nodes cannot take it.
  4. Choose the fix. Lower the request to what the service really needs, measured, or add bigger nodes, or let the cluster autoscaler add them. Never set requests to zero to force scheduling.
  5. Check. After kubectl apply, the events show Scheduled for each Pod, then Pulling and Started, and the Deployment reports 3/3 available.
kubectl describe pod orders-56fff5d9f5-9jtpw | tail -3
# Warning  FailedScheduling  default-scheduler  0/3 nodes are available: 3 Insufficient cpu.
kubectl describe nodes | grep -A6 "Allocated resources"     # how much CPU is already requested
# In deployment.yaml, resources.requests.cpu: "6" becomes cpu: 500m, then:
kubectl apply -f deployment.yaml
kubectl rollout status deployment orders                      # successfully rolled out
Find the reason in the events, then request what the service needs

How to answer

  • Components never call each other; they watch the API server and write back to it.
  • etcd is the only stateful part; back it up, or the cluster forgets everything.
  • Production runs three or five control plane members so etcd keeps a majority if one fails.
  • Managed services such as EKS (Elastic Kubernetes Service), AKS (Azure Kubernetes Service) and GKE (Google Kubernetes Engine) run the control plane for you.

Common mistakes

  • Saying the scheduler starts containers. It only writes which node a Pod goes to.
  • Saying kubectl or the kubelet writes to etcd directly.

Follow-up questions

What runs on every worker node?

Three components besides your Pods. The kubelet, the node agent, watches the API server for Pods bound to its node, has the container runtime start them, runs their liveness and readiness probes and reports status. The container runtime, containerd or CRI-O, pulls images and runs containers through the CRI (Container Runtime Interface). kube-proxy programs iptables or IPVS rules so Service IPs reach ready Pods. A CNI (Container Network Interface) plugin gives every Pod its own IP.

  • The kubelet restarts failed containers locally, without asking the control plane.
  • DaemonSets run one Pod per node, for log shippers, monitoring agents and the network plugin.
  • Nodes report their capacity and conditions, such as memory pressure, through the kubelet.

See it in the infographic: Control plane and nodes

What happens, step by step, when you run kubectl apply -f deployment.yaml?

kubectl sends the manifest to the API server, which authenticates you, authorizes the request with RBAC (role-based access control), runs admission controllers, validates it and stores the Deployment in etcd; kubectl prints created. Then watchers react. The Deployment controller creates a ReplicaSet, and the ReplicaSet controller creates the Pods. The scheduler binds each Pod to a node. The kubelet on that node has the runtime pull the image and start the containers, then reports Running and Ready.

  • created means stored, not running; follow with kubectl rollout status.
  • Each step is a separate component reacting to a change it watches.
  • kubectl get events shows each step as it happens.

See it in the infographic: What happens on kubectl apply

Kubernetes is called declarative. What does that mean in practice?

You describe the desired state, 3 replicas of this image with these resources, and the cluster works out how to get there and keeps it there. Each controller runs a reconciliation loop: observe the actual state, compare it with the desired one, act to close the gap, repeat. Kill a Pod and the ReplicaSet controller creates another; lose a node and its Pods are recreated elsewhere. You never say start this container on that machine.

  • Desired state lives in objects; actual state is reported in their status fields.
  • Loops are level-based, not event-based, so a missed event is fixed on the next pass.
  • Operators extend the same pattern to your own resources, such as a PostgreSQL cluster.

See it in the infographic: What happens on kubectl apply

What is etcd, and what happens if you lose it?

etcd is a distributed, strongly consistent key-value store that holds every Kubernetes object: Deployments, Pods, Services, ConfigMaps, Secrets and the nodes themselves. It replicates with the Raft protocol and needs a majority of its members to accept writes. Lose quorum and the API server can no longer change anything; lose its data without a backup and the cluster forgets every workload, even though containers may still run on the nodes for a while.

  • Back up etcd with etcdctl snapshot save, and test the restore.
  • Secrets are stored base64-encoded unless encryption at rest is enabled.
  • Large or chatty objects slow etcd and the whole control plane.

See it in the infographic: Control plane and nodes

The whole control plane goes down for ten minutes. What happens to your running application?

It keeps serving. Running containers belong to the kubelets and the runtime on each node, and existing Service routing rules stay in place, so traffic flows. What stops is change: no deployments, no scaling, no scheduling of new Pods, and no rescheduling if a node dies. A crashed container is still restarted by its own kubelet. When the control plane returns, controllers reconcile whatever drifted in the meantime.

  • The data plane, nodes and Pods, keeps running without the control plane.
  • The autoscaler cannot react, so a traffic spike is not absorbed.
  • Managed control planes run on several zones to avoid this outage.

See it in the infographic: Control plane and nodes

Why three or five etcd members and not two or four?

etcd needs a majority, a quorum, to accept writes. With three members it survives losing one; with five, two. Four members still survive only one failure, since a majority of four is three, so an even count adds cost and no tolerance.

Check yourself

1. Which component decides on which node a new Pod runs?
Show answers
  • The scheduler: Correct. It filters and scores nodes by requests and constraints, then binds the Pod.
  • The kubelet: Incorrect. The kubelet only runs Pods already bound to its node.
  • The API server: Incorrect. It stores the binding the scheduler writes; it does not choose.
  • The controller manager: Incorrect. The ReplicaSet controller creates Pods without a node.
2. kubectl apply -f deployment.yaml prints deployment.apps/orders created. What is certainly true at that moment?
Show answers
  • The Deployment is stored in etcd: Correct. The API server answers once the object is stored; everything else happens after.
  • The 3 Pods are running: Incorrect. Controllers, the scheduler and kubelets have not necessarily acted yet.
  • The image is pulled on every node: Incorrect. Pulling happens later, on the nodes the Pods are scheduled to.
3. Which component reads and writes etcd directly?
Show answers
  • Only the API server: Correct. Every other component goes through the API server.
  • The API server and the scheduler: Incorrect. The scheduler writes bindings through the API server.
  • Every control plane component and every kubelet: Incorrect. That would skip authentication, validation and admission.