From 1f70a6b763a245f135f34c5a71f7149e3926d84c Mon Sep 17 00:00:00 2001 From: Nicole Date: Wed, 24 Jan 2024 07:19:25 -0700 Subject: [PATCH] [prometheus-node-exporter] Add variable to change port for node-exporter daemonset (#4167) * added var for port to be used in daemonset. Added option to add host port and change name for kuberbacproxy container port Signed-off-by: Nicole * changed default of hostport to false Signed-off-by: Nicole * added default value for port name to values file instead of in daemonset template Signed-off-by: Nicole * changed comments for new vars and changed name of var to enable hostport Signed-off-by: Nicole --------- Signed-off-by: Nicole --- charts/prometheus-node-exporter/Chart.yaml | 2 +- charts/prometheus-node-exporter/templates/daemonset.yaml | 7 +++++-- charts/prometheus-node-exporter/values.yaml | 7 +++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/charts/prometheus-node-exporter/Chart.yaml b/charts/prometheus-node-exporter/Chart.yaml index 54feef684a61..83d592222528 100644 --- a/charts/prometheus-node-exporter/Chart.yaml +++ b/charts/prometheus-node-exporter/Chart.yaml @@ -6,7 +6,7 @@ keywords: - prometheus - exporter type: application -version: 4.25.0 +version: 4.26.0 appVersion: 1.7.0 home: https://github.com/prometheus/node_exporter/ sources: diff --git a/charts/prometheus-node-exporter/templates/daemonset.yaml b/charts/prometheus-node-exporter/templates/daemonset.yaml index d9e418169b25..82dba5cabeec 100644 --- a/charts/prometheus-node-exporter/templates/daemonset.yaml +++ b/charts/prometheus-node-exporter/templates/daemonset.yaml @@ -41,7 +41,7 @@ spec: {{- end }} serviceAccountName: {{ include "prometheus-node-exporter.serviceAccountName" . }} containers: - {{- $servicePort := ternary 8100 .Values.service.port .Values.kubeRBACProxy.enabled }} + {{- $servicePort := ternary .Values.kubeRBACProxy.port .Values.service.port .Values.kubeRBACProxy.enabled }} - name: node-exporter image: {{ include "prometheus-node-exporter.image" . }} imagePullPolicy: {{ .Values.image.pullPolicy }} @@ -200,7 +200,10 @@ spec: {{- end }} ports: - containerPort: {{ .Values.service.port}} - name: "http" + name: {{ .Values.kubeRBACProxy.portName }} + {{- if .Values.kubeRBACProxy.enableHostPort }} + hostPort: {{ .Values.service.port }} + {{- end }} - containerPort: 8888 name: "http-healthz" readinessProbe: diff --git a/charts/prometheus-node-exporter/values.yaml b/charts/prometheus-node-exporter/values.yaml index 7cb89068cce3..fad11ea0e27f 100644 --- a/charts/prometheus-node-exporter/values.yaml +++ b/charts/prometheus-node-exporter/values.yaml @@ -56,6 +56,13 @@ kubeRBACProxy: ## Ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container containerSecurityContext: {} + # Specify the port used for the Node exporter container (upstream port) + port: 8100 + # Specify the name of the container port + portName: http + # Configure a hostPort. If true, hostPort will be enabled in the container and set to service.port. + enableHostPort: false + resources: {} # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little