I'm running a kubernetes job, deleting it, then starting it again in rapid succession.
I'm using the following command to get the pod related to my job so I can run kubectl logs $POD
.
kubectl get pods -l job-name=myjob --output=jsonpath='{.items[*].metadata.name}'
But right after deleting a job the above command returns two pods, the one that has yet to be removed, and the new one.
kubectl describe jobs/myjob
shows the correct pod name, I could parse it out of the text from there so I get the unique pod name for the most recently started job, but that seems hacky.
Is there a better way to get the pod name from a specific job?