xxxxxxxxxx
kubectl create -f https://k8s.io/examples/application/job/cronjob.yaml
xxxxxxxxxx
kubectl describe cronjob hello
Name: cleanup-job
Namespace: default
Labels: <none>
Annotations: <none>
Schedule: * 2 * * *
Concurrency Policy: Allow
Suspend: False
Successful Job History Limit: 3
Failed Job History Limit: 1
Starting Deadline Seconds: <unset>
Selector: <unset>
Parallelism: <unset>
Completions: <unset>
Pod Template:
Labels: <none>
Containers:
hello:
Image: busybox:1.28
Port: <none>
Host Port: <none>
Command:
/bin/rm
-f
/tmp/*
Environment: <none>
Mounts: <none>
Volumes: <none>
Last Schedule Time: Mon, 30 May 2022 02:00:00 -0600
Active Jobs: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 16m cronjob-controller Created job cleanup-job-27565242
Normal SawCompletedJob 16m cronjob-controller Saw completed job: cleanup-job-27565242, status: Complete
Copy
xxxxxxxxxx
apiVersion: batch/v1
kind: CronJob
metadata:
name: hello
spec:
schedule: "* * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox:1.28
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure