Tell when Job is Complete
Since version 1.11, you can do:
kubectl wait --for=condition=complete job/myjob
and you can also set a timeout:
kubectl wait --for=condition=complete --timeout=30s job/myjob
You can visually watch a job's status with this command:
kubectl get jobs myjob -w
The -w
option watches for changes. You are looking for the SUCCESSFUL
column to show 1
.
For waiting in a shell script, I'd use this command:
until kubectl get jobs myjob -o jsonpath='{.status.conditions[?
(@.type=="Complete")].status}' | grep True ; do sleep 1 ; done