From 173c4a73accba98b75e8e578b3a5a8ac185abd84 Mon Sep 17 00:00:00 2001
From: Steve Wilkerson <wilkers.steve@gmail.com>
Date: Mon, 5 Mar 2018 10:44:16 -0600
Subject: [PATCH] node-exporter: use endpoints section and lookups to set port

This PS moves node-exporter to use the endpoints section and
lookups to set the ports it serves on.

Change-Id: Id6d71b12e531375e792384ac4410bce74170d033
---
 prometheus-node-exporter/templates/daemonset.yaml | 4 ++--
 prometheus-node-exporter/templates/service.yaml   | 4 ++--
 prometheus-node-exporter/values.yaml              | 6 ------
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/prometheus-node-exporter/templates/daemonset.yaml b/prometheus-node-exporter/templates/daemonset.yaml
index 0c2b2af6e6..957656d9ed 100644
--- a/prometheus-node-exporter/templates/daemonset.yaml
+++ b/prometheus-node-exporter/templates/daemonset.yaml
@@ -65,8 +65,8 @@ spec:
             - --collector.mountstats
           ports:
             - name: metrics
-              containerPort: {{ .Values.network.node_exporter.port }}
-              hostPort: {{ .Values.network.node_exporter.port }}
+              containerPort: {{ tuple "node_metrics" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
+              hostPort: {{ tuple "node_metrics" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
 {{ tuple $envAll $envAll.Values.pod.resources.node_exporter | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
           volumeMounts:
             - name: proc
diff --git a/prometheus-node-exporter/templates/service.yaml b/prometheus-node-exporter/templates/service.yaml
index 482ee48bba..5565c9984e 100644
--- a/prometheus-node-exporter/templates/service.yaml
+++ b/prometheus-node-exporter/templates/service.yaml
@@ -33,8 +33,8 @@ spec:
   clusterIP: None
   ports:
   - name: metrics
-    port: {{ .Values.network.node_exporter.port }}
-    targetPort: {{ .Values.network.node_exporter.port }}
+    port: {{ tuple "node_metrics" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
+    targetPort: {{ tuple "node_metrics" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
   selector:
 {{ tuple $envAll "node_exporter" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
 {{- end }}
diff --git a/prometheus-node-exporter/values.yaml b/prometheus-node-exporter/values.yaml
index 78f0c11bf5..fb33a49f9c 100644
--- a/prometheus-node-exporter/values.yaml
+++ b/prometheus-node-exporter/values.yaml
@@ -103,10 +103,6 @@ monitoring:
     node_exporter:
       scrape: true
 
-network:
-  node_exporter:
-    port: 9100
-
 endpoints:
   cluster_domain_suffix: cluster.local
   local_image_registry:
@@ -134,8 +130,6 @@ endpoints:
     port:
       metrics:
         default: 9100
-      prometheus_port:
-        default: 9100
 
 manifests:
   configmap_bin: true