打赏

星辰大海ゞ

That which does not kill us makes us stronger!

导航

同步pod时区与node主机保持一致

一、通过环境变量设置

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

 

posted on 2018-12-11 16:35  星辰大海ゞ  阅读(826)  评论(0编辑  收藏  举报