In your Kubernetes clusters, the timezone is typically assumed to be UTC, which is a very cloud-native way to provision things. The resources you have might be across the globe, so having every node or host use the same timezone makes sense, especially if you're correlating information in logs.
But in other environments, there is a need to have the local timezone configured.
What happens if your cronjobs in the cluster are not aligned with the local timezone? This could cause some minor havoc.
The answer is simple. The timezone settings for cronjobs are managed by the
kube-controller-manager component. Assuming all of your control-plane nodes are provisioned prior with localized and correct timezone settings, just add an extra mount, adding in
/etc/localtime into the
Inside Rancher RKE it may look something like this in your cluster.yaml file:
services: kube-controller: extra_binds: - '/etc/localtime:/etc/localtime'
Provision your clusters with the localtime setting mounted and your jobs will be in the proper timezone.