给客户测试用的私部环境,那边给了两台装有 CentOS8 的机器,一台做 master ,另一台做 worker ,我使用 kubeadm 搭建好之后,用 helm 把我们的服务装了上去。但是部署完成之后我发现 pod 里面的时间和主机的不一致,更奇怪的是,时区竟然是一致的:
我上网搜可能的解决方案,发现的都是针对 时区不一致、时差 8 小时 这种情况的解决方案。我这情况实在是不知道该从哪里入手去排查了,有 k8s 高手可以帮忙指点一下吗?
1
C1V7dYXW4PN67euV 2023 年 2 月 13 日
tzdata
|
2
mooyo 2023 年 2 月 13 日
开 NTP 让他自动同步试试?
|
3
aru 2023 年 2 月 13 日
先检查下那两台主机的时间是否一致
pod 时间和宿主机时间不一致没见过(时区不一样除外) |
7
julyclyde 2023 年 2 月 13 日
容器内还有时钟设备吗??
|
8
aapeli 2023 年 2 月 13 日
挂载宿主的 /etc/localtime /etc/timezone 到容器里
|
9
fengche361 2023 年 2 月 13 日
挂载宿主的 /etc/timezone 能保证内外时区一致,挂载宿主的 /etc/localtime 能保证内外时间一致
|
10
julyclyde 2023 年 2 月 13 日
你大概是把俩文件搞反了
https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_node/libc_431.html If the TZ environment variable does not have a value, the operation chooses a time zone by default. In the GNU C library, the default time zone is like the specification `TZ=:/etc/localtime' If characters begins with a slash, it is an absolute file name; otherwise the library looks for the file `/share/lib/zoneinfo/characters'. The `zoneinfo' directory contains data files describing local time zones in many different parts of the world. The names represent major cities, with subdirectories for geographical areas; for example, `America/New_York', `Europe/London', `Asia/Hong_Kong'. These data files are installed by the system administrator, who also sets `/etc/localtime' to point to the data file for the local time zone. 这是 localtime 符号连接的来源 |