From 19b7e9731235fef16fe22be990a3246c224e8ce0 Mon Sep 17 00:00:00 2001 From: TheRealNoob Date: Wed, 29 Jan 2025 10:44:46 -0800 Subject: [PATCH] [kube-state-metrics] tpl for affinity (#5231) * [kube-state-metrics] tpl affinity Signed-off-by: TheRealNoob * update values.yaml Signed-off-by: TheRealNoob * Update charts/kube-state-metrics/values.yaml Signed-off-by: David Calvert * Update charts/kube-state-metrics/values.yaml Signed-off-by: David Calvert --------- Signed-off-by: TheRealNoob Signed-off-by: David Calvert Co-authored-by: David Calvert --- charts/kube-state-metrics/Chart.yaml | 2 +- charts/kube-state-metrics/templates/deployment.yaml | 6 +++++- charts/kube-state-metrics/values.yaml | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/charts/kube-state-metrics/Chart.yaml b/charts/kube-state-metrics/Chart.yaml index bc94bd519956..5e4891952771 100644 --- a/charts/kube-state-metrics/Chart.yaml +++ b/charts/kube-state-metrics/Chart.yaml @@ -7,7 +7,7 @@ keywords: - prometheus - kubernetes type: application -version: 5.28.0 +version: 5.28.1 appVersion: 2.14.0 home: https://github.com/kubernetes/kube-state-metrics/ sources: diff --git a/charts/kube-state-metrics/templates/deployment.yaml b/charts/kube-state-metrics/templates/deployment.yaml index bc93d42b714e..e2b18186fd8d 100644 --- a/charts/kube-state-metrics/templates/deployment.yaml +++ b/charts/kube-state-metrics/templates/deployment.yaml @@ -307,7 +307,11 @@ spec: {{- end }} {{- if .Values.affinity }} affinity: -{{ toYaml .Values.affinity | indent 8 }} + {{- if kindIs "map" .Values.affinity }} + {{- toYaml .Values.affinity | nindent 8 }} + {{- else }} + {{- tpl .Values.affinity $ | nindent 8 }} + {{- end }} {{- end }} {{- with .Values.nodeSelector }} nodeSelector: diff --git a/charts/kube-state-metrics/values.yaml b/charts/kube-state-metrics/values.yaml index 948eb587269a..01f7bfb49ef2 100644 --- a/charts/kube-state-metrics/values.yaml +++ b/charts/kube-state-metrics/values.yaml @@ -304,8 +304,16 @@ containerSecurityContext: nodeSelector: {} ## Affinity settings for pod assignment +## Can be defined as either a dict or string. String is useful for `tpl` templating. ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ affinity: {} +# affinity: | +# podAntiAffinity: +# requiredDuringSchedulingIgnoredDuringExecution: +# - labelSelector: +# matchLabels: +# {{- include "kube-state-metrics.selectorLabels" . | indent 10 }} +# topologyKey: kubernetes.io/hostname ## Tolerations for pod assignment ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/