Skip to content

[kube-state-metrics] Fix autosharding configuration service - #7176

Open
Alja9 wants to merge 7 commits into
prometheus-community:mainfrom
Alja9:fix-shard
Open

[kube-state-metrics] Fix autosharding configuration service#7176
Alja9 wants to merge 7 commits into
prometheus-community:mainfrom
Alja9:fix-shard

Conversation

@Alja9

@Alja9 Alja9 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it

Enforce ClusterIP for autosharding, avoid headless service error.

Which issue this PR fixes

Autosharding get a Kubernetes error, example:

level=WARN msg="upgrade failed" name=my-kube-state-metrics error="Service \"my-kube-state-metrics\" is invalid: spec.clusterIPs[0]: Invalid value: \"None\": may not be set to 'None' for NodePort services"
Error: UPGRADE FAILED: Service "my-kube-state-metrics" is invalid: spec.clusterIPs[0]: Invalid value: "None": may not be set to 'None' for NodePort services

Instead of giving an error, how about to enforce it to the ClusterIP (auto-corrected, no Kubernetes error).

(optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged)

  • fixes #

Special notes for your reviewer

Checklist

  • DCO signed
  • Chart Version bumped
  • Title of the PR starts with chart name (e.g. [prometheus-couchdb-exporter])
  • Add an helm unittest test case to cover this change.

Alja9 and others added 5 commits August 6, 2026 00:45
Signed-off-by: aldi.j <aldi.jayadi222@gmail.com>
Signed-off-by: aldi.j <aldi.jayadi222@gmail.com>

Co-authored-by: GitHub Copilot <copilot@github.com>
Signed-off-by: aldi.j <aldi.jayadi222@gmail.com>
Signed-off-by: Aldi Jayadi <34116297+Alja9@users.noreply.github.com>
Signed-off-by: Aldi Jayadi <34116297+Alja9@users.noreply.github.com>
Alja9 added 2 commits August 9, 2026 21:39
Signed-off-by: Aldi Jayadi <34116297+Alja9@users.noreply.github.com>
Signed-off-by: Aldi Jayadi <34116297+Alja9@users.noreply.github.com>

@sebastiangaiser sebastiangaiser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix, this resolves the invalid Service manifest you get with autosharding plus a NodePort/LoadBalancer service.type (headless + NodePort can't coexist), and it also corrects the metrics-port nodePort guard that was checking service.nodePort instead of selfMonitor.telemetryNodePort. A few small things:

  • Two of the unit tests are named "fails when autosharding enabled with NodePort/LoadBalancer service type", but they don't fail, they assert the service is forced to headless ClusterIP. Could you please rename them to match (e.g. "forces headless ClusterIP even when service.type is NodePort")?
  • The test file is missing a trailing newline.
  • Needs a rebase on main (currently conflicting) and a re-bump to 8.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants