How to use cron with Kubernetes to schedule tasks

preview_player
Показать описание
If you've ever needed to schedule a single or recurring task in your Kubernetes clusters, it's just a cronjob away. Jack Wallen shows you how.

List of Commands:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cron-hello
spec:
schedule: "0,15,30,45 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: cron-hello
image: busybox
args:
- /bin/sh
- -c
- date; echo Hello, TechRepublic!
restartPolicy: OnFailure
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cron-hello
spec:
schedule: "0,15,30,45 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: cron-hello
image: busybox
args:
- /bin/sh
- -c
- date; echo Hello, TechRepublic!
restartPolicy: OnFailure
kubeclt get cronjobs
kubectl get jobs --watch
kubectl delete cronjob NAME

Рекомендации по теме