kubernetes: pod status shows "CrashLoopBackOff" but pod phase shows "Running"
What happened:
Here is a pod called test-worker-0 which created by stateful set. I run some command contains **exit 0 ** in this pod, so that the status keeps "CrashLoopBackOff" when I run
kubectl get pods test-worker-0
However, when I catch the phase field via kubectl get pods test-worker-0 -o yaml, it always shows as “Running”. The same issue happen via invoking kube-client python SDK read_namespaced_pod_status method
Is that a bug , or how can I catch the accurate status whenever this pod is in "CrashLoopBackOff" ?
What you expected to happen: phase field should show correctly when pod is CrashLoopBackOff
How to reproduce it (as minimally and precisely as possible):
- create a stateful set, which container.command just writes “exit 0”
- pod will keep
"CrashLoopBackOff"viakubectl get pods test-worker-0 - according to
kubectl get pods test-worker-0 -o yamlorread_namespaced_pod_status, phase field keep showing as“Running”
Anything else we need to know?:
Environment: centos 7.5
- Kubernetes version (use
kubectl version): 1.9.5 - Cloud provider or hardware configuration: on-premise
- OS (e.g:
cat /etc/os-release): CentOS Linux release 7.5.1804 (Core) - Kernel (e.g.
uname -a): Linux 3.10.0-862.3.3.el7.x86_64 #1 SMP Fri Jun 15 04:15:27 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux - Install tools:
- Others:
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 6
- Comments: 15 (7 by maintainers)
Not exactly what you said. I had deployed a daemonset in my cluster with restart policy “always”. When one of the pod is pending, the ‘pod.status.phase’ changed to ‘pending’ using ‘kubectl get pod xxx -n xxx -o yaml’. I think, when the pod is not running correct for somereason like ‘CrashLoopBackOff’, the kubectl command gives out the reason in the status field in stdout but the actually ‘pod.status.phase’ remained, as ‘CrashLoopBackOff’ is actually not a pod phase. you can try it out. Actually i think it is better to determine a pod’s status together with the judgement of ‘pod.status.conditions’ with type=‘Ready’ and status=‘True’ if such conditions exist.