<p>I need to deploy an application that have Europe/Rome timezone.</p>
<p>I applied the following deployment:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
  labels:
    app: myapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
        - name: myapp
          image: 10.166.23.73:5000/local/myapp:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 8080
          env:
            - name: TZ
              value: Europe/Rome
          volumeMounts:
          - name: tz-rome
            mountPath: /etc/localtime
      volumes:
        - name: tz-rome
          hostPath:
            path: /usr/share/zoneinfo/Europe/Rome
</code></pre>
<p>However, when I run &quot;date&quot; command within the POD, I don't get the &quot;Europe/Rome&quot; timezone...</p>
<p>What is wrong with the above deployment yaml?</p>

mark009
<p>If you remove the env variable, that should be works. for example:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
  namespace: test-timezone
  labels:
    app: myapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
        - name: myapp
          image: busybox
          imagePullPolicy: Always
          command: [ &quot;sleep&quot;, &quot;10000&quot; ]
          volumeMounts:
          - name: tz-rome
            mountPath: /etc/localtime
      volumes:
        - name: tz-rome
          hostPath:
            path: /usr/share/zoneinfo/Europe/Rome

</code></pre>
<p>The output:</p>
<pre><code>/ # date
Fri Feb  4 02:16:16 CET 2022
</code></pre>
<p>If you want to set the timezone using <strong>TZ environment</strong>, you need the <strong>tzdata package</strong> in the container, for example:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp3
  namespace: test-timezone
  labels:
    app: myapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
        - name: myapp
          image: nginx
          imagePullPolicy: Always
          command: [ &quot;sleep&quot;, &quot;10000&quot; ]
          env:
            - name: TZ
              value: Europe/Rome
</code></pre>
<p>Nginx has the tzdata package inside:</p>
<pre><code>root@myapp2-6f5bbdf56-nnx66:/# apt list --installed | grep tzdata

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

tzdata/now 2021a-1+deb11u2 all [installed,local]

root@myapp2-6f5bbdf56-nnx66:/# date
Fri Feb  4 02:32:48 CET 2022
</code></pre>
