helm: allow Service creation and custom annotations for Prometheus scraping#1267
Open
lvg-dexters wants to merge 1 commit intoaws:mainfrom
Open
helm: allow Service creation and custom annotations for Prometheus scraping#1267lvg-dexters wants to merge 1 commit intoaws:mainfrom
lvg-dexters wants to merge 1 commit intoaws:mainfrom
Conversation
…raping Adds two opt-in values to the chart: - service.create: when true in IMDS/DaemonSet mode, creates a headless Service (clusterIP: None) selecting DaemonSet pods. Default false preserves existing behavior. SQS mode continues to auto-create a Service as before. - service.annotations: applied to the Service metadata. Enables attaching prometheus.io/* annotations for scrape discovery via endpointslice-based mechanisms (vanilla Prometheus, Grafana Alloy, grafana/k8s-monitoring). Strictly additive and backward-compatible. Existing SQS users see no change. Existing IMDS users who do not set service.create see no change. Only IMDS users who explicitly opt in get the new Service. Verified via helm template across behavior matrix: - enablePrometheusServer=false: no Service (all modes) - SQS=false, PromServer=true, service.create=false: no Service (legacy IMDS) - SQS=false, PromServer=true, service.create=true: headless Service with DaemonSet selector - SQS=true, PromServer=true: ClusterIP Service with Deployment selector (legacy SQS, unchanged) Refs aws#1266
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available: Closes #1266
Description of changes:
Adds two opt-in values to the Helm chart so the metrics Service can be used for Prometheus scrape discovery in IMDS/DaemonSet mode, and so any chart-created Service can carry custom annotations.
Motivation
Today the Service template at
config/helm/aws-node-termination-handler/templates/service.yamlis only rendered whenenableSqsTerminationDrainingANDenablePrometheusServerare both true, and the Service metadata has no annotations block. That leaves users running NTH in IMDS mode withenablePrometheusServer: truewithout a chart-native path to expose metrics for endpointslice-based discovery (vanilla Prometheus, Grafana Alloy, grafana/k8s-monitoring).podMonitor.createaddresses Prometheus Operator users, but annotation-based discovery has no option.Full problem statement and design rationale in the linked issue (#1266).
Changes
Two files, 30 additions total.
config/helm/aws-node-termination-handler/values.yamlservice.create: false(boolean, default false). When true in IMDS mode, creates a headless Service.service.annotations: {}(default empty). Applied to the Service metadata when present.config/helm/aws-node-termination-handler/templates/service.yamlif and .Values.enablePrometheusServer (or .Values.enableSqsTerminationDraining .Values.service.create).labelsandspec.selectorbranch on mode:labelsDeployment/selectorLabelsDeploymentin SQS mode (unchanged),labelsDaemonset/selectorLabelsDaemonsetin IMDS mode. Both helpers already exist in_helpers.tpl.spec.clusterIP: Noneadded in IMDS mode only (headless). SQS mode keeps existingtype: ClusterIPbehavior exactly.metadata.annotationsblock threads.Values.service.annotationswhen set.Backward compatibility
Strictly additive. Behavior matrix:
enableSqsTerminationDrainingenablePrometheusServerservice.createfalsetruetruefalsetruetruetruefalsetruefalsefalsetruetrueExisting SQS users: zero change. Existing IMDS users who do not set
service.create: zero change. Only IMDS users who explicitly opt in see new behavior.How you tested your changes:
Environment (Linux / Windows): Linux (macOS host, Helm 3.19.0)
Kubernetes Version: Not applied to a cluster for this change (pure chart templating). Expected to work on any Kubernetes version supporting
v1Service(all supported versions).Ran
helm lint(passes) andhelm templateacross the full behavior matrix:All matrix rows produce expected output. Annotations propagate correctly.
Checklist
mainservice.annotations,serviceAnnotationson 2026-04-24)helm lintpasseshelm templateverified across the full behavior matrixBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.