可以设置TZ环境变量来实现,在以下环境中测试可以使用:
服务器:CentOS7
KS8:v1.20.4
Docker:v20.10.6
比如我要设置时区为Asia/Shanghai。
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo
spec:
replicas: 1
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: demo
image: xxxx
imagePullPolicy: Always
env:
- name: TZ
value: Asia/Shanghai