From d2b4585ce9d559f8b2fa50d9e66159e5b06990c4 Mon Sep 17 00:00:00 2001 From: Andreas Bauer Date: Thu, 27 Jun 2024 10:43:26 +0200 Subject: [PATCH 1/2] Add pod anti-affinity and topology spread constraints to proxysql deployment. --- charts/proxysql/templates/_helpers.tpl | 1 + charts/proxysql/templates/deployment.yaml | 20 +++++++++++++++++++- charts/proxysql/values.yaml | 9 +++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/charts/proxysql/templates/_helpers.tpl b/charts/proxysql/templates/_helpers.tpl index f1f66dc..ac68f2c 100644 --- a/charts/proxysql/templates/_helpers.tpl +++ b/charts/proxysql/templates/_helpers.tpl @@ -40,6 +40,7 @@ release: {{ .Release.Name }} helm.sh/chart: {{ include "proxysql.chart" . }} app.kubernetes.io/version: {{ .Values.image.tag | default .Chart.AppVersion | quote }} app.kubernetes.io/managed-by: {{ .Release.Service }} +app.kubernetes.io/name: {{ include "proxysql.fullname" . }} {{- end -}} {{/* diff --git a/charts/proxysql/templates/deployment.yaml b/charts/proxysql/templates/deployment.yaml index 264e25c..0812d4d 100644 --- a/charts/proxysql/templates/deployment.yaml +++ b/charts/proxysql/templates/deployment.yaml @@ -165,10 +165,21 @@ spec: nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.affinity }} affinity: + {{- with .Values.affinity }} {{- toYaml . | nindent 8 }} {{- end }} + {{- if .Values.podAntiAffinity.enabled }} + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - {{ include "proxysql.fullname" . }} + topologyKey: kubernetes.io/hostname + {{- end }} {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} @@ -177,6 +188,13 @@ spec: priorityClassName: {{ . }} {{- end }} terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds | int }} + topologySpreadConstraints: + {{- range $constraint := .Values.topologySpreadConstraints }} + - {{- toYaml $constraint | nindent 10 }} + labelSelector: + matchLabels: + {{- include "proxysql.satellite.selectorLabels" $ | nindent 14 }} + {{- end }} volumes: - name: data emptyDir: {} diff --git a/charts/proxysql/values.yaml b/charts/proxysql/values.yaml index dcc5239..55c49f7 100644 --- a/charts/proxysql/values.yaml +++ b/charts/proxysql/values.yaml @@ -107,6 +107,10 @@ tolerations: [] # Will be applied if not specified otherwise. affinity: {} +# Set a pod-to pod anti-affinity rule, to spread proxysql pods evenly across nodes. +podAntiAffinity: + enabled: false + # Common annotations to add to all resources (sub-charts are not considered). # Evaluated as a template commonAnnotations: {} @@ -412,6 +416,11 @@ debug: terminationGracePeriodSeconds: 60 +topologySpreadConstraints: +# - maxSkew: 1 # allows a node or zone to have up to X pods more or less than any other node or zone. +# topologyKey: kubernetes.io/hostname # at least one Pod per Node +# whenUnsatisfiable: DoNotSchedule + # How long shall the pre-stop-Hook wait k8s to deregister the pod from the service, # before checking for open connections? sleep_before_connection_check: 15 From 621f9ad5e9836c4bb2e40469ae9ebacee53c7253 Mon Sep 17 00:00:00 2001 From: Andreas Bauer Date: Thu, 27 Jun 2024 10:54:19 +0200 Subject: [PATCH 2/2] Update ProxySQL chart version from 1.0.0 to 1.1.0 in Chart.yaml --- charts/proxysql/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/proxysql/Chart.yaml b/charts/proxysql/Chart.yaml index e9da9fe..0ba9699 100644 --- a/charts/proxysql/Chart.yaml +++ b/charts/proxysql/Chart.yaml @@ -3,7 +3,7 @@ apiVersion: v1 appVersion: "2.5.5" description: ProxySQL Helm chart for Kubernetes name: proxysql -version: 1.0.0 +version: 1.1.0 home: https://www.proxysql.com/ sources: - https://github.com/dysnix/charts