Skip to content
Visual explainer 4h to learn 4 steps

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.

Topic 27 of 33

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.

FlowFixing a broken component
  1. 1
    Spot symptoms

    kubectl refused, Pods Pending, or ReplicaSets not acting.

  2. 2
    Check containers

    crictl ps -a on the control plane node.

  3. 3
    Read logs

    crictl logs or /var/log/pods for the component.

  4. 4
    Fix the manifest

    Edit /etc/kubernetes/manifests/COMPONENT.yaml.

  5. 5
    Wait for restart

    kubelet recreates the static Pod automatically.

SequenceWhat happens after you save a broken manifest
You
kubelet
containerd
kube-apiserver
  1. 1Save kube-apiserver.yaml with a typo
    You to kubelet: Save kube-apiserver.yaml with a typo
  2. 2Stop old container, start new one
    kubelet to containerd: Stop old container, start new one
  3. 3Run binary with the bad flag
    containerd to kube-apiserver: Run binary with the bad flag
  4. 4Exit 1: unknown flag
    kube-apiserver to containerd: Exit 1: unknown flag
  5. 5Restart with back-off, again and again
    kubelet to containerd: Restart with back-off, again and again
  6. 6crictl ps -a, crictl logs ID
    You to containerd: crictl 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.

CompareSymptom to suspect
API server or etcd
  • kubectl: connection refused
  • Every command fails
  • Debug with crictl on the node
Scheduler
  • kubectl works
  • New Pods Pending, no events
  • Pods with nodeName still run
Controller manager
  • 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.

  1. 1
    Locate static Pod manifests~1h
  2. 2
    Diagnose a broken API server~1h
  3. 3
    Fix the scheduler or controller manager~1h
  4. 4
    Read 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

bash
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.yaml

The 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.

bash
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 nodes

Deployments 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.

bash
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 -w

Quick 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.

Question 1

1kubectl works, but every new Pod stays Pending with no events, while Pods with spec.nodeName set run fine. Which component is broken?

Question 2

2After editing kube-apiserver.yaml, crictl ps -a shows no kube-apiserver container at all. Where is the error message?

Question 3

3You copied kube-scheduler.yaml to /etc/kubernetes/manifests/kube-scheduler.bak.yaml before editing. What risk does that create?

Question 4

4The API server logs show repeated timeouts connecting to https://127.0.0.1:2380. What is wrong?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. 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.

  2. 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.

  3. 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.

Go deeper

ShareXLinkedInWhatsApp