Skip to content
LF Cert Trainer

Lesson 140 · Section 12: Troubleshooting

Lesson 140: Control plane failure: when the API server, scheduler, controller manager or etcd breaks

How to tell which control plane component failed from the symptom alone, how to read its status and logs with kubectl, or with crictl and the kubelet journal when the API server is down, and how to fix the usual faults in static Pod manifests. · 24 min read · 3 min video

1/9Control plane failure
0:00 / 3:12

Narrated by the local narrator voice. Keys: Space plays and pauses, J and L step, C captions, F full screen.

Why control plane failures look so strange

When an application breaks, its own users notice. When a control plane component breaks, the whole cluster changes behaviour, often in ways that seem unrelated: a new Deployment shows 0/3 and never moves, Pods sit in Pending with no explanation, kubectl hangs for half a minute and then gives up. Existing applications usually keep running, because the kubelets and kube-proxy carry on with what they already know, which makes the failure even harder to spot.

The good news is that every component has exactly one job. If you know the jobs, the symptom tells you which component to look at before you run a single command.

Read the component from the symptom

Which component is broken? Read it from the symptom64432379watcheswatchesstatic Podskubectlrefused or hangskube-apiserverport 6443etcdport 2379kube-schedulerPods stay Pendingcontroller-managerno Pods createdkubeletruns them all
Which component is broken? Read it from the symptom. Each control plane component has one job, so each failure has its own signature. kubectl that hangs is the API server or etcd; Pods that stay Pending with no events is the scheduler; Deployments that create nothing is the controller manager.

Parts:

  • kubectl (refused or hangs)
  • kube-apiserver (port 6443)
  • etcd (port 2379)
  • kube-scheduler (Pods stay Pending)
  • controller-manager (no Pods created)
  • kubelet (runs them all)

Connections:

  • kubectl to kube-apiserver: 6443
  • kube-apiserver to etcd: 2379
  • kube-scheduler to kube-apiserver: watches
  • controller-manager to kube-apiserver: watches
  • kubelet to kube-apiserver: static Pods
ComponentIts jobWhen it fails you see
kube-apiserverThe front door: every read and write in the cluster goes through itkubectl: connection refused on 6443, TLS handshake timeout, or a hang; nothing else can change
etcdStores the whole cluster stateThe API server fails to start or answers with etcdserver: request timed out, context deadline exceeded
kube-schedulerChooses a node for each new PodNew Pods stay Pending, NODE is <none>, and there are no FailedScheduling events (nobody is trying)
kube-controller-managerRuns the controllers: ReplicaSets create Pods, Deployments create ReplicaSets, nodes are marked NotReady, tokens are madeA new Deployment has no ReplicaSet or no Pods; scaling does nothing; deleted Pods are not replaced
kubelet (on the control plane node)Runs the four above as static PodsAll of them disappear at once

Static Pods and where their logs go

How a static Pod manifest becomes a running componentwatchedstartsreportswriteskube-apiserver.yaml/etc/kubernetes/manifestskubeletstaticPodPathcontainerdcrictl ps -aMirror Podkubectl get podsContainer logs/var/log/pods
How a static Pod manifest becomes a running component. The kubelet watches /etc/kubernetes/manifests and starts a container for every file. Save a broken file and the component disappears or crash loops; save the fix and the kubelet restarts it within seconds.

Parts:

  • kube-apiserver.yaml (/etc/kubernetes/manifests)
  • kubelet (staticPodPath)
  • containerd (crictl ps -a)
  • Mirror Pod (kubectl get pods)
  • Container logs (/var/log/pods)

Connections:

  • kube-apiserver.yaml to kubelet: watched
  • kubelet to containerd: starts
  • kubelet to Mirror Pod: reports
  • containerd to Container logs: writes

kubeadm runs the control plane as static Pods: YAML files in /etc/kubernetes/manifests/ that the kubelet starts directly, with no scheduler and no API server involved. The kubelet finds the folder through staticPodPath in its configuration (/var/lib/kubelet/config.yaml).

/etc/kubernetes/manifests/
├── etcd.yaml
├── kube-apiserver.yaml
├── kube-controller-manager.yaml
└── kube-scheduler.yaml

Three things follow from this design:

  • Editing a file is the fix. The kubelet notices the change, stops the old container and starts a new one, usually within 20 seconds. kubectl edit on the mirror Pod does nothing lasting.
  • The logs live on the node. Every container writes to /var/log/pods/<namespace>_<pod>_<uid>/<container>/ (with symlinks in /var/log/containers/). kubectl logs reads them through the kubelet; crictl logs reads them directly.
  • A broken file can make the Pod vanish. If the YAML does not parse, the kubelet cannot create the Pod at all, so there is no container to inspect. Then the kubelet's own journal is the only place that says why.
Under the hood · Clusters that run the control plane as services

