示例

apiVersion: v1
kind: Pod
metadata:
  name: counter
spec:
  containers:
  - name: count
    image: busybox
    args: [/bin/sh, -c,
            'i=0; while true; do echo "hello world: $i: $(date)"; i=$((i+1)); sleep 10; done']
    volumeMounts:
      - mountPath: /etc/localtime
        name: timezone
  volumes:
    - name: timezone
      hostPath:
        path: /usr/share/zoneinfo/Asia/Shanghai

加上后面的volume即可

    volumeMounts:
      - mountPath: /etc/localtime
        name: timezone
  volumes:
    - name: timezone
      hostPath:
        path: /usr/share/zoneinfo/Asia/Shanghai

其中hostPath是宿主机的本地路径,

还有其它方法就不说了,这个最保险。

查看pod的时间

kubectl exec pod/counter date
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