Getting different Pod status from "kubectl get pod" and "kubectl describe pod" command

Viewed 804

I created a Pod with two container – one container was successfully created, while other container failed.

Now, when I execute below command then I see that “Status” is “Error”:

C:\Users\test123>kubectl get pod pod3-two-nginx-containers-port-error
NAME                                   READY   STATUS   RESTARTS   AGE
pod3-two-nginx-containers-port-error   1/2     Error    0          134m

But when I execute below command then I see that "Status" is "Running":

C:\Users\test123>kubectl describe pod pod3-two-nginx-containers-port-error
Name:         pod3-two-nginx-containers-port-error
Namespace:    default
Priority:     0
Node:         minikube/192.168.49.2
Start Time:   Thu, 18 Mar 2021 12:50:19 +0530
Labels:       <none>
Annotations:  <none>
Status:       Running
IP:           10.244.0.9
IPs:

Why Kubernetes is showing wrong statuses?

1 Answers

Kubernetes is not showing the wrong status.

  • From kubectl get pod <<POD_NAME>> command you get the Pod’s status.
  • From kubectl describe pod <<POD_NAME>> you get the Pod phase’s status. Read more about Pod phases status over here.

kubectl describe pod is giving you status as RUNNING because Pod has been bound to a node + all of the containers have been created + at least one container is still running. Same you can read over the link I have shared over.

kubectl get pod is giving you status as ERROR because Pod is not in healthy state. Right now I do not have link where you can read about what STATUS field means in kubectl get pod but probably I will find and share later.

Another way you can verify this is by running kubectl get pods --field-selector=status.phase=Running command. If you get you Pod listed here then it is another way you can be sure of that status shown in kubectl describe pod command is Pod phase's status.

Related