kubernetes / kubernetes/kubectl
how to kubectl wait for job completion regardless of success or failure
- Dominant language
- Go
- Stars
- 3.3k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
We are running AKS and use Azure DevOps with kubectl task to deploy our application. Before we deploy the actual application, we are running a data migration job. We want to wait for this job in the Azure DevOps pipeline, however the only option so far is to:
`kubectl wait --for=condition=complete --timeout=600s job/somejob`
In this case the pipeline task would only exit if the job has completed or the timeout has elapsed. In the case the job fails we are left with just waiting for timeout. I looked at using `kubectl wait --for=jsonpath` but there is no single value (and i mean single as in singular, not a combination of different values) in the output returned by kubectl that would indicate the job has finished, regardless of whether it succeeded or failed. And due to kubectl not supporting and/or conditions in jsonpath I am not able to evaluate the job completion based on multiple values. The only field that represents true completion is when `.status.completionTime` is set. I tried just out of curiosity doing `kubectl wait --for=jsonpath={.status.completionTime}`, and the task did indeed wait for the job once .status.completionTime was set, however docs suggest the condition would be met if the value I look for is True, but obviously completionTime is not. Is there any docs that would indicate how `wait --for=jsonpath` behaves on the fields that are set dynamically (like `.status.completionTime`) during the job execution?
Contributor guide
Assessment
This issue has not been assessed yet.