cluster-monitoring-operator: Timezone problem with kube-state-metrics
Hi I updated my cluster yesterday with openshift-ansible with this commit https://github.com/openshift/openshift-ansible/commit/8c77207289a9ae8b1c3f565aba45d662e62a9fb3 This commit changed the timezone in api, controller and etcd. kube-state-metrics pod is still in UTC timezone and I get exactly this issue: https://github.com/kubernetes/kube-state-metrics/issues/500
What can I do? It is possible to set the timezone also in kube-state-metric pod?
Openshift-Version:
oc version
oc v3.11.0+b6db8e6-107
kubernetes v1.11.0+d4cacc0
features: Basic-Auth GSSAPI Kerberos SPNEGO
Server https://s-cp-lb-01.cloud.mycompany.de:443
openshift v3.11.0+d0c29df-98
kubernetes v1.11.0+d4cacc0
If you need more information let me know.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (14 by maintainers)
In 2019 a timezone should be not an issue. What the problem to set the TZ environment variable? It could be done by a ansible fact like described above.
From my side, it should be document that the timezone must be unique across the whole cluster. But the timezone should be managed by the user.
You might be get an ideal solution but it is not a real world solution.
Openshift is the enterprise version of kubernetes. Its mainly using inside onpremise datacenter. Supporting only UTC is bogus and breaks a lot IT process in (german) datacenters.
The worst case would be that RedHat official supports UTC only.
my opinion, for 3.x we should hostmount /etc/localtime into the kube-state-metrics container, just like we do with the api and etcd containers.
for 4.x we should use UTC everywhere. We should not continue down this path.
FYI @Reamer @brancz @sdodson
I’ve verified timezone influence for
CronJobas follows.In my conclusion,
CronJobstarting time depends oncontrol plane(controller)timezone, notkube-state-metricstimezone. Butkube_cronjob_next_schedule_timevalue depends onkube-state-metricstimezone. Look the test2 section, it’s buggy.api,controller,etcdtimezone:UTCkube-state-metrics:UTCCronJobSchedule:5 9 * * *kube_cronjob_next_schedule_time:UTCtimezone, even thoughCronJobis scheduled asJST. The time is same but timezone is different.api,controller,etcdtimezone:JST(UTC+9)kube-state-metrics:UTCCronJobSchedule:50 18 * * *kube_cronjob_next_schedule_time:api,controller,etcdtimezone:JST(UTC+9)kube-state-metrics:JST(UTC+9)CronJobSchedule:0 19 * * *kube_cronjob_next_schedule_time:test1>
After changing UTC timezone to JST for only control plane.
test2>
After stop
cluster-monitoring-operatorandprometheus-operator, change thetimezonetoJST(UTC+9) forkube-state-metrics.test3>
Hi @brancz, just update cluster-monitoring-operator. Your change works. Thank you.
I feel like this should be brought up on a broader level (probably at least on aos-devel), but yes I agree with this.
I think it’d be much better if everything were UTC than having components respecting different timezones.
We could implement a new ansible-playbook variable:
openshift_logging_kube_state_metrics_timezone: "Europe/Paris"Default value is generated via facts on the master.This value will be set as env var or config parameter… on the cluster-monitoring-operator deployment.
If the cluster-monitoring-operator detects this variable / config value, it will add a TZ env var to the kube-state-metrics deploy.
The kube-state-metrics can now translate the kubernetes metrics timezone to UTC or export the time values with +x values for its timezone so that prometheus can convert it to UTC.
@brancz Can I get your opinion whether you think we should revert the changes that were made in the linked pull requests for openshift-ansible? We did this because people complained when the api/controllers/etcd processes moved from host services to static pods without access to /etc/localtime which meant their log timestamps were different from the rest of the system.
Hi @bysnupy,
Steps to reproduce:
release-3.11.With a time zone in kube-api pod, the time for the next cron job is reported not in UTC any more. The application of kube-state-metrics but still calculates with UTC. Now I have the same issue, which is described here https://github.com/kubernetes/kube-state-metrics/issues/500