Difference between revisions of "Kubernetes CronJobs"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
+ | CronJobs (previously ScheduledJobs) has been a beta feature since Kubernetes 1.8! With 1.21 we get to finally see this widely used API graduate to stable. | ||
+ | |||
+ | CronJobs are meant for performing regular scheduled actions such as backups, report generation, and so on. Each of those tasks should be configured to recur indefinitely (for example: once a day / week / month); you can define the point in time within that interval when the job should start. | ||
+ | |||
+ | |||
+ | apiVersion: batch/v1 | ||
+ | [[kind:]] CronJob | ||
+ | metadata: | ||
+ | name: hello | ||
+ | spec: | ||
+ | schedule: "*/1 * * * *" | ||
+ | jobTemplate: | ||
+ | spec: | ||
+ | template: | ||
+ | spec: | ||
+ | containers: | ||
+ | - name: hello | ||
+ | image: [[busybox]] | ||
+ | imagePullPolicy: IfNotPresent | ||
+ | command: | ||
+ | - /bin/sh | ||
+ | - -c | ||
+ | - date; echo Hello from the Kubernetes cluster | ||
+ | restartPolicy: OnFailure | ||
+ | |||
Revision as of 06:42, 3 May 2021
CronJobs (previously ScheduledJobs) has been a beta feature since Kubernetes 1.8! With 1.21 we get to finally see this widely used API graduate to stable.
CronJobs are meant for performing regular scheduled actions such as backups, report generation, and so on. Each of those tasks should be configured to recur indefinitely (for example: once a day / week / month); you can define the point in time within that interval when the job should start.
apiVersion: batch/v1 kind: CronJob metadata: name: hello spec: schedule: "*/1 * * * *" jobTemplate: spec: template: spec: containers: - name: hello image: busybox imagePullPolicy: IfNotPresent command: - /bin/sh - -c - date; echo Hello from the Kubernetes cluster restartPolicy: OnFailure
See also
cron
,crontab
,systemctl list-timers
, anacron, Kubernetes scheduler, Systemd services,CronJobsStack
,cron.schedule
,crontab -l
,0x004b
,at, /etc/cron.deny, /etc/cron.allow, /etc/crontab, /var/spool/cron/crontabs/
- Kubernetes: distributions, tools, CKA, CKS, Kubernetes interfaces: CSI, CNI, installation, workloads, networking,
kubeadm
,Kubernetes API
, Kubernetes API Server,kubectl, kubeadm, kubelet, kube-proxy
, Cloud services: EKS, GKE, TKE, DKS, Helm, Kubernetes RBAC, Kubernetes deployments, Minikube, Rancher, OpenShift, Charmed Kubernetes, Ingress, Kubernetes scheduler, Kubernetes Finalizers, logging, Kubernetes operator, Orka,kind:
, Kubernetes namespaces, Kubernetes dashboard, Kubernetes Metrics Server, Field Selectors, CoreDNS, CRI, Kubernetes Topology Manager, Kubernetes governance: (SIG, KEP), Kustomize, controllers,ReadinessProbe, LivenessProbe
, KOPS, K9s, Kui, k3s, ImagePullBackOff, PDB, EndPoints, Kots, metadata, Karpenter, Replicated.com, Kubernetes Authenticating, Kubernetes timeline, Changelog/Versions, service accounts, Kubernetes Pod Lifecycle, Kubernetes Conformance Certified, Kubernetes backup, Kubernetes Pod Security Admission, tEKS, Kubernetes events, Kubernetes ports, Kubernetes policies, Connect, addons, DoKC, Kubernetes control plane, Kubernetes Federation, Kubernetes info, Kubetest2, Sidecar (Kubernetes)
Advertising: