本文最后更新于134 天前,其中的信息可能已经过时,如有错误请发送邮件到big_fw@foxmail.com
1.挂载服务器的时区
[root@k8s-m ~]# cat demo-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
namespace: default
labels:
app: my-pod
spec:
containers:
- name: my-pod
image: nginx
volumeMounts:
- name: host-time
mountPath: /etc/localtime
readOnly: true
volumes:
- name: host-time
hostPath:
path: /etc/localtime
2.传递变量
如果一步骤没有用,可以结合二步骤一起使用,如果是没上线之前可以直接重新打镜像
rm -f /etc/localtime
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@k8s-m ~]# cat time-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: pod-env-tz
spec:
containers:
- name: edit time
image: xxxxxxxxxxxxxxxxxx
env:
- name: TZ
value: Asia/Shanghai