Tell when Job is Complete

前端 未结 4 972
花落未央
花落未央 2020-11-27 16:51

I\'m looking for a way to tell (from within a script) when a Kubernetes Job has completed. I want to then get the logs out of the containers and perform cleanup.

Wh

4条回答
  •  半阙折子戏
    2020-11-27 17:15

    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
    

提交回复
热议问题