From 6f4f34606d01c3bd3d0cd2e3efa4915da56e65ba Mon Sep 17 00:00:00 2001 From: Rajat Vig <rvig@etsy.com> Date: Sat, 21 Mar 2020 12:12:22 +0000 Subject: [PATCH] Remove custom k8s-app label in favor of standard k8s labels in the manifest for node-exporter --- .../node-exporter/node-exporter.libsonnet | 18 +++++++++--------- manifests/node-exporter-daemonset.yaml | 2 ++ manifests/node-exporter-service.yaml | 3 ++- manifests/node-exporter-serviceMonitor.yaml | 8 +++++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet b/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet index 1f108e04..ffa16129 100644 --- a/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet +++ b/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet @@ -16,6 +16,10 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; nodeExporter+:: { port: 9100, + labels: { + 'app.kubernetes.io/name': 'node-exporter', + 'app.kubernetes.io/version': $._config.versions.nodeExporter, + }, }, }, @@ -128,7 +132,7 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; daemonset.new() + daemonset.mixin.metadata.withName('node-exporter') + daemonset.mixin.metadata.withNamespace($._config.namespace) + - daemonset.mixin.metadata.withLabels(podLabels) + + daemonset.mixin.metadata.withLabels(podLabels + $._config.nodeExporter.labels) + daemonset.mixin.spec.selector.withMatchLabels(podLabels) + daemonset.mixin.spec.template.metadata.withLabels(podLabels) + daemonset.mixin.spec.template.spec.withTolerations([existsToleration]) + @@ -154,16 +158,12 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; metadata: { name: 'node-exporter', namespace: $._config.namespace, - labels: { - 'k8s-app': 'node-exporter', - }, + labels: $._config.nodeExporter.labels, }, spec: { - jobLabel: 'k8s-app', + jobLabel: 'app.kubernetes.io/name', selector: { - matchLabels: { - 'k8s-app': 'node-exporter', - }, + matchLabels: $._config.nodeExporter.labels, }, endpoints: [ { @@ -196,7 +196,7 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; service.new('node-exporter', $.nodeExporter.daemonset.spec.selector.matchLabels, nodeExporterPort) + service.mixin.metadata.withNamespace($._config.namespace) + - service.mixin.metadata.withLabels({ 'k8s-app': 'node-exporter' }) + + service.mixin.metadata.withLabels($._config.nodeExporter.labels) + service.mixin.spec.withClusterIp('None'), }, } diff --git a/manifests/node-exporter-daemonset.yaml b/manifests/node-exporter-daemonset.yaml index 7a65619a..80ae5fbe 100644 --- a/manifests/node-exporter-daemonset.yaml +++ b/manifests/node-exporter-daemonset.yaml @@ -3,6 +3,8 @@ kind: DaemonSet metadata: labels: app: node-exporter + app.kubernetes.io/name: node-exporter + app.kubernetes.io/version: v0.18.1 name: node-exporter namespace: monitoring spec: diff --git a/manifests/node-exporter-service.yaml b/manifests/node-exporter-service.yaml index 1d728d76..f2bec65d 100644 --- a/manifests/node-exporter-service.yaml +++ b/manifests/node-exporter-service.yaml @@ -2,7 +2,8 @@ apiVersion: v1 kind: Service metadata: labels: - k8s-app: node-exporter + app.kubernetes.io/name: node-exporter + app.kubernetes.io/version: v0.18.1 name: node-exporter namespace: monitoring spec: diff --git a/manifests/node-exporter-serviceMonitor.yaml b/manifests/node-exporter-serviceMonitor.yaml index 3ceed6c9..c74c4700 100644 --- a/manifests/node-exporter-serviceMonitor.yaml +++ b/manifests/node-exporter-serviceMonitor.yaml @@ -2,7 +2,8 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: labels: - k8s-app: node-exporter + app.kubernetes.io/name: node-exporter + app.kubernetes.io/version: v0.18.1 name: node-exporter namespace: monitoring spec: @@ -20,7 +21,8 @@ spec: scheme: https tlsConfig: insecureSkipVerify: true - jobLabel: k8s-app + jobLabel: app.kubernetes.io/name selector: matchLabels: - k8s-app: node-exporter + app.kubernetes.io/name: node-exporter + app.kubernetes.io/version: v0.18.1 -- GitLab