Change timezone #821
-
Hey, First amazing project! Thanks, all contributors. I wondered why my K8S Cronjob was not running at the expected time and found out that the default timezone is UTC. Is it recommended to add the feature into the variables? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@janis-ax Thanks for your kind words. Here's what GPT-4 says about your question above, I think it answers it well: By default, Kubernetes uses UTC for all timestamps and time-related operations. It's recommended to keep this default setting for consistency and to avoid potential issues. Changing the time zone of a cluster-wide environment could lead to confusing behavior and unexpected results. However, if you still need to change it for specific workloads like CronJobs, you could set the time zone at the container level. This would not affect the entire cluster but just the individual containers. There are several ways to set the timezone for a container: Using an environment variable: You can set an environment variable apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: hello
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
args:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
env:
- name: TZ
value: Europe/Berlin
restartPolicy: OnFailure |
Beta Was this translation helpful? Give feedback.
@janis-ax Thanks for your kind words. Here's what GPT-4 says about your question above, I think it answers it well:
By default, Kubernetes uses UTC for all timestamps and time-related operations. It's recommended to keep this default setting for consistency and to avoid potential issues. Changing the time zone of a cluster-wide environment could lead to confusing behavior and unexpected results.
However, if you still need to change it for specific workloads like CronJobs, you could set the time zone at the container level. This would not affect the entire cluster but just the individual containers.
There are several ways to set the timezone for a container:
Using an environment variable:
Y…