Cronjobber is the cronjob controller from Kubernetes patched with time zone support.
# Install CustomResourceDefinition $ kubectl apply -f https://raw.githubusercontent.com/hiddeco/cronjobber/master/deploy/crd.yaml # Setup service account and RBAC $ kubectl apply -f https://raw.githubusercontent.com/hiddeco/cronjobber/master/deploy/rbac.yaml # Deploy Cronjobber $ kubectl apply -f https://raw.githubusercontent.com/hiddeco/cronjobber/master/deploy/deploy.yaml
Instead of creating a
like you normally would, you create a
TZCronJob, which works exactly
the same but supports an additional field:
.spec.timeZone. Set this
to the time zone you wish to schedule your jobs in and Cronjobber will
take care of the rest.
apiVersion: cronjobber.hidde.co/v1alpha1 kind: TZCronJob metadata: name: hello spec: schedule: "*/1 * * * *" timezone: "Europe/Amsterdam" jobTemplate: spec: template: spec: containers: - name: hello image: busybox args: - /bin/sh - -c - date; echo "Hello, World!" restartPolicy: OnFailure
There has been a long outstanding (and now closed) issue
to add time zone support to the
CronJob kind in Kubernetes, including
a fully working PR
which actually made it possible. SIG Apps and in SIG Architecture
decided however against adding it because of the downside of having
to manage and distribute time zone databases.
People are now encouraged to innovate and solve these kinds of problems in the ecosystem rather than core.
Instead of putting this in Kubernetes the ask is to:
- Develop this in the ecosystem (e.g., a controller) that others can use. Distribute it, solve the problems there, and see what update looks like
- If the solution is widely adopted and can be used by everyone (including small scale, multi-cluster, etc) then it could be considered for core Kubernetes
Cronjobber is the most simple answer to this: it is the original PR on top of a more recent version of the cronjob controller, with some glue added to make it an independent controller.
This application is derived from open source components. You can find the original source code of these components below.