0

I am having issue with date and time in kubernetes cluster. My host time is sync using the ntp. Though i have synced it after configuring the cluster. Now all the pods created within my cluster will have wrong timezone. I found the issue is with the docker itself. As I am using CentOS 7 VMs which are over EXSi, it seems docker containers are taking UTC timezone from the exsi host rather then the centos i guess? Is there a way to fix this issue where new pods spawned will take the CentOS timezone rather then the EXSi host timezone? I could have use TZ env but for some docker base image like alpine, tzdate packages seems to be needed. So i don't want to rebuild the docker for some application which i can get prebuild out of the box like fluentd and such. Is there a way to fix it?

Thank You

  • Am I right that you have changed timezone on hosts after installing Kubernetes? So now pods are created with the wrong timezone. – Nick May 22 '20 at 13:42
  • I have not changed the timezone i guess. But i did changed the time though. – Susanta Gautam May 22 '20 at 18:27
  • Could you please describe "Now all the pods created within my cluster will have wrong timezone" in more details. Minimum reproducible example would be very handy. At the moment the exact issue is not clear, but the question itself looks interesting – Nick May 22 '20 at 19:01
  • hello @Nick i have made changes to the post. I think you will be clear now. Can you suggest me anything that can help me? – Susanta Gautam May 23 '20 at 11:13
  • could you check what are time and TZ on ESXI host, Centos 7 VM and Affected Pod ? – Nick May 26 '20 at 12:10
  • Time is correctly synced with our ntp server for both exsi and host machine. But the exsi timezone is UTC while my centos is GMT +5:45. – Susanta Gautam May 27 '20 at 13:59

1 Answers1

0

As far as I know, the VMWware ESX/ESXi hosts setup guest virtual machines (VM) to sync the time with the host (or hypervisor).

Assuming that NTP is working on ESXi host, clocks on CentOS VM must be synced as well.

The clock in a container is the same as the host machine because it’s controlled by the kernel. In this case, the host machine is CentOS VM. Thus container's clocks shall be synced as well.

The timezone is controlled by the OS layer though and so may be different in the container. You can mount in the time zone file to overcome this.

Now all the pods created within my cluster will have wrong timezone.

As far as I understood that's exactly the issue you've found.

ESXi 5.5 and after uses UTC by default and it doesn't support changing the time zone.

Nick
  • 151
  • 7
  • I have found the same finding too. Thank you for your answer. Now, for my problem, can i solve it by syncing the time of exsi host, centos and mounting the /etc/localtime? This file should work for all the base image right? like for the alpine which will require tzdate package to use TZ environment variable. – Susanta Gautam May 27 '20 at 14:02