一、通过环境变量设置

apiVersion: v1
kind: Pod
metadata:
  name: pod-env-tz
spec:
  containers:
  - name: ngx
    image: nginx:latest
    imagePullPolicy: IfNotPresent
    env:
      - name: TZ
        value: Asia/Shanghai

二、通过挂载主机时区文件设置

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: myweb
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: myweb
    spec:
      containers:
      - name: myweb
        image: harbor/tomcat:8.5-jre8
        volumeMounts:
        - name: host-time
          mountPath: /etc/localtime
      volumes:
      - name: host-time
        hostPath:
          path: /etc/localtime

创建deployment后,找到pod,执行date命令检查时间是否同步

kubectl exec podid -- date

 

相关文章:

  • 2022-12-23
  • 2021-12-22
  • 2021-06-03
  • 2022-12-23
  • 2021-05-19
  • 2021-06-01
  • 2021-05-12
  • 2022-02-04
猜你喜欢
  • 2021-08-18
  • 2021-08-02
  • 2021-08-16
  • 2022-12-23
  • 2022-12-23
  • 2021-06-01
  • 2022-01-20
相关资源
相似解决方案