I'm using Java Fabric k8s client to get List of the PODs where phase is equal to "Running". I have 2 containers in the POD. What I noticed is getPods() method is returning POD as Running even one of the 2 containers is still not in READY state.
Why is this happening when all the containers in the pod are not in READY state?
CodePudding user response:
Running
is a Pod status state that is defined as:
"The Pod has been bound to a node, and all of the containers have been created. At least one container is still running, or is in the process of starting or restarting."
Just one of the Pod's containers needs to be booting up or running to sufficiently mark the whole Pod as Running
. Possible states are Pending, Running, Succeeded, Failed, Unknown
. Think of these as the highest-level description of the Pod state. Each of these states has a Pod condition array amongst other metadata that provide more details about the containers inside.
Ready
is a Pod condition which is a sub-state of a Pod status
(status.condition
). In simplest terms, when a Pod is marked as Ready
, it's fully booted up and able to accept traffic. Sometimes this does depend on how your Pod spec is set up; for example, if your Pod has a readinessProbe
, it reaches Ready
only if the readinessProbe
succeeds.
Example: kubectl get po
NAME READY STATUS RESTARTS AGE
nani-play-8b6b89455-9g674 1/1 Running 0 13s
If I explore deeper into the pod via kubectl describe po nani-play-8b6b89455-9g674
, amongst the other information is
Conditions:
Type Status
Initialized True
Ready True <----