RKE2 how to set the timezone
This document (000021862) is provided subject to the disclaimer at the end of this document.
Environment
RKE2
Situation
Containers do not inherit timezones from host machines and have only accessed to the clock from the kernel - which is always UTC. The default timezone for most images is UTC, yet it is not guaranteed and may be different from container to container since it can be changed on a pod or image level.
Resolution
You can use the following environment variables to set the desired timezone in the various pods by editing the cluster YAML:
``
machineSelectorConfig:
- config:
kube-apiserver-extra-env: "TZ=<timezone>"
kube-scheduler-extra-env: "TZ=<timezone>"
kube-controller-manager-extra-env: "TZ=<timezone>"
kube-proxy-extra-env: "TZ=<timezone>"
etcd-extra-env: "TZ=<timezone>"
cloud-controller-manager-extra-env: "TZ=<timezone>"
This assumes the tzdb package is present on the nodes. Rancher started including this in their k8s releases from January 2025 onwards.
For other non-static pods and workloads you may have, you can consider using k8tz that creates a admission controller that injects the timezones into any pods created.
See here: https://github.com/k8tz/k8tz
Cause
Rancher started including the tzdb package in k8s releases from January 2025 onwards.
Prior to this it as not possible to set the Timezone.
See this issue:
https://github.com/rancher/rke2/issues/7331
Additional Information
Check the k8tz controller to manage it globally in your cluster.
See: https://github.com/k8tz/k8tz
Disclaimer
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.