简体   繁体   中英

What time is it in a Kubernetes pod?

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

DateTime.Now

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM