现在在Kubernetes窗格中几点钟了? [英] What time is it in a Kubernetes pod?

查看:53
本文介绍了现在在Kubernetes窗格中几点钟了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Say I have some (.NET Core) code running in a k8s pod and I ask for:

DateTime.Now

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

I assume I will get the date-time from the host that the pod is running on. Is there any way of getting a date-time value that is consistent across the k8s cluster?

推荐答案

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

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

时区由OS层tho控制,因此容器中的时区可能不同.您可以在时区文件中挂载以解决此问题.

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.

跨机器的时钟同步是一个复杂的话题.您可以像在所有节点上安装NTP客户端一样简单,也可以像在每个节点上安装GPS硬件时钟一样复杂.

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时钟与主机同步的方法,但是您仍然需要使所有主机保持同步.

If your Kubernetes nodes are VMs this adds another layer of complexity. Most IaaS and hypervisors provide some way of synchronizing the VM clock with the host, but you still need to keep all your host machines in sync.

这篇关于现在在Kubernetes窗格中几点钟了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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