<p>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.</p>

<p>I am able to get it for Running, Pending, but not for Completed.</p>

<p>Running:</p>

<pre>
[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
</pre>

<p>Pending: </p>

<pre>
[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
</pre>

<p>Completed:</p>

<pre>
[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.
</pre>

<p>I believe there may be a bug in the field-selector, but just wondering if there are any fixes or details on a workaround.</p>

<p>The correct <em>status.phase</em> for completed pods is <strong>Succeeded</strong>.  </p>

<p><strong>So, to filter only completed pods, you should use this:</strong><br>
<code>kubectl get pod --field-selector=status.phase=Succeeded</code></p>

<p>Although, the use of bare pods is not recommended. Consider using a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/" rel="noreferrer">Job Controller</a>:</p>

<blockquote>
  <p>A Job creates one or more Pods and ensures that a specified number of
  them successfully terminate. As pods successfully complete, the Job
  tracks the successful completions.</p>
</blockquote>

<p>You can check job conditions and wait for them with this:<br>
<code>kubectl wait --for=condition=complete job/myjob</code></p>
