diff --git a/charts/prometheus-pushgateway/Chart.yaml b/charts/prometheus-pushgateway/Chart.yaml index a0e2af2f58f7..1b9633c6f5a7 100644 --- a/charts/prometheus-pushgateway/Chart.yaml +++ b/charts/prometheus-pushgateway/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 appVersion: "v1.7.0" description: A Helm chart for prometheus pushgateway name: prometheus-pushgateway -version: 2.7.1 +version: 2.8.0 home: https://github.com/prometheus/pushgateway sources: - https://github.com/prometheus/pushgateway diff --git a/charts/prometheus-pushgateway/templates/_helpers.tpl b/charts/prometheus-pushgateway/templates/_helpers.tpl index 73eefcb1c18d..af9bad350e62 100644 --- a/charts/prometheus-pushgateway/templates/_helpers.tpl +++ b/charts/prometheus-pushgateway/templates/_helpers.tpl @@ -182,10 +182,29 @@ nodeSelector: tolerations: {{- toYaml . | nindent 2 }} {{- end }} -{{- with .Values.affinity }} +{{- if or .Values.podAntiAffinity .Values.affinity }} affinity: - {{- toYaml . | nindent 2 }} {{- end }} + {{- with .Values.affinity }} + {{- toYaml . | nindent 2 }} + {{- end }} + {{- if eq .Values.podAntiAffinity "hard" }} + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - topologyKey: {{ .Values.podAntiAffinityTopologyKey }} + labelSelector: + matchExpressions: + - {key: app.kubernetes.io/name, operator: In, values: [{{ include "prometheus-pushgateway.name" . }}]} + {{- else if eq .Values.podAntiAffinity "soft" }} + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + topologyKey: {{ .Values.podAntiAffinityTopologyKey }} + labelSelector: + matchExpressions: + - {key: app.kubernetes.io/name, operator: In, values: [{{ include "prometheus-pushgateway.name" . }}]} + {{- end }} {{- with .Values.topologySpreadConstraints }} topologySpreadConstraints: {{- toYaml . | nindent 2 }} diff --git a/charts/prometheus-pushgateway/values.yaml b/charts/prometheus-pushgateway/values.yaml index 344b22d64131..1f67939dbe40 100644 --- a/charts/prometheus-pushgateway/values.yaml +++ b/charts/prometheus-pushgateway/values.yaml @@ -213,6 +213,18 @@ containerSecurityContext: {} ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity affinity: {} +## Pod anti-affinity can prevent the scheduler from placing pushgateway replicas on the same node. +## The value "soft" means that the scheduler should *prefer* to not schedule two replica pods onto the same node but no guarantee is provided. +## The value "hard" means that the scheduler is *required* to not schedule two replica pods onto the same node. +## The default value "" will disable pod anti-affinity so that no anti-affinity rules will be configured (unless set in `affinity`). +## +podAntiAffinity: "" + +## If anti-affinity is enabled sets the topologyKey to use for anti-affinity. +## This can be changed to, for example, failure-domain.beta.kubernetes.io/zone +## +podAntiAffinityTopologyKey: kubernetes.io/hostname + ## Topology spread constraints for pods ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/ topologySpreadConstraints: []