Table of Contents |
---|
Purpose of localtime volume in helm charts
...
- TZ Environment Variable: Another way to set the timezone in a container is to use the
TZ
environment variable. This doesn't require mounting/etc/localtime
but can be less consistent across different environments or container images.
Example Configuration
With this setup, your container will display the time according to the host system's timezone.
Code Block | ||
---|---|---|
| ||
volumes: - name: localtime hostPath: path: /etc/localtime volumeMounts: - name: localtime mountPath: /etc/localtime readOnly: true |
...
Summary
The mounting of /etc/localtime
in your Helm chart is a method to ensure the container uses the same timezone as the host system. This is useful for applications that need to display the correct local time, especially in logs and time-sensitive operations.
...
You can specify the TZ
variable in a Kubernetes Pod or Deployment definition:
Code Block | ||
---|---|---|
| ||
apiVersion: v1
kind: Pod
metadata:
name: timezone-example
spec:
containers:
- name: myapp
image: myapp:latest
env:
- name: TZ
value: "America/New_York" |
3. In a Helm Chart
In your Helm values or templates:
Code Block | ||
---|---|---|
| ||
env:
- name: TZ
value: "America/New_York" |
Examples of Timezones You Can Use
...