Skip to content

feat(chart): add prometheus servicemonitor support - #456

Open
Ayush4958 wants to merge 1 commit into
kubernetes-sigs:mainfrom
Ayush4958:feat/add-prometheus-service-monitor-support
Open

feat(chart): add prometheus servicemonitor support#456
Ayush4958 wants to merge 1 commit into
kubernetes-sigs:mainfrom
Ayush4958:feat/add-prometheus-service-monitor-support

Conversation

@Ayush4958

@Ayush4958 Ayush4958 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Description

Adds native Prometheus Operator ServiceMonitor support to the Helm chart.
The template is safely guarded by .Capabilities.APIVersions.Has to prevent crashing non prometheus clusters & automatically handles TLS injection for secure metric endpoints.

Related Issue

Fixes #443

Type of Change

/kind feature

Testing

  • Executed helm template testing various edge cases (secure vs insecure metrics).
  • Helm unit tests added to cover all logic paths.

Checklist

  • make test passes
  • make lint passes

Does this PR introduce a user-facing change?

Added Prometheus ServiceMonitor template to Helm chart via `metrics.serviceMonitor.enabled`.

@kubernetes-prow kubernetes-prow Bot added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 25, 2026
@netlify

netlify Bot commented Aug 25, 2026

Copy link
Copy Markdown

Deploy Preview for node-readiness-controller canceled.

Name Link
🔨 Latest commit 212ba52
🔍 Latest deploy log https://app.netlify.com/projects/node-readiness-controller/deploys/6a8d43003375d40008da1253

@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Ayush4958
Once this PR has been reviewed and has the lgtm label, please assign sergeykanzhelev for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 25, 2026
@kubernetes-prow

Copy link
Copy Markdown

Hi @Ayush4958. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubernetes-prow kubernetes-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 25, 2026
@Ayush4958

Copy link
Copy Markdown
Contributor Author

Hi @ajaysundark ,
PR is ready for review
take time to review it

thanks ...

@AvineshTripathi

Copy link
Copy Markdown
Contributor

cc @rawadhossain

@rawadhossain rawadhossain 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.

Took a first look at this.

one question on the secure metrics setup, how is the prometheus serviceaccount supposed to get the metrics-reader permission?

also, looks like the new serviceMonitor values are missing from the README.

Comment on lines +24 to +27
{{- if .Values.metrics.secure }}
scheme: https
tlsConfig:
insecureSkipVerify: true

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.

when metrics.secure is enabled, don't we also need to configure the bearer token for the metrics endpoint? also, can we avoid insecureSkipVerify here and use the generated cert instead?

{{- if not .Values.metrics.enabled }}
{{- fail "You enabled metrics.serviceMonitor.enabled, but metrics.enabled is false. Please enable metrics to use the ServiceMonitor." }}
{{- end }}
{{- if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" }}

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.

if serviceMonitor.enabled=true but the CRD isn't installed, this just renders nothing. do we want to warn here, or is the current behavior intentional?

Comment on lines +26 to +27
# Note: testing .Capabilities.APIVersions.Has is not fully supported by helm-unittest,
# but assuming the environment supports it, we can test standard rendering.

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.

I think helm-unittest supports capabilities.apiVersions here. Since it's already been used below, can we also add a case where CRD isn't present?

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

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Helm chart missing ServiceMonitor template for Prometheus Operator integration

3 participants