问题描述
我想用命令改变时区.我知道应用主机路径.
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 时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!