Time Zone Cronjobs
The Cloud Platform uses UTC, but sometimes you may need a Cronjob to run at specific times of a day in the UK (including during BST). Kubernetes Cronjobs do not support time zones, so to enable running cronjobs at specific UK times, you can use TZ Cronjobber(a cronjob controller for Kubernetes with support for time zones).
Instead of creating a CronJob 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.
In this example the timezone is set to “Europe/London” and scheduled every day at 14:10. During BST the job will trigger at 13:10 UTC, but the rest of the year it will trigger at 14:10 UTC.
apiVersion: cronjobber.hidde.co/v1alpha1 kind: TZCronJob metadata: name: hello spec: schedule: "10 14 * * *" timezone: "Europe/London" jobTemplate: spec: template: spec: containers: - name: hello image: bitnami/nginx:latest args: - /bin/sh - -c - date; echo "Hello, World!" restartPolicy: OnFailure
Applying tzcronjob in your Namespace
Using the above example create a
tzcronjob.yaml file and apply it to your namespace in the kubernetes cluster.
``` kubectl apply --filename tzcronjob.yaml --namespace [your namespace] ```
Verify that the tzcronjob is created.
``` kubectl get tzcronjob --namespace [your namespace] ```