diff --git a/jsonnet/kube-prometheus/addons/anti-affinity.libsonnet b/jsonnet/kube-prometheus/addons/anti-affinity.libsonnet index 56ea5303b900f1af4576295864751567c3481a3a..d7a48107fa4eadfc8274ee9535bcd1426ce01f59 100644 --- a/jsonnet/kube-prometheus/addons/anti-affinity.libsonnet +++ b/jsonnet/kube-prometheus/addons/anti-affinity.libsonnet @@ -12,18 +12,18 @@ podAntiAffinity: 'soft', podAntiAffinityTopologyKey: 'kubernetes.io/hostname', }, + prometheusAdapter+: { + podAntiAffinity: 'soft', + podAntiAffinityTopologyKey: 'kubernetes.io/hostname', + }, }, - local antiaffinity(key, values, namespace, type, topologyKey) = { + local antiaffinity(labelSelector, namespace, type, topologyKey) = { local podAffinityTerm = { namespaces: [namespace], topologyKey: topologyKey, labelSelector: { - matchExpressions: [{ - key: key, - operator: 'In', - values: values, - }], + matchLabels: labelSelector, }, }, @@ -45,8 +45,7 @@ alertmanager+: { spec+: antiaffinity( - 'alertmanager', - [$.values.alertmanager.name], + $.alertmanager.config.selectorLabels, $.values.common.namespace, $.values.alertmanager.podAntiAffinity, $.values.alertmanager.podAntiAffinityTopologyKey, @@ -58,8 +57,7 @@ prometheus+: { spec+: antiaffinity( - 'prometheus', - [$.values.prometheus.name], + $.prometheus.config.selectorLabels, $.values.common.namespace, $.values.prometheus.podAntiAffinity, $.values.prometheus.podAntiAffinityTopologyKey, @@ -73,8 +71,7 @@ template+: { spec+: antiaffinity( - 'app.kubernetes.io/name', - ['blackbox-exporter'], + $.blackboxExporter.config.selectorLabels, $.values.common.namespace, $.values.blackboxExporter.podAntiAffinity, $.values.blackboxExporter.podAntiAffinityTopologyKey, @@ -84,4 +81,19 @@ }, }, + prometheusAdapter+: { + deployment+: { + spec+: { + template+: { + spec+: + antiaffinity( + $.prometheusAdapter.config.selectorLabels, + $.values.common.namespace, + $.values.prometheusAdapter.podAntiAffinity, + $.values.prometheusAdapter.podAntiAffinityTopologyKey, + ), + }, + }, + }, + }, } diff --git a/jsonnet/kube-prometheus/components/prometheus-adapter.libsonnet b/jsonnet/kube-prometheus/components/prometheus-adapter.libsonnet index 33b95d13e3a902cb7c6c3ff3e6ddf575f63258a2..341a2f5a89d8ba1bfd700207781cfe5a496aff9c 100644 --- a/jsonnet/kube-prometheus/components/prometheus-adapter.libsonnet +++ b/jsonnet/kube-prometheus/components/prometheus-adapter.libsonnet @@ -8,6 +8,7 @@ local defaults = { requests: { cpu: '102m', memory: '180Mi' }, limits: { cpu: '250m', memory: '180Mi' }, }, + replicas: 2, listenAddress: '127.0.0.1', port: 9100, commonLabels:: { @@ -162,12 +163,12 @@ function(params) { labels: pa._config.commonLabels, }, spec: { - replicas: 1, + replicas: pa._config.replicas, selector: { matchLabels: pa._config.selectorLabels }, strategy: { rollingUpdate: { maxSurge: 1, - maxUnavailable: 0, + maxUnavailable: 1, }, }, template: { diff --git a/manifests/prometheus-adapter-deployment.yaml b/manifests/prometheus-adapter-deployment.yaml index 92740436618ac553c122ebed9848ef3981ac5c10..787e18fbf557db19ffb5cf803202137cad561f36 100644 --- a/manifests/prometheus-adapter-deployment.yaml +++ b/manifests/prometheus-adapter-deployment.yaml @@ -9,7 +9,7 @@ metadata: name: prometheus-adapter namespace: monitoring spec: - replicas: 1 + replicas: 2 selector: matchLabels: app.kubernetes.io/component: metrics-adapter @@ -18,7 +18,7 @@ spec: strategy: rollingUpdate: maxSurge: 1 - maxUnavailable: 0 + maxUnavailable: 1 template: metadata: labels: