如何更改整个 Kubernetes 集群的时区? [英] How to change TimeZone of entire Kubernetes cluster?

查看:53
本文介绍了如何更改整个 Kubernetes 集群的时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将整个 on-prim kubernetes 集群的时区从默认 UTC 更改为 America/Los_Angeles.

I want to change timezone of our entire on-prim kubernetes Cluster from default UTC to America/Los_Angeles.

我知道通过使用卷更改它以进行单一部署[参考:https://evalle.xyz/posts/kubernetes-tz/] 这是一项繁琐的工作,因为我的集群中有很多 Pod.

I am aware about changing it for single deployment by using volumes[ref.: https://evalle.xyz/posts/kubernetes-tz/] This is tedious job to do, as there are many pods in my cluster.

我正在寻找更好的选择来一次性完成整个集群.非常感谢任何帮助.

I am looking out better option to do it for entire cluster one go. Any help much appreciated.

推荐答案

TL;DR:您将无法在集群中全局设置 TZ.

TL;DR: You will not be able to globally set the TZ in a cluster.

基于 (Kubernetes pod 中几点了?)

容器中的时钟与主机相同,因为它由内核控制.

The clock in a container is the same as the host machine because it’s controlled by the kernel.

正如您已经提到的,您可以通过绑定主机操作系统的 zoneinfo 来更改 POD 的 TZ.

As you already mentioned, you can change the TZ of the POD by binding the zoneinfo of the host OS.

所以 TIME ZONE (TZ) 是在 POD 级别本地控制的,不能全局更改,因为这应该在 POD 定义内完成.

So the TIME ZONE (TZ) is something that is locally controlled at POD level and can’t be changed globally because this should be done within the POD definition.

如果你想改变TZ而不绑定宿主操作系统的zoneinfo,基于(https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes)你可以通过设置 TZ 环境变量.如果您更改图像并在其中设置 TZ 环境变量,则创建 POD 时,它将从图像继承,因此将使用 TZ 环境变量集创建 POD.

If you want to change the TZ without binding the zoneinfo of the host OS, based on (https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes) you may change it by setting the TZ environment variable. If you change your image and set the TZ environment variable in there, when the POD is created it will inherit from the image so the POD will be created with the TZ environment variable set.

所以你唯一的选择是:

1.-在每个POD中绑定宿主操作系统的zoneinfo.

1.- Bind the zoneinfo of the host OS in each POD.

2.- 在集群的每个节点上更改时区.

2.- Change your TimeZone on each node of your cluster.

3.- 在 IMAGE 上设置 TZ 环境变量,以便 POD 在创建时继承该值.

3.- Set the TZ environment variable on your IMAGE so the POD will inherit the value when is created.

这篇关于如何更改整个 Kubernetes 集群的时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