Wait for kubernetes job to complete on either failure/success using command line

Run the first wait condition as a subprocess and capture its PID. If the condition is met, this process will exit with an exit code of 0. kubectl wait –for=condition=complete job/myjob & completion_pid=$! Do the same for the failure wait condition. The trick here is to add && exit 1 so that the subprocess returns … Read more

How to automatically remove completed Kubernetes Jobs created by a CronJob?

You can now set history limits, or disable history altogether, so that failed or successful CronJobs are not kept around indefinitely. See my answer here. Documentation is here. To set the history limits: The .spec.successfulJobsHistoryLimit and .spec.failedJobsHistoryLimit fields are optional. These fields specify how many completed and failed jobs should be kept. By default, they … Read more