<p>Let's say I and the partner company I'm dealing with live in a country that employs <a href="https://en.wikipedia.org/wiki/Daylight_saving_time" rel="noreferrer">Daylight Saving Time</a>.</p>
<p>I have a CronJob in a kubernetes cluster that uploads files to the partner company daily at, say, 4:00, 10:00, 16:00, and 22:00. E.g. <code>0 4,10,16,22 * * *</code>.</p>
<p>Kubernetes SIG <a href="https://github.com/kubernetes/kubernetes/issues/47202#issuecomment-360820586" rel="noreferrer">decided</a> that CronJob object will not support local timezone and will always run in the default one, which is UTC.</p>
<p>I can change the schedule, so that it reflects local time specified above in UTC and give the CronJob that schedule. However every time daylight saving kicks in (twice a year) I would need somehow modify all the CronJobs to use the new time, <em>and</em> I need to modify my deployment pipeline to create new releases of the CronJobs with the new time.</p>
<p>I cannot keep the CronJob running on the same schedule past daylight saving change, as the job will upload files not during the times expected by the partner.</p>
<p>What is the easiest way to manage this?</p>
<p><strong>Option 1</strong></p>
<p>It was <a href="https://github.com/kubernetes/kubernetes/issues/47202#issuecomment-400421237" rel="noreferrer">suggested</a> that writing a new kubernetes controller could do, but it does not seem that anyone raised up to that challenge and published working solution.</p>
<p><strong>Option 2</strong></p>
<p>Another option I have considered is changing the timezone of the entire cluster. But if you <a href="https://www.google.com/search?&amp;q=kubernetes+cluster+change+timezone" rel="noreferrer">google it</a> it does not seem to be very popular solution, and some people strongly believe that kubernetes being a cloud application should be run in UTC.</p>
<p>From what I understand <code>cron</code> uses a local time zone which, in case of kubernetes will be the timezone of the controller manager, which is not necessary a timezone of the node it is running on. On the other hand, changing time zone of the controller manager container, sounds risky, as it is not clear how it will interact with other components of the kubernetes, such as etcd and kubelets.</p>
<p><strong>Option 3</strong></p>
<p>Doing it manually twice a year. Since people in the organisation come and go it would be difficult to retain the knowledge when and how. I do not want our partner to complain twice a year. Also it might be tricky to set up notifications for this as the dates change every year.</p>
<p><strong>Option 4</strong></p>
<p>Write some homegrown automation to run twice a year and hope that when time comes it works as expected. That is actually triggers, triggers at the right time and does everything it's supposed to do. (the latter is easier to test but the former is harder).</p>
<p>All these options feel quite unsatisfactory. I googled a lot and I have not found a lot, I feel it should be quite common issue, and yet nothing comes up in the search. Am I overlooking something? Is there an easy and natural way to solve it?</p>

Andrew Savinykh
<p>Time Zones was added to CronJob in Kubernetes 1.22. To cite <a href="https://github.com/kubernetes/kubernetes/issues/47202#issuecomment-950887675" rel="nofollow noreferrer">github thread</a></p>
<blockquote>
<p>Just to clarify, it's available in 1.22.</p>
</blockquote>
<blockquote>
<p>It was implemented in a very strange way that's not exposed in the schema, though. I'm not aware of any explanation for why that was done, and it ignores core concepts behind Kubernetes. I think this still needs work.</p>
</blockquote>
<p>It can be done via <code>CRON_TZ</code> variable, as described <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#cron-schedule-syntax" rel="nofollow noreferrer">here</a>.</p>
<pre><code>#      ┌────────────────── timezone (optional)
#      |      ┌───────────── minute (0 - 59)
#      |      │ ┌───────────── hour (0 - 23)
#      |      │ │ ┌───────────── day of the month (1 - 31)
#      |      │ │ │ ┌───────────── month (1 - 12)
#      |      │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
#      |      │ │ │ │ │                                   7 is also Sunday on some systems)
#      |      │ │ │ │ │
#      |      │ │ │ │ │
# CRON_TZ=UTC * * * * *
</code></pre>
<p><strong>Update</strong></p>
<p>This feature is to be marked as <a href="https://github.com/kubernetes/kubernetes/pull/104404#issuecomment-970406114" rel="nofollow noreferrer">unsupported</a></p>
