diff --git a/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet b/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet index 264f4a08b3155ad5313bb8520fb36abdfd43428d..cf55c02a6c87fa66909d6a87f803e1f128ea4f5f 100644 --- a/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet +++ b/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet @@ -20,6 +20,11 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; 'app.kubernetes.io/name': 'node-exporter', 'app.kubernetes.io/version': $._config.versions.nodeExporter, }, + selectorLabels: { + [labelName]: $._config.nodeExporter.labels[labelName] + for labelName in std.objectFields($._config.nodeExporter.labels) + if !std.setMember(labelName, ['app.kubernetes.io/version']) + }, }, }, @@ -69,6 +74,7 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; local containerEnv = container.envType; local podLabels = $._config.nodeExporter.labels; + local selectorLabels = $._config.nodeExporter.selectorLabels; local existsToleration = toleration.new() + toleration.withOperator('Exists'); @@ -133,7 +139,7 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; daemonset.mixin.metadata.withName('node-exporter') + daemonset.mixin.metadata.withNamespace($._config.namespace) + daemonset.mixin.metadata.withLabels(podLabels) + - daemonset.mixin.spec.selector.withMatchLabels(podLabels) + + daemonset.mixin.spec.selector.withMatchLabels(selectorLabels) + daemonset.mixin.spec.template.metadata.withLabels(podLabels) + daemonset.mixin.spec.template.spec.withTolerations([existsToleration]) + daemonset.mixin.spec.template.spec.withNodeSelector({ 'kubernetes.io/os': 'linux' }) + @@ -163,7 +169,7 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; spec: { jobLabel: 'app.kubernetes.io/name', selector: { - matchLabels: $._config.nodeExporter.labels, + matchLabels: $._config.nodeExporter.selectorLabels, }, endpoints: [ { @@ -194,7 +200,7 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; local nodeExporterPort = servicePort.newNamed('https', $._config.nodeExporter.port, 'https'); - service.new('node-exporter', $.nodeExporter.daemonset.spec.selector.matchLabels, nodeExporterPort) + + service.new('node-exporter', $._config.nodeExporter.selectorLabels, nodeExporterPort) + service.mixin.metadata.withNamespace($._config.namespace) + 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 3e61863a7c80c92e3324d14b8b36028e1772568d..1ed3478ed635e7860a2a38935653f54ec75c16c7 100644 --- a/manifests/node-exporter-daemonset.yaml +++ b/manifests/node-exporter-daemonset.yaml @@ -10,7 +10,6 @@ spec: selector: matchLabels: app.kubernetes.io/name: node-exporter - app.kubernetes.io/version: v0.18.1 template: metadata: labels: diff --git a/manifests/node-exporter-service.yaml b/manifests/node-exporter-service.yaml index 174bc0fea5d96b8e9a6226b1ee5f9eb42af5e798..7dfbef6391d2d80d194f194b49ef6f6cee6c8448 100644 --- a/manifests/node-exporter-service.yaml +++ b/manifests/node-exporter-service.yaml @@ -14,4 +14,3 @@ spec: targetPort: https selector: app.kubernetes.io/name: node-exporter - app.kubernetes.io/version: v0.18.1 diff --git a/manifests/node-exporter-serviceMonitor.yaml b/manifests/node-exporter-serviceMonitor.yaml index c74c470023ec344e4da1fb796eb191a6a3d9c42a..357164d9ed211def81ffa132f7eb16ee4a03c430 100644 --- a/manifests/node-exporter-serviceMonitor.yaml +++ b/manifests/node-exporter-serviceMonitor.yaml @@ -25,4 +25,3 @@ spec: selector: matchLabels: app.kubernetes.io/name: node-exporter - app.kubernetes.io/version: v0.18.1