Core Kubernetes · 02
Architecture
1.What is in a cluster ?
Two halves. The control plane stores the state you asked for and keeps steering toward it. The nodes run your Pods. You need at least one.
- Control plane : kube-apiserver, etcd, kube-scheduler, kube-controller-manager, plus cloud-controller-manager on a cloud.
- Node : kubelet, a container runtime, usually kube-proxy.
- Add-ons : a CNI network plugin (required) and cluster DNS.
- Cloud : in-tree cloud code is gone since v1.31, so clouds run cloud-controller-manager.
2.Old words, new words
- masterSay control plane. kubeadm switched its node label in v1.24.
- minionSay node, or worker node.
- client-serverNo. Hub-and-spoke around kube-apiserver.
- dockershimGone in v1.24. Nodes use a CRI runtime.
- kube-dnsCoreDNS since v1.13, behind a Service still named kube-dns.
- /healthzDeprecated (v1.16), like componentstatuses (v1.19). Use
/livez,/readyz.
3.Who talks to whom
kube-apiserver is the hub. The others watch it and write back to it. Only kube-apiserver touches etcd.
Arrows point from the caller. Dashed : kube-apiserver calls the kubelet for logs, exec and port-forward. A CNI plugin such as Cilium can replace kube-proxy.
4.The parts, one by one
| Part | Runs on | Job | Port |
|---|---|---|---|
| kube-apiserver | Control plane | HTTP API, authn, authz, admission. Only etcd client. | 6443 |
| etcd | Control plane | Holds every API object, the cluster's only source of truth. Back it up. | 2379-2380 |
| kube-scheduler | Control plane | Gives each unscheduled Pod a node | 10259 |
| kube-controller-manager | Control plane | Built-in loops (Deployment, ReplicaSet, Node ...) | 10257 |
| cloud-controller-manager | Cloud only | Node, route and load balancer loops, cloud API | 10258 |
| kubelet | Every node | Registers the node, runs its Pods via CRI | 10250 |
| container runtime | Every node | Pulls images, makes Pod sandboxes and containers for the kubelet (CRI v1) | socket |
| kube-proxy (optional) | Every node | Packet rules for Service virtual IPs | 10256 |
| CNI plugin (add-on) | Every node | Pod IPs and Pod-to-Pod traffic | - |
| CoreDNS (add-on) | kube-system Pods | Cluster DNS for Services and Pods | - |
Ports are TCP. NodePort range : see Services.
In short : The control plane stores the desired state and reconciles toward it, each node's kubelet makes it real through a CRI runtime, and every part goes through kube-apiserver, the only one that touches etcd.
1.From apply to running
- 1-3, API :
kubectl applysends the Deployment over HTTPS. kube-apiserver checks it (authn, authz, mutating admission, validation, validating admission) and saves it in etcd. - 4-5, controllers : the Deployment controller makes a ReplicaSet, which makes Pods with no node yet (Pending).
- 6, scheduler : filters and scores the nodes, then posts a binding.
- 7-11, node : the kubelet sees the Pod and asks the runtime for a sandbox. The runtime calls CNI for the Pod IP, pulls the image, starts the containers. The kubelet reports Running.
No one calls the next step. Each part watches the API and reacts to a change.
2.Inside a node
- The kubelet registers its Node and renews a Lease in
kube-node-leaseas its heartbeat. - It drives the runtime over CRI gRPC on a local socket. CRI v1 only : containerd, CRI-O, or Docker via cri-dockerd.
- Static Pods : files in the kubelet's manifest folder run with no API server. kubeadm puts the control plane in
/.etc/ kubernetes/ manifests - Since v1.35 the kubelet refuses cgroup v1 unless overridden. v1.36+ needs containerd 2.0+.
3.kube-proxy is not the network
Key point
4.HA control plane
- 3+ control plane nodes, odd count for etcd quorum : 3 survive 1 loss, 5 survive 2.
- kube-apiserver : all copies active behind a load balancer (TCP check, 6443).
- Scheduler, controller-manager : one leader per Lease, the rest wait.
- Stacked etcd (kubeadm default) : fewer hosts, but a dead node takes an apiserver and an etcd member.
- External etcd : 3+ own hosts, failures stay apart.
Bottom row : scheduler and controller-manager, each with its own leader Lease.
5.Commands
| Command | Shows |
|---|---|
kubectl get nodes -o wide | Nodes, kubelet version, CONTAINER-RUNTIME column |
kubectl get pods -n kube-system -o wide | Static control plane Pods, CoreDNS, kube-proxy, CNI, and their nodes |
kubectl get --raw='/readyz?verbose' | API server checks one by one. /livez for liveness |
kubectl -n kube-system get lease -l apiserver.kubernetes.io/identity=kube-apiserver | One Lease per running kube-apiserver |
sudo crictl ps | On the node : containers via CRI, even with the API server down |
In short : Each step from apply to running is a loop reacting to an API change, the kubelet makes Pods real through CRI and CNI, and HA means 3+ control plane nodes behind a load balancer.