k8s中解決容器時差問題


解決k8s的pod容器的時差常用的兩種方式:

1、通過設置pod 模板中的環境變量 env解決

   在pod的模板中添加以下:

apiVersion: v1

kind: Pod
metadata:
   name: pod-name
spec:
  containers:
  - name: name
    image: image-name
    imagePullPolicy: IfNotPresent
    env:
    - name: TZ
       value: Asia/Shanghai

2、掛載宿主機的時區文件進行設置

apiVersion: v1
kind: Pod
metadata:
   name: pod-vol-tz
spec:
  containers:
  - name: ngx
    image: nginx:latest
    imagePullPolicy: IfNotPresent
    volumeMounts:
    -  name: config
       mountPath: /etc/localtime
       readOnly: true
   volumes:
    - name: config
       hostPath:
           path: /etc/localtime

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM