Kubernetes – Synchronizing Date and Time in Pods Hosted in Own Datacenter

kubernetestime-synchronization

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

Best Answer

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.