From ab723550d0097305c65b08196b0381dad64a76b2 Mon Sep 17 00:00:00 2001 From: Philipp Belitz Date: Fri, 6 Dec 2024 10:49:32 +0100 Subject: [PATCH] feat: pod disruption budget Added a flag to enable/disable a [pod disruption budget](https://kubernetes.io/docs/tasks/run-application/configure-pdb/), helping Connaisseur to be always available. fixes #1850 --- charts/connaisseur/templates/_helpers.tpl | 7 +++++++ .../templates/pod_disruption_budget.yaml | 21 +++++++++++++++++++ charts/connaisseur/values.yaml | 4 ++++ 3 files changed, 32 insertions(+) create mode 100644 charts/connaisseur/templates/pod_disruption_budget.yaml diff --git a/charts/connaisseur/templates/_helpers.tpl b/charts/connaisseur/templates/_helpers.tpl index 8e83dec69..97f0839ee 100644 --- a/charts/connaisseur/templates/_helpers.tpl +++ b/charts/connaisseur/templates/_helpers.tpl @@ -165,6 +165,13 @@ Create the name of the redis tls secret {{- include "connaisseur.name" . }}-redis-tls {{- end -}} +{{/* +Create the name of the pod disruption budget +*/}} +{{- define "connaisseur.podDisruptionBudget" -}} +{{- include "connaisseur.name" . }}-pod-disruption-budget +{{- end -}} + {{/* Extract Kubernetes Minor Version. */}} diff --git a/charts/connaisseur/templates/pod_disruption_budget.yaml b/charts/connaisseur/templates/pod_disruption_budget.yaml new file mode 100644 index 000000000..e972e41a9 --- /dev/null +++ b/charts/connaisseur/templates/pod_disruption_budget.yaml @@ -0,0 +1,21 @@ +{{ if .Values.kubernetes.podDisruptionBudget -}} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ include "connaisseur.podDisruptionBudget" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "connaisseur.labels" . | nindent 4 }} +spec: + {{- with .Values.kubernetes.podDisruptionBudget }} + {{- if hasKey . "minAvailable" }} + minAvailable: {{ .minAvailable }} + {{- end }} + {{- if hasKey . "maxUnavailable" }} + maxUnavailable: {{ .maxUnavailable }} + {{- end }} + {{- end }} + selector: + matchLabels: + {{- include "connaisseur.selectorLabels" . | nindent 8 }} +{{- end }} diff --git a/charts/connaisseur/values.yaml b/charts/connaisseur/values.yaml index 4c7770f29..ea3f99bc2 100644 --- a/charts/connaisseur/values.yaml +++ b/charts/connaisseur/values.yaml @@ -102,6 +102,10 @@ kubernetes: # (except for pods – see kubernetes.deployment.podLabels for that) additionalLabels: {} + # activate pod disruption budget + # can set `minAvailable` and `maxUnavailable` values + podDisruptionBudget: {} + # ----------------------------------------------------- # changes to connaisseur application logic