Is there a way to check whether a pod status is in the completed state? I have a Pod that I only wanted to use once (where init containers didn't quite serve my purpose) and want to write a check to wait for Completed status.
I am able to get it for Running, Pending, but not for Completed.
Running:
[user@sandbox gcp_kubernetes_installation]$ kubectl get pods --field-selector=status.phase=Running -n mynamespace NAME READY STATUS RESTARTS AGE mssql-deployment-795dfcf9f7-l2b44 1/1 Running 0 6m data-load-pod 1/1 Running 0 5m
Pending:
[user@sandbox gcp_kubernetes_installation]$ kubectl get pods --field-selector=status.phase=Pending -n mynamespace NAME READY STATUS RESTARTS AGE app-deployment-0 0/1 Pending 0 5m
Completed:
[user@sandbox gcp_kubernetes_installation]$ kubectl get pod -n namespace NAME READY STATUS RESTARTS AGE mssql-deployment-795dfcf9f7-l2b44 1/1 Running 0 11m data-load-data-load-pod 0/1 Completed 0 10m app-deployment-0 0/1 Pending 0 10m [user@sandbox gcp_kubernetes_installation]$ kubectl get pods --field-selector=status.phase=Completed -n namespace No resources found.
I believe there may be a bug in the field-selector, but just wondering if there are any fixes or details on a workaround.
kubectl wait
to wait for the Job complete condition. Take a look at this answer. – Eduardo Baitello