Broken control plane components
Fix a broken API server, scheduler or controller manager via static Pod manifests.
By Invicly Tech, , in Kubernetes Administrator (CKA). About 10 minutes to read.
In short
In kubeadm clusters, the API server, scheduler, controller manager and etcd are static Pods. A typo in their manifests breaks the component, and if it is the API server, kubectl stops working. You then debug on the node with crictl, container logs and the manifests directly.
Explained simply
On a kubeadm cluster, the brain of Kubernetes (the API server, etcd, the scheduler and the controller manager) runs as static Pods. The kubelet on the control plane node reads their YAML files from /etc/kubernetes/manifests and keeps them running.
That means a single wrong line in one of those files can break a component. If it is the API server, kubectl stops working completely, so you cannot use kubectl to debug. You have to go to the node and look at the containers and files directly.
Each component breaks in its own recognizable way. API server down: every kubectl command fails. Scheduler down: new Pods stay Pending forever. Controller manager down: Deployments do not create Pods and scaling does nothing. etcd down: the API server crashes too.
The fix loop is always the same: find the failing container, read its log, correct the manifest, and let the kubelet restart it. Keep a backup copy of each file before you edit, but never inside the manifests folder.
Press Play on a diagram to walk through it one step at a time.
- 1Spot symptoms
kubectl refused, Pods Pending, or ReplicaSets not acting.
- 2Check containers
crictl ps -a on the control plane node.
- 3Read logs
crictl logs or /var/log/pods for the component.
- 4Fix the manifest
Edit /etc/kubernetes/manifests/COMPONENT.yaml.
- 5Wait for restart
kubelet recreates the static Pod automatically.
- You to kubelet: Save kube-apiserver.yaml with a typo1Save kube-apiserver.yaml with a typo
- kubelet to containerd: Stop old container, start new one2Stop old container, start new one
- containerd to kube-apiserver: Run binary with the bad flag3Run binary with the bad flag
- kube-apiserver to containerd: Exit 1: unknown flag4Exit 1: unknown flag
- kubelet to containerd: Restart with back-off, again and again5Restart with back-off, again and again
- You to containerd: crictl ps -a, crictl logs ID6crictl ps -a, crictl logs ID
In depth
Telling the components apart by symptom
The fastest path is to guess the broken component from what you see. kubectl answering The connection to the server ...:6443 was refused points at the API server (or etcd behind it). kubectl working but new Pods staying Pending with no scheduling events points at the scheduler. A Deployment that never creates a ReplicaSet, a scale command that changes nothing, or a dead node never marked NotReady points at the controller manager, which runs all those control loops.
When the API server is up, kubectl -n kube-system get pods shows the mirror Pods, and kubectl logs works for them. kubectl get --raw='/readyz?verbose' lists each internal check of the API server, including its etcd connection.
- kubectl: connection refused
- Every command fails
- Debug with crictl on the node
- kubectl works
- New Pods Pending, no events
- Pods with nodeName still run
- Deployments make no ReplicaSets
- Scaling does nothing
- Dead nodes not marked NotReady
Debugging without kubectl
When the API server is down, work on the control plane node with sudo. crictl ps -a lists all containers, including exited ones; a component restarting every few seconds shows a growing ATTEMPT count and status Exited. crictl logs CONTAINER_ID prints its output, usually ending in the exact flag or file it choked on. The same logs are files under /var/log/pods/kube-system_kube-apiserver-NODE_UID/.
If crictl shows no container at all for the component, the kubelet could not even parse the manifest, for example because of a YAML indentation error. Then the answer is in journalctl -u kubelet, which reports the manifest file it could not decode. crictl needs to know the runtime socket; on kubeadm nodes /etc/crictl.yaml usually sets runtime-endpoint: unix:///run/containerd/containerd.sock.
- sudo crictl ps -a --name kube-apiserver
- sudo crictl logs $(sudo crictl ps -a --name kube-apiserver -q | head -1)
- sudo journalctl -u kubelet --since '10 min ago' | grep -i manifest
The usual breakages in manifests
Exam tasks and real outages tend to repeat the same mistakes. A flag name with a typo makes the binary exit with unknown flag. A wrong file path, such as a certificate under /etc/kubernetes/pki that does not exist, gives no such file or directory; check that the path also exists inside a mounted hostPath volume. A wrong etcd address, such as port 2380 (peer traffic) instead of 2379 (client traffic) in --etcd-servers, makes the API server time out connecting to etcd.
Other classics: a wrong image tag (the static Pod stays in image pull errors), a liveness probe pointing at the wrong port so the kubelet keeps killing a healthy component, and a wrong kubeconfig path for the scheduler or controller manager (they use /etc/kubernetes/scheduler.conf and controller-manager.conf).
- API server 6443; etcd client 2379, peer 2380
- Scheduler health: https://127.0.0.1:10259/healthz
- Controller manager health: https://127.0.0.1:10257/healthz
Editing safely and waiting correctly
Copy the manifest to a folder outside /etc/kubernetes/manifests, such as /root/backup, before editing. The kubelet runs every manifest file in that folder, so a backup left there with another name starts a second copy of the component, which can fight the real one.
After you save, the kubelet notices the change within about 20 seconds and recreates the Pod. The API server then takes up to a minute to become ready, so do not panic and edit again too soon; watch with watch sudo crictl ps instead. A trick to force a restart without changing anything is to move the manifest out of the folder, wait until crictl shows the container gone, then move it back. Never restart containers with crictl stop and expect lasting fixes; the manifest is the source of truth.
Learn it in 4 short steps
About 1h each. Track them with a timer in your plan.
- 1Locate static Pod manifests~1h
- 2Diagnose a broken API server~1h
- 3Fix the scheduler or controller manager~1h
- 4Read component logs with crictl~1h
Key points
- Pods stuck Pending with no events often mean the scheduler is down.
- Deployments not creating Pods often mean the controller manager is down.
- If crictl shows nothing for a component, check kubelet logs for manifest errors.
- Back up a manifest outside the manifests directory before editing it.
Key terms
Tap a card to flip it. 0/4 known
Examples
kubectl get pods -n kube-system # may fail if API server is down
sudo crictl ps -a | grep -E "apiserver|scheduler|controller|etcd"
sudo crictl logs <container-id> 2>&1 | tail -20
ls /var/log/pods/ | grep kube-apiserver
sudo journalctl -u kubelet | grep -i apiserver | tail
sudo cp /etc/kubernetes/manifests/kube-apiserver.yaml /root/
sudo vim /etc/kubernetes/manifests/kube-apiserver.yamlThe API server will not come back
After a change, kubectl says connection refused. Step 1: list containers on the control plane; kube-apiserver keeps exiting. Step 2: read its log; the last line names the problem, here a certificate path with a typo. Step 3: back up and fix the manifest. Step 4: wait for the container to stay Running and kubectl to answer.
ssh cp1
sudo crictl ps -a --name kube-apiserver
sudo crictl logs $(sudo crictl ps -a --name kube-apiserver -q | head -1) 2>&1 | tail -3
# open /etc/kubernetes/pki/apiserver.crtt: no such file or directory
sudo cp /etc/kubernetes/manifests/kube-apiserver.yaml /root/
sudo sed -i 's#apiserver.crtt#apiserver.crt#' /etc/kubernetes/manifests/kube-apiserver.yaml
watch sudo crictl ps --name kube-apiserver
kubectl get nodesDeployments that never create Pods
kubectl create deployment works, but READY stays 0/1 and kubectl get rs shows nothing. Step 1: no ReplicaSet means the Deployment controller is not running, so look at the controller manager. Step 2: its mirror Pod is in CrashLoopBackOff. Step 3: the log says its kubeconfig file does not exist. Step 4: fix the --kubeconfig path in the manifest and watch the ReplicaSet appear.
kubectl get deploy,rs -l app=test
kubectl -n kube-system get pods | grep controller-manager
kubectl -n kube-system logs kube-controller-manager-cp1 | tail -3
# stat /etc/kubernetes/controller-manager.cnf: no such file or directory
sudo grep -n 'kubeconfig' /etc/kubernetes/manifests/kube-controller-manager.yaml
sudo sed -i 's#controller-manager.cnf#controller-manager.conf#g' \
/etc/kubernetes/manifests/kube-controller-manager.yaml
kubectl get rs -l app=test -wQuick reference
- Manifests: /etc/kubernetes/manifests; back up to /root, never next to them
- sudo crictl ps -a shows exited control plane containers and their ATTEMPT count
- No container at all = manifest cannot be parsed; read journalctl -u kubelet
- --etcd-servers must use client port 2379, not peer port 2380
- kubectl get --raw='/readyz?verbose' lists API server health checks
- Pending with no events = scheduler down; no ReplicaSets = controller manager down
- Logs on disk: /var/log/pods/kube-system_COMPONENT-NODE_UID/
Common mistakes
- Leaving a backup copy inside /etc/kubernetes/manifests, which kubelet also runs.
- Restarting kubelet repeatedly instead of reading the component logs.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
On the control plane node, list every control plane container with its state and write the ID of the etcd container to /opt/etcd-id.txt.
- Exercise 2medium
In a lab, break the scheduler by changing its image tag to one that does not exist, observe the symptoms, then fix it.
- Exercise 3hard
The API server is down after someone edited it. Find and fix the problem using only node tools, then prove the cluster is healthy.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- How do I restart the kube-apiserver in a kubeadm cluster?
- Edit or touch its manifest, or move kube-apiserver.yaml out of /etc/kubernetes/manifests and back. The kubelet stops and recreates the static Pod.
- Why can't I use kubectl to fix the API server?
- kubectl talks to the API server, so when that is down there is nothing to talk to. You must fix it on the node through its static Pod manifest.
- Where are control plane logs on a kubeadm cluster?
- Use kubectl logs on the mirror Pods if the API works, otherwise crictl logs or the files under /var/log/pods on the control plane node.