Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to change timezone for cron job scheduler?

Hello,

We have GKE version 1.24.

All cron jobs seem to run per UTC timezone. But what we want to accomplish is to run cronjobs scheduled per Europe/Warsaw timezone.

I did read thread https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/ 

but it does not provide answer to that. It just says timezone is taken from  kube-controller-manager but there is nothing about changing timezone in kube-controller-manager.

I am aware that it will be available as setting in 1.25 (via spec.timeZone) but we are on 1.24.

I am aware that setting TZ or CRON_TZ i can accomplish it but as per documentation - i would like to avoid using that.

0 1 4,224
1 REPLY 1

Hello pkowalski,

As per Martijn Pieters from Stackoverflow, "

If you can upgrade to 1.24, you can instead use the new CronJobTimeZone feature gate to enable the new, official, time-zone support added with KEP 3140. Note that this is still an alpha-level feature; hopefully it will reach beta in 1.25. If all goes well, the feature should reach maturity in release 1.27.

With the feature-gate enabled, you can add a timeZone field to your CronJob spec:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: scheduler
spec:
  schedule: "0 23 * * *"
  timeZone: "TIMEZONE"

Top Labels in this Space