diff --git a/README.md b/README.md index 5901d192bc9ac93d00e008e76d29d02d7d437358..bbc0d0a76dcdc9cdf2ab550422cd048eeccc9692 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,10 @@ These are the available fields with their respective default values: cpuPerNode: '2m', memoryPerNode: '30Mi', }, + + nodeExporter+:: { + port: 9100, + }, }, } ``` diff --git a/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet b/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet index c9e1faeb00cb313b24c9ef243e680ac28252d42e..d7f77bf9f85f2c87294461a01c6e6dc63e611c9a 100644 --- a/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet +++ b/jsonnet/kube-prometheus/node-exporter/node-exporter.libsonnet @@ -13,6 +13,10 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; nodeExporter: 'quay.io/prometheus/node-exporter', kubeRbacProxy: 'quay.io/coreos/kube-rbac-proxy', }, + + nodeExporter+:: { + port: 9100, + }, }, nodeExporter+:: { @@ -83,7 +87,7 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; local nodeExporter = container.new('node-exporter', $._config.imageRepos.nodeExporter + ':' + $._config.versions.nodeExporter) + container.withArgs([ - '--web.listen-address=127.0.0.1:9100', + '--web.listen-address=127.0.0.1:' + $._config.nodeExporter.port, '--path.procfs=/host/proc', '--path.sysfs=/host/sys', @@ -101,8 +105,8 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; local proxy = container.new('kube-rbac-proxy', $._config.imageRepos.kubeRbacProxy + ':' + $._config.versions.kubeRbacProxy) + container.withArgs([ - '--secure-listen-address=$(IP):9100', - '--upstream=http://127.0.0.1:9100/', + '--secure-listen-address=$(IP):' + $._config.nodeExporter.port, + '--upstream=http://127.0.0.1:' + $._config.nodeExporter.port + '/', ]) + // Keep `hostPort` here, rather than in the node-exporter container // because Kubernetes mandates that if you define a `hostPort` then @@ -112,7 +116,7 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; // used by the service is tied to the proxy container. We *could* // forgo declaring the host port, however it is important to declare // it so that the scheduler can decide if the pod is schedulable. - container.withPorts(containerPort.new(9100) + containerPort.withHostPort(9100) + containerPort.withName('https')) + + container.withPorts(containerPort.new($._config.nodeExporter.port) + containerPort.withHostPort($._config.nodeExporter.port) + containerPort.withName('https')) + container.mixin.resources.withRequests({ cpu: '10m', memory: '20Mi' }) + container.mixin.resources.withLimits({ cpu: '20m', memory: '40Mi' }) + container.withEnv([ip]); @@ -177,7 +181,7 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; local service = k.core.v1.service; local servicePort = k.core.v1.service.mixin.spec.portsType; - local nodeExporterPort = servicePort.newNamed('https', 9100, 'https'); + local nodeExporterPort = servicePort.newNamed('https', $._config.nodeExporter.port, 'https'); service.new('node-exporter', $.nodeExporter.daemonset.spec.selector.matchLabels, nodeExporterPort) + service.mixin.metadata.withNamespace($._config.namespace) +