Kubernetes CKA sample exam question 25 with answer

Question
A pod my-nginx-pod (image=nginx) in custom namespace is not running. Find the problem and fix it and make it running.
Note: All the supported definition files has been placed at /root

Answer
Get some details:

kubectl -n custom get po
we can see that the pod my-nginx-pod is in the Pending state.
Get more details - look in pod events section:
kubectl -n custom describe po my-nginx-pod
In events we can see that the:
persistentvolumeclaim "pv-claim-log" not found
List all PVs and check the bound for pv-claim-log:
kubectl get pv
we can see that the volume mypvlog is in the Bound state and it's claim to default/pv-claim-log.
Note that the PVCs are namespaced so the namespace should be custom and not default.
So - to fix this, it is needed to recreate PV and PVC. PVC should be in namespace custom:
kubectl delete pvc pv-claim-log
kubectl delete pv mypvlog
Open pvc definition file and add namespace:
..
metadata:
  name: pv-claim-log
  namespace: custom
...
Save and recreate:
kubectl apply -f pv.yaml
kubectl apply -f pvc.yaml
Check, the claim should be in Bound state:
kubectl -n custom get pvc
kubectl get pv
Check the pod status now:
kubectl -n custom get po
Pod is in Running state. This solved the issue.