Troubleshooting
This part introduces how to troubleshoot various problems on Kubernetes, includes
Remember kubectl is always the most important tool when starting to troubleshoot any problems.

Listing Nodes

1
kubectl get nodes
2
kubectl describe node <node-name>
Copied!

Listing Pods

1
kubectl get pods -o wide
2
kubectl -n kube-system get pods -o wide
Copied!

Looking at Pod events

1
kubectl describe pod <pod-name>
Copied!

Looking at kube-apiserver logs

1
PODNAME=$(kubectl -n kube-system get pod -l component=kube-apiserver -o jsonpath='{.items[0].metadata.name}')
2
kubectl -n kube-system logs $PODNAME --tail 100
Copied!
If kube-apiserver is not running as kubelet static Pods, then use journalctl -u kube-apiserver command instead.

Looking at kube-controller-manager logs

1
PODNAME=$(kubectl -n kube-system get pod -l component=kube-controller-manager -o jsonpath='{.items[0].metadata.name}')
2
kubectl -n kube-system logs $PODNAME --tail 100
Copied!
If kube-controller-manager is not running as kubelet static Pods, then use journalctl -u kube-controller-manager command instead.

Looking at kube-scheduler logs

1
PODNAME=$(kubectl -n kube-system get pod -l component=kube-scheduler -o jsonpath='{.items[0].metadata.name}')
2
kubectl -n kube-system logs $PODNAME --tail 100
Copied!
If kube-scheduler is not running as kubelet static Pods, then use journalctl -u kube-scheduler command instead.

Looking at kube-dns logs

Kube-dns is usually running as addons. Each kube-dns Pod contains three containers and kubedns container's log could be got by
1
PODNAME=$(kubectl -n kube-system get pod -l k8s-app=kube-dns -o jsonpath='{.items[0].metadata.name}')
2
kubectl -n kube-system logs $PODNAME -c kubedns
Copied!

Looking at kubelet logs

SSH to the Node and then run
1
journalctl -l -u kubelet
Copied!

Looking at kube-proxy logs

Kube-proxy is usually running as daemonsets, whose logs could be got by
1
$ kubectl -n kube-system get pod -l component=kube-proxy
2
NAME READY STATUS RESTARTS AGE
3
kube-proxy-42zpn 1/1 Running 0 1d
4
kube-proxy-7gd4p 1/1 Running 0 3d
5
kube-proxy-87dbs 1/1 Running 0 4d
6
$ kubectl -n kube-system logs kube-proxy-42zpn
Copied!