diff --git a/config/helm/aws-node-termination-handler/templates/service.yaml b/config/helm/aws-node-termination-handler/templates/service.yaml index 19f7b067..917da36e 100644 --- a/config/helm/aws-node-termination-handler/templates/service.yaml +++ b/config/helm/aws-node-termination-handler/templates/service.yaml @@ -1,15 +1,30 @@ -{{- if and .Values.enableSqsTerminationDraining .Values.enablePrometheusServer -}} +{{- if and .Values.enablePrometheusServer (or .Values.enableSqsTerminationDraining .Values.service.create) -}} apiVersion: v1 kind: Service metadata: name: {{ include "aws-node-termination-handler.fullname" . }} namespace: {{ .Release.Namespace }} labels: + {{- if .Values.enableSqsTerminationDraining }} {{- include "aws-node-termination-handler.labelsDeployment" . | nindent 4 }} + {{- else }} + {{- include "aws-node-termination-handler.labelsDaemonset" . | nindent 4 }} + {{- end }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: type: ClusterIP + {{- if not .Values.enableSqsTerminationDraining }} + clusterIP: None + {{- end }} selector: + {{- if .Values.enableSqsTerminationDraining }} {{- include "aws-node-termination-handler.selectorLabelsDeployment" . | nindent 4 }} + {{- else }} + {{- include "aws-node-termination-handler.selectorLabelsDaemonset" . | nindent 4 }} + {{- end }} ports: - name: http-metrics port: {{ .Values.prometheusServerPort }} diff --git a/config/helm/aws-node-termination-handler/values.yaml b/config/helm/aws-node-termination-handler/values.yaml index ada2864e..e1f6afe6 100644 --- a/config/helm/aws-node-termination-handler/values.yaml +++ b/config/helm/aws-node-termination-handler/values.yaml @@ -155,6 +155,20 @@ strategy: {} podDisruptionBudget: {} # maxUnavailable: 1 +service: + # Controls Service creation for the metrics server. + # - In SQS mode (enableSqsTerminationDraining=true): a Service is auto-created + # when enablePrometheusServer=true (legacy behavior, unchanged by this value). + # - In IMDS mode (enableSqsTerminationDraining=false): opt in by setting + # service.create=true. Creates a headless Service (clusterIP: None) pointing + # at DaemonSet pods, for Prometheus scrape discovery via Kubernetes endpoint + # slices. + # When enablePrometheusServer=false, no Service is created regardless. + create: false + # Annotations to add to the Service metadata. Useful for attaching + # prometheus.io/* annotations for endpoint-based scrape discovery. + annotations: {} + serviceMonitor: # Specifies whether ServiceMonitor should be created # this needs enableSqsTerminationDraining: true