<p>I'm trying to get information for a cron job so I can grab the current release of service.</p>

<p>So when I run <code>kubectl get pods</code> I get:</p>

<pre><code>NAME                                      READY   STATUS      RESTARTS   AGE
cron-backfill-1573451940-jlwwj            0/1     Completed   0          33h
test-pod-66df8ccd5f-jvmkp                 1/1     Running     0          16h
</code></pre>

<p>When I run <code>kubectl get pods --selector=job-name=cron-backfill</code> I get:</p>

<pre><code>No resources found in test namespace.
</code></pre>

<p>But when I run <code>kubectl get pods --selector=app=test-pod</code> I get:</p>

<pre><code>NAME                               READY   STATUS    RESTARTS   AGE
test-pod-66df8ccd5f-jvmkp          1/1     Running   0          16h
</code></pre>

<p>which is what I want. I figured since the first pod is a cron job there must be some other command used to check for those, but no luck.</p>

<p>I tried looking through the k8s docs here <a href="https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/</a> but can't find something that seems to work.</p>

olivercollins-inhome
<p>You need to</p>

<pre><code>kubectl describe pods cron-backfill-1573451940-jlwwj
</code></pre>

<p>And then you can see the <code>Labels:</code> part</p>

<p>EX:</p>

<pre><code>Labels:             app=&lt;app-name&gt;
                    controller-uid=&lt;xxxxxxxxxx&gt;
                    job-name=cron-backfill-1573451940-jlwwj 
                    release=&lt;release-name&gt;

</code></pre>

<p>Final you can use following command to get your pods:</p>

<pre><code>kubectl get pods --selector=job-name=cron-backfill-1573451940-jlwwj
</code></pre>

<p>Hope this may help you, Guy!</p>
