官方Prometheus镜像,使用的不是咱们上海的时区,我们可以用上海时区文件创建一个configmap,然后挂载到启动的Prometheus容器里:
kubectl create configmap prometheus-time-zone --from-file=/usr/share/zoneinfo/Asia/Shanghai
然后挂载:
volumeMounts:
- name: prometheus-time-zone
mountPath: /etc/localtime
subPath: Shanghai
然后可以把容器里的时区改成上海时区,东八区
用date 验证时间是本地时间了
但这个只是改了Prometheus容器得本地时区文件而已。centos系统 就是/etc/localtime Ubuntu是/etc/timezone
但是Prometheus 是在代码里,统一做得UTC转换
类似这样: