同步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
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】博客园携手 AI 驱动开发工具商 Chat2DB 推出联合终身会员
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步