DEV Community

Fred Richards
Fred Richards

Posted on

Shift the TZ for your K8s CronJobs

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 kube-controller-manager component.

Inside Rancher RKE it may look something like this in your cluster.yaml file:

services:
  kube-controller:
    extra_binds:
      - '/etc/localtime:/etc/localtime'
Enter fullscreen mode Exit fullscreen mode

Provision your clusters with the localtime setting mounted and your jobs will be in the proper timezone.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more