Troubleshooting a misconfigured kube-controller manager
Troubleshooting a misconfigured kube-controller manager#
Lab
The main role of a kube-controller manager is to check the health of running containers. This means that in a k8s cluster, if the kube-controller is not operational, it would be impossible to detect failed applications to trigger the sel-healing mechanism which is basically the k8s system trying to restart the pods. This means that probes would also fail.
context#
- The problem here is that the kube-controller manager pod is not comming on. its is stuck on the
CrashLoopBackstatus - we can confirm this with the command
kubectl get pods -n kube-system. This just lists all pods in thekube-systemnamespace - considering that the
kube-controller manageris a static pod, we can use the container runtime commands to check its logs. In context ofDocker, we would usedocker psbut our system usescri-oand thus we can list all running containers using the commandwatch crictl ps -a. the-aflag just specifies that we want to see even the failed container - The above commnad should list all running containers in the system even the failed and
kube-controller-managershould be there - Beaing a static pod, we can either use the
crictl logs container-id,journalctlor/var/log/syslogfile to check for errors
fix#
- Using the commad
crictl logs container-ID | grep -i errorwe get an output telling us that there is an error in the manifest file - The static pod’s manifest files are located in
/etc/kubernetes/manifests/ - a simple search on the patterns got from the error in the manifest file, we can get the rootcause of the error
- saving the manifest file will trigger the system to create another pod from the corrected manifest file. This might take awhile, alternatively, we can move the manifest file to another directory and put it back in the kubernetes manifests file. This will manualy trigger the creation of a new
kube-controller managerpod - running the command
kubectl get pods -n kube-systemwill show the pod in Running state