<p>I am having issue with date and time in kubernetes cluster. Cluster is setup in the data center using the kubeadm. My host server 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 time. So the cause for it seems to  be the docker taking the UTC timezone. For the temporary solution, i use volume mount /etc/localtime with the hostmeachine in the pods which we create but it seems not feasible for the application i install using helm from helm repo. Is there any way to fix this issue? I don't want every pods have the volume mounts for the correct time. Is there any way through which the docker gets timezone from the host machine.</p>

<p>FYI the k8s cluster is setup upon the CentOS 7. They are VM created over the EXSi. Thank You</p>

<p>It's not broken. It's working as designed.</p>

<p>Clock in a container is the same as on the host machine because it’s controlled by the kernel of that machine.</p>

<p>Timezone is controlled by the OS layer so it may be different inside the container.
The way around it is using specific timezone config and hostPath volume to set specific timezone.</p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  name: busybox-sleep
spec:
  containers:
  - name: busybox
    image: busybox
    args:
    - sleep
    - "1000000"
    volumeMounts:
    - name: tz-config
      mountPath: /etc/localtime
  volumes:
    - name: tz-config
      hostPath:
        path: /usr/share/zoneinfo/Europe/Prague
        type: File
</code></pre>

<p>Because you are using helm, you should check the documentation for the image you are using and look for a timezone variable that you could change so you can put that in your <code>value.yaml</code> or use <code>--set</code> option when deploying.</p>

<p>I recommend reading <a href="https://medium.com/@yildirimabdrhm/kubernetes-timezone-management-8cc139b01f9d" rel="nofollow noreferrer">Kubernetes Container Timezone Management</a>.</p>
