title: Time Zone in Kubernetes Pods Using Environment Variable
body: <p>I am trying to update my pod time to Asia/Kolkata zone as per <a href="https://stackoverflow.com/questions/55089265/kubernetes-timezone-in-pod-with-command-and-argument">kubernetes timezone in POD with command and argument</a>. However, the time still remains the same UTC time. Only the time zone is getting updated from UTC to Asia.</p>
  <p>I was able to fix it using the volume mounts as below. Create a config map and apply the deployment yaml.</p>
  <pre><code>kubectl create configmap tz --from-file=/usr/share/zoneinfo/Asia/Kolkata -n &lt;required namespace&gt;
  </code></pre>
  <p><strong>Why is the environmental variable method not working?  Will a pod eviction occur from one host to another if we use volume mount time and will if affect the volume mount time after pod eviction?</strong></p>
  <p>The EV deployment YAML is below which does not update the time</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: connector
    labels:
      app: connector
    namespace: clients
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: connector
    template:
      metadata:
        labels:
          app: connector
      spec:
        containers:
        - image: connector
          name: connector
          resources:
            requests:
              memory: &quot;32Mi&quot;  # &quot;64M&quot;
              cpu: &quot;250m&quot;
            limits:
              memory: &quot;64Mi&quot;  # &quot;128M&quot;
              cpu: &quot;500m&quot;
          ports:
            - containerPort: 3307
              protocol: TCP
          env:
            - name: TZ
              value: Asia/Kolkata
          volumeMounts:
            - name: connector-rd
              mountPath: /home/mongobi/mongosqld.conf
              subPath: mongosqld.conf
        volumes:
        - name: connector-rd
          configMap:
            name: connector-rd
            items:
            - key: mongod.conf
  </code></pre>
  <p>Volume Mount yaml is below.</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: connector
    labels:
      app: connector
    namespace: clients
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: connector
    template:
      metadata:
        labels:
          app: connector
      spec:
        containers:
        - image: connector
          name: connector
          resources:
            requests:
              memory: &quot;32Mi&quot;  # &quot;64M&quot;
              cpu: &quot;250m&quot;
            limits:
              memory: &quot;64Mi&quot;  # &quot;128M&quot;
              cpu: &quot;500m&quot;
          ports:
            - containerPort: 3307
              protocol: TCP
          volumeMounts:
            - name: tz-config
              mountPath: /etc/localtime
            - name: connector-rd
              mountPath: /home/mongobi/mongosqld.conf
              subPath: mongosqld.conf
        volumes:
        - name: connector-rd
          configMap:
            name: connector-rd
            items:
            - key: mongod.conf
              path: mongosqld.conf
        - name: tz-config
          hostPath:
             path: /usr/share/zoneinfo/Asia/Kolkata
  </code></pre>