Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
k8s create job from cronjob (how to run a cronjob now + once)
$ kubectl create job --from=cronjob/<CRONJOB-NAME> <NEW-JOB-NAME>
$ kubectl create job --from=cronjob/my-cron my-cron-manual-001
function k8s-cronjob-run() {
[ -z "$source_cronjob_name" ] && echo "Please provide source-cronjob-name !" && return
sink_run_id=$(date -u +"%Y-%m-%dt%H.%M.%Sz")
echo "=== cronjob: $source_cronjob_name -> job: $sink_job_name ==="
cmd="kubectl create job --from=cronjob/${source_cronjob_name} ${sink_job_name}"
echo $cmd
echo "You may want to: ... "
echo " kubectl get job ${sink_job_name}"
echo " kubectl describe job ${sink_job_name}"
echo " kubectl delete job ${sink_job_name}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment