Ultimate Mock Exam for CKA- Exam4- Identify and fix the issue that occurs while running kubectl commands on cluster4?

Hello,
Please see the question:
Identify and fix the issue that occurs while running kubectl commands on cluster4?

Solution

Step 1: SSH into the Control Plane Node

ssh cluster4-controlplane

Step 2: Inspect the kube-apiserver Pod

Check the status of the kube-apiserver static pod:

crictl ps | grep kube-apiserver

Get the logs:

crictl logs <container_id>

Problem while executing

For me the crictl ps is not lising any api-server as it is not running
crictl ps
CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID POD NAMESPACE
3dce73dfa25a4 a389e107f4ff1 32 minutes ago Running kube-scheduler 1 c5d5670d3c95a kube-scheduler-cluster4-controlplane kube-system
b13c6f98eee49 8cab3d2a8bd0f 32 minutes ago Running kube-controller-manager 1 f5169c1a522c2 kube-controller-manager-cluster4-controlplane kube-system
63a1f43226af5 ead0a4a53df89 42 minutes ago Running coredns 0 dd47f9c81971b coredns-7484cd47db-rxz74 kube-system
e066b504dcf95 ead0a4a53df89 42 minutes ago Running coredns 0 17e75d3d486ec coredns-7484cd47db-xkmcp kube-system
fe5e393878470 c9fe3bce8a6d8 42 minutes ago Running kube-flannel 0 12cf5a1bd4e71 canal-6f5sg kube-system
9806ae768a55f feb26d4585d68 42 minutes ago Running calico-node 0 12cf5a1bd4e71 canal-6f5sg kube-system
09fa9927da43f 040f9f8aac8cd 42 minutes ago Running kube-proxy 0 452e9becccbe8 kube-proxy-t6nlp kube-system
918b36b61e218 a9e7e6b294baf 43 minutes ago Running etcd 0 7339754527762 etcd-cluster4-controlplane kube-system

Please suggest some good method of how to see the kube-pai server log if crictl ps doesnt give any pod name

Don’t run it just one time and expect it to be there. The point of this question is that api server is in crashloop so the pod starts, then it exits. You can see this behaviour by watching the output of crictl for 30 seconds or so

watch crictl ps -a

Press CTRL-C to stop the watch, just after the api server container reappears and use that container id to get the logs.

Note that there is more than one error to fix in this one :wink:

2 Likes