问题描述
我想使用命令更改时区.我知道应用主机路径.
I want to change timezone with command.I know applying hostpath.
您知道如何应用命令吗?
Could you know how to apply command ?
ln -snf/user/share/zoneinfor/$ TZ/etc/localtime
ln -snf /user/share/zoneinfor/$TZ /etc/localtime
在容器内效果很好.但是我不知道在yaml文件中应用命令和参数.
it works well within container.But I don't know applying with command and arguments in yaml file.
推荐答案
您可以通过使用特定的时区配置和hostPath卷来设置特定的时区来更改pod的timezone
.您的yaml文件如下所示:
You can change the timezone
of your pod by using specific timezone config and hostPath volume to set specific timezone. You're yaml file will look something like:
apiVersion: v1
kind: Pod
metadata:
name: busybox-sleep
spec:
containers:
- name: busybox
image: busybox
args:
- sleep
- "1000000"
volumeMounts:
- name: tz-config
mountPath: /etc/localtime
volumes:
- name: tz-config
hostPath:
path: /usr/share/zoneinfo/Europe/Prague
type: File
如果要跨所有Pod进行部署,则需要将volume和volumeMounts添加到所有部署文件中,并将hostPath
部分中的path
值更改为要设置的时区.
If you want it across all pod, deployment you need to add volume and volumeMounts to all your deployment file and change the path
value in hostPath
section to the timezone you want to set.
这篇关于带有命令和参数的POD中的kubernetes时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!