Skip to content

Commit

Permalink
[prometheus] Add config for hard/soft podAntiAffinity and bump chart …
Browse files Browse the repository at this point in the history
…deps (#4341)

* [prometheus] Add config for hard/soft podAntiAffinity

Signed-off-by: James Andrew <[email protected]>

* [prometheus] bump dependencies

prometheus-pushgateway to 2.8.0
kube-state-metrics to 5.16.4

Signed-off-by: James Andrew <[email protected]>

* [prometheus] Bump prometheus chart to v25.17.0

Signed-off-by: James Andrew <[email protected]>

* [prometheus] Fix indentation of pod affinity

Signed-off-by: James Andrew <[email protected]>

---------

Signed-off-by: James Andrew <[email protected]>
  • Loading branch information
james-jra authored Mar 8, 2024
1 parent 0511d29 commit 2430376
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 10 deletions.
8 changes: 4 additions & 4 deletions charts/prometheus/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ dependencies:
version: 1.9.0
- name: kube-state-metrics
repository: https://prometheus-community.github.io/helm-charts
version: 5.16.2
version: 5.16.4
- name: prometheus-node-exporter
repository: https://prometheus-community.github.io/helm-charts
version: 4.30.3
- name: prometheus-pushgateway
repository: https://prometheus-community.github.io/helm-charts
version: 2.7.1
digest: sha256:5ed0b00e1cc49009ca45133136a02c38f311f040b063914c04864983f6df5721
generated: "2024-03-01T05:51:36.909838+02:00"
version: 2.8.0
digest: sha256:23062baabef57dc60e08aaec1882cdde4f84ec9d2807573368b7e86ec1fa89f0
generated: "2024-03-08T09:36:45.247714358Z"
4 changes: 2 additions & 2 deletions charts/prometheus/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: prometheus
appVersion: v2.50.1
version: 25.16.0
version: 25.17.0
kubeVersion: ">=1.19.0-0"
description: Prometheus is a monitoring system and time series database.
home: https://prometheus.io/
Expand Down Expand Up @@ -38,7 +38,7 @@ dependencies:
repository: https://prometheus-community.github.io/helm-charts
condition: prometheus-node-exporter.enabled
- name: prometheus-pushgateway
version: "2.7.*"
version: "2.8.*"
repository: https://prometheus-community.github.io/helm-charts
condition: prometheus-pushgateway.enabled
keywords:
Expand Down
23 changes: 21 additions & 2 deletions charts/prometheus/templates/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,29 @@ spec:
tolerations:
{{ toYaml .Values.server.tolerations | indent 8 }}
{{- end }}
{{- if .Values.server.affinity }}
{{- if or .Values.server.affinity .Values.server.podAntiAffinity }}
affinity:
{{ toYaml .Values.server.affinity | indent 8 }}
{{- end }}
{{- with .Values.server.affinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if eq .Values.server.podAntiAffinity "hard" }}
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: {{ .Values.server.podAntiAffinityTopologyKey }}
labelSelector:
matchExpressions:
- {key: app.kubernetes.io/name, operator: In, values: [{{ template "prometheus.name" . }}]}
{{- else if eq .Values.server.podAntiAffinity "soft" }}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
topologyKey: {{ .Values.server.podAntiAffinityTopologyKey }}
labelSelector:
matchExpressions:
- {key: app.kubernetes.io/name, operator: In, values: [{{ template "prometheus.name" . }}]}
{{- end }}
{{- with .Values.server.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
Expand Down
23 changes: 21 additions & 2 deletions charts/prometheus/templates/sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,29 @@ spec:
tolerations:
{{ toYaml .Values.server.tolerations | indent 8 }}
{{- end }}
{{- if .Values.server.affinity }}
{{- if or .Values.server.affinity .Values.server.podAntiAffinity }}
affinity:
{{ toYaml .Values.server.affinity | indent 8 }}
{{- end }}
{{- with .Values.server.affinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if eq .Values.server.podAntiAffinity "hard" }}
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: {{ .Values.server.podAntiAffinityTopologyKey }}
labelSelector:
matchExpressions:
- {key: app.kubernetes.io/name, operator: In, values: [{{ template "prometheus.name" . }}]}
{{- else if eq .Values.server.podAntiAffinity "soft" }}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
topologyKey: {{ .Values.server.podAntiAffinityTopologyKey }}
labelSelector:
matchExpressions:
- {key: app.kubernetes.io/name, operator: In, values: [{{ template "prometheus.name" . }}]}
{{- end }}
{{- with .Values.server.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
Expand Down
8 changes: 8 additions & 0 deletions charts/prometheus/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,14 @@
"podAnnotations": {
"type": "object"
},
"podAntiAffinity": {
"type": "string",
"enum": ["", "soft", "hard"],
"default": ""
},
"podAntiAffinityTopologyKey": {
"type": "string"
},
"podDisruptionBudget": {
"type": "object",
"properties": {
Expand Down
12 changes: 12 additions & 0 deletions charts/prometheus/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,18 @@ server:
##
affinity: {}

## Pod anti-affinity can prevent the scheduler from placing Prometheus server 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 `server.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

## Pod topology spread constraints
## ref. https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
topologySpreadConstraints: []
Expand Down

0 comments on commit 2430376

Please sign in to comment.