什么时候在Kubernetes窗格中?

1 .net kubernetes

假设我在k8s窗格中运行了一些(.NET Core)代码,我要求:

DateTime.Now
Run Code Online (Sandbox Code Playgroud)

我假设我将从运行Pod的主机获取日期时间。有什么办法可以在k8s集群中获得一致的日期时间值?

Kar*_*KFI 5

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

The timezone is controlled by the OS layer tho and so may be different in the container. You can mount in the time zone file to overcome this.

Synchronization of clocks across machines is a complicated topic. You can go as simple as installing an NTP client on all the nodes or as complex as installing GPS hardware clocks on every node.

如果您的Kubernetes节点是VM,这会增加另一层复杂性。大多数IaaS和虚拟机管理程序都提供了某种使VM时钟与主机同步的方法,但是您仍然需要使所有主机保持同步。