From 3a93f396471f811645006c5c31ea22015a08d676 Mon Sep 17 00:00:00 2001 From: Carlos de Paula Date: Mon, 25 May 2020 19:14:28 -0300 Subject: [PATCH] Add relabeling to have the correct node name --- arm_exporter.jsonnet | 2 +- utils.libsonnet | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/arm_exporter.jsonnet b/arm_exporter.jsonnet index eb780e7..6c7744d 100644 --- a/arm_exporter.jsonnet +++ b/arm_exporter.jsonnet @@ -73,7 +73,7 @@ local utils = import 'utils.libsonnet'; daemonset.mixin.spec.selector.withMatchLabels(podLabels) + daemonset.mixin.spec.template.metadata.withLabels(podLabels) + daemonset.mixin.spec.template.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.withNodeSelectorTerms([{ matchExpressions: [{ key: 'kubernetes.io/arch', operator: 'In', values: ['arm', 'arm64'] }] }]) + - daemonset.mixin.spec.template.spec.withTolerations([{ 'operator': 'Exists' }]) + + daemonset.mixin.spec.template.spec.withTolerations([{ operator: 'Exists' }]) + daemonset.mixin.spec.template.spec.withServiceAccountName('arm-exporter') + daemonset.mixin.spec.template.spec.withContainers(c), diff --git a/utils.libsonnet b/utils.libsonnet index 16c4f2b..45482ff 100644 --- a/utils.libsonnet +++ b/utils.libsonnet @@ -196,6 +196,15 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; port: portName, scheme: portScheme, interval: '30s', + relabelings: [ + { + action: 'replace', + regex: '(.*)', + replacement: '$1', + sourceLabels: ['__meta_kubernetes_pod_node_name'], + targetLabel: 'instance', + }, + ], }, ], namespaceSelector: { @@ -219,13 +228,21 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; tlsConfig: { insecureSkipVerify: true, }, + relabelings: [ + { + action: 'replace', + regex: '(.*)', + replacement: '$1', + sourceLabels: ['__meta_kubernetes_pod_node_name'], + targetLabel: 'instance', + }, + ], }], }, }; std.mergePatch(s, t) ), - // Adds arguments to a container in a deployment // args is an array of arguments in the format // ["arg1","arg2",]