Some clusters (built "the hard way", or by other installers) run the components as systemd services instead of static Pods. The method is the same, only the tools change:

systemctl status kube-apiserver kube-controller-manager kube-scheduler etcd
journalctl -u kube-apiserver --no-pager | tail -n 30
cat /etc/systemd/system/kube-apiserver.service      # the flags live here
systemctl daemon-reload && systemctl restart kube-apiserver

Check ls /etc/kubernetes/manifests first: if the files are there, it is a kubeadm-style cluster.

When the API server answers

Use kubectl as you would for any application, in the kube-system namespace:

kubectl -n kube-system get pods
kubectl -n kube-system describe pod kube-controller-manager-controlplane
kubectl -n kube-system logs kube-controller-manager-controlplane
kubectl get --raw='/readyz?verbose' | grep -v '+'      # only the failing checks
kubectl -n kube-system get lease                      # is there an active scheduler and controller manager?

Example · A Deployment that never gets Pods

Task: the Deployment api in namespace shop was created ten minutes ago but has no Pods.

kubectl -n shop get deploy,rs,pods
NAME                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/api   0/2     0            0           10m

No resources found in shop namespace.   # no ReplicaSet, no Pods

No ReplicaSet at all: the Deployment controller never ran. That is the controller manager.

kubectl -n kube-system get pods | grep controller-manager
kubectl -n kube-system logs kube-controller-manager-controlplane | tail -n 3
kube-controller-manager-controlplane   0/1   CrashLoopBackOff   7    12m
Error: unknown flag: --cluster-signing-cert-fil

A misspelled flag. Fix it in the manifest on the control plane node, then watch it come back:

cp /etc/kubernetes/manifests/kube-controller-manager.yaml /root/kcm.yaml.bak
vi /etc/kubernetes/manifests/kube-controller-manager.yaml   # --cluster-signing-cert-file=...
watch crictl ps --name kube-controller-manager
kubectl -n shop get rs,pods                                  # the ReplicaSet and its Pods appear

When the API server is down

When kubectl cannot talk to the API server, go to the nodereadsthencontainer idfixYoussh controlplanejournalctl -u kubeletkubelet's viewcrictl ps -aExited containerscrictl logsthe error lineManifestfix the flag
When kubectl cannot talk to the API server, go to the node. With the API server down, kubectl is blind. The kubelet and containerd keep working, so their tools still show what is running, what died and why.

Parts:

  • You (ssh controlplane)
  • journalctl -u kubelet (kubelet's view)
  • crictl ps -a (Exited containers)
  • crictl logs (the error line)
  • Manifest (fix the flag)

Connections:

  • You to journalctl -u kubelet: reads
  • journalctl -u kubelet to crictl ps -a: then
  • crictl ps -a to crictl logs: container id
  • crictl logs to Manifest: fix

Without the API server, kubectl is blind, but the node is not. The kubelet and containerd keep running, and crictl talks to containerd directly:

CommandWhat it shows
crictl ps -aAll containers, including Exited ones, with an ATTEMPT counter
crictl ps -a --name kube-apiserverOnly that component
crictl logs <container-id>The container's output; add 2>&1 because most components log to stderr
crictl podsThe Pod sandboxes; a missing one means the kubelet never created the Pod
crictl inspect <container-id>The full container config, including the command line it was started with
journalctl -u kubelet -fThe kubelet's view: manifest parse errors, image pull failures, sandbox errors
ls /var/log/pods/The log files themselves, still there when the container is gone

Example · kubectl is refused

kubectl get nodes
The connection to the server 192.168.56.10:6443 was refused - did you specify the right host or port?

Log in to the control plane node and look for the API server container:

ssh controlplane
crictl ps -a --name kube-apiserver
crictl logs $(crictl ps -a --name kube-apiserver -q | head -n 1) 2>&1 | tail -n 5
CONTAINER      IMAGE          CREATED          STATE     NAME             ATTEMPT
4f1c2a9e7d3b   c2e4f1a9b0d7   20 seconds ago   Exited    kube-apiserver   6

E1204 09:20:30 run.go:72] "command failed" err="open /etc/kubernetes/pki/apiserver.crtt: no such file or directory"

The certificate path has a typo. Fix the flag and wait:

cp /etc/kubernetes/manifests/kube-apiserver.yaml /root/kube-apiserver.yaml.bak
sed -i 's#apiserver.crtt#apiserver.crt#' /etc/kubernetes/manifests/kube-apiserver.yaml
watch crictl ps --name kube-apiserver        # Running, ATTEMPT stops growing
kubectl get nodes

Example · No container at all

crictl ps -a --name kube-apiserver returns nothing, not even an exited container. The kubelet never got as far as creating it. Ask the kubelet:

