kube-state-metrics: kube-state-metrics with autosharding stops updating shards when the labels of the statefulset are updated
What happened:
When I updated the labels of the ksm statefulset when kube-state-metrics are deployed with autosharding updates, and thus the recalculation of shards, stop getting to pods that don’t get restarted
What you expected to happen:
I would expect shards update to happen even when statefulset labels are updated, as in k8s this is allowed and it doesn’t cause the pods to get restarted
How to reproduce it (as minimally and precisely as possible):
- clone kube-state-metrics repo
git clone https://github.com/kubernetes/kube-state-metrics && cd kube-state-metrics - with the editor of your choice add a label to the metadata of the
stsprone to change in examples/autosharding/statefulset.yaml e.g.app.revision: '1'and set replicas to2 - deploy ksm with autosharding
kubectl apply -k ./examples/autosharding - change the label
kubectl patch sts kube-state-metrics -n kube-system --patch '{"metadata": {"labels": {"app.revision": "2"}}}' - scale the statefulset to 3 replicas
kubectl scale statefulsets kube-state-metrics --replicas=3 -n kube-system - checks the logs of
pod/kube-state-metrics-0andpod/kube-state-metrics-1they didn’t update their shards calculation. This is recovered only after all pods are restarted and labels are not changed again.
Anything else we need to know?:
Environment:
- kube-state-metrics version: 2.11.0
- Kubernetes version (use
kubectl version):Client Version: v1.29.3 Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3 Server Version: v1.27.7-gke.1121002 - Cloud provider or hardware configuration: Google Kubernetes Engine (GKE)
- Other info: N/A
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 20 (20 by maintainers)
I can have a look. Will try reproducing this issue to understand what happened.