journalctl -u kubelet --no-pager | grep -i apiserver | tail -n 5
"Could not process manifest file" err="/etc/kubernetes/manifests/kube-apiserver.yaml: couldn't parse as pod(yaml: line 41: mapping values are not allowed in this context)"

The YAML itself is broken, here an indentation error on line 41. Open the file at that line, compare with your backup or with another manifest, and fix the indentation.

Example · The API server cannot reach etcd

The API server starts, then exits after about 20 seconds. Its logs show connection attempts to etcd:

grpc: addrConn.createTransport failed to connect to {Addr: "127.0.0.1:2380"} ... connection refused
Error creating leases: error creating storage factory: context deadline exceeded

Port 2380 is etcd's peer port, used between etcd members. Clients such as the API server use 2379. Compare the API server's etcd flags with what etcd really serves:

grep etcd /etc/kubernetes/manifests/kube-apiserver.yaml
grep -E 'listen-client-urls|advertise-client-urls|cert-file|key-file|trusted-ca' /etc/kubernetes/manifests/etcd.yaml
API server flagMust match
--etcd-servers=https://127.0.0.1:2379etcd's --listen-client-urls
--etcd-cafile=/etc/kubernetes/pki/etcd/ca.crtThe CA that signed etcd's server certificate
--etcd-certfile, --etcd-keyfileA client certificate etcd trusts (apiserver-etcd-client.crt)

If etcd itself is the one exiting, read its logs the same way (crictl logs), and check its data directory (--data-dir, and the hostPath of the etcd-data volume) after a restore.

Faults the exam plants

FaultWhere it showsFix
Misspelled or unknown flagError: unknown flag: --... in the logsCorrect the flag; kube-apiserver -h inside the image lists them
Path to a file that does not existno such file or directory in the logsCorrect the path in the flag, or the hostPath/mountPath that should make it visible
Wrong etcd address or portconnection refused to :2380, context deadline exceeded--etcd-servers=https://127.0.0.1:2379
Wrong image or tagErrImagePull in journalctl -u kubelet or crictl eventsUse the image tag of the other components (same version)
Wrong kubeconfig in scheduler or controller managerUnauthorized, connection refused, or no such file for --kubeconfig/etc/kubernetes/scheduler.conf, /etc/kubernetes/controller-manager.conf
Broken YAMLNo container at all; couldn't parse as pod in the kubelet journalFix indentation
Wrong staticPodPath in the kubelet configAll four components gonestaticPodPath: /etc/kubernetes/manifests in /var/lib/kubelet/config.yaml, then systemctl restart kubelet
Your own kubeconfig is wrongOnly your kubectl fails; components are Running in crictlserver: and certificates in ~/.kube/config

Tricks

Common mistakes

  • Editing the mirror Pod. kubectl edit pod kube-apiserver-controlplane cannot change a static Pod. Edit the file on the node.
  • Leaving a backup in the manifests folder. The kubelet runs every file there, and two API servers on one port break each other.
  • Not waiting. The kubelet needs up to 20 seconds to notice a change, then the component needs time to start. Watch crictl ps instead of editing again.
  • Reading crictl logs without 2>&1. Most components log to stderr; piping only stdout to tail or grep shows nothing.
  • Confusing 2379 and 2380. Clients use 2379. 2380 is for etcd members talking to each other.
  • Blaming the API server for a kubeconfig problem. If crictl ps shows it running and stable, test with kubectl --kubeconfig /etc/kubernetes/admin.conf get nodes before you touch the manifest.

Recap

  • Each component has one job, so the symptom names it: refused kubectl is the API server or etcd, silent Pending is the scheduler, nothing created is the controller manager.
  • On kubeadm they are static Pods: files in /etc/kubernetes/manifests, restarted by the kubelet when the file changes.
  • API server up: kubectl -n kube-system get pods, describe, logs.
  • API server down: on the node, crictl ps -a, crictl logs <id> 2>&1, journalctl -u kubelet.
  • The planted fault is usually one line: a flag, a path, an etcd port, an image tag or the YAML itself.

Official docs

Quiz: check what you learned

5 questions on this lesson · about 3 min · instant feedback. Missed questions come back in your review queue.

Sign in to take the quiz and keep your score.

Practise: try it on a real cluster

2 hands-on labs for this lesson. You get goals, not steps: any solution that reaches them passes.

  • A cluster with three faults at once, one in a worker node, one in the control plane and one in cluster networking, picked at random for each session. Find them with the troubleshooting method, repair them, and ship a release through the repaired cluster.

    Fix · Level 3 · challenge · target 40 min

  • kubectl is refused and the API server keeps restarting. Read the container logs on the node with crictl, follow the API server's complaint to the component behind it, and repair two static Pod manifests without losing any data.

    Fix · Level 3 · challenge · target 25 min

Discussion

Learners ask and answer questions here. Sign in to read and join the discussion.