From 6a0bbda8a583f53f003a0ed3df60809d0a27bec3 Mon Sep 17 00:00:00 2001 From: Nathanael Liechti Date: Tue, 19 Dec 2023 17:17:41 +0000 Subject: [PATCH] feat(helm): add topologySpreadConstraints and PDB --- charts/podinfo/templates/deployment.yaml | 4 ++++ charts/podinfo/templates/pdb.yaml | 14 ++++++++++++++ charts/podinfo/values.yaml | 7 +++++++ 3 files changed, 25 insertions(+) create mode 100644 charts/podinfo/templates/pdb.yaml diff --git a/charts/podinfo/templates/deployment.yaml b/charts/podinfo/templates/deployment.yaml index 87ed3735..aa2f7fb0 100644 --- a/charts/podinfo/templates/deployment.yaml +++ b/charts/podinfo/templates/deployment.yaml @@ -203,3 +203,7 @@ spec: secret: secretName: {{ template "podinfo.tlsSecretName" . }} {{- end }} + {{- with .Values.topologySpreadConstraints }} + topologySpreadConstraints: +{{- toYaml . | nindent 8 }} + {{- end }} \ No newline at end of file diff --git a/charts/podinfo/templates/pdb.yaml b/charts/podinfo/templates/pdb.yaml new file mode 100644 index 00000000..9057132f --- /dev/null +++ b/charts/podinfo/templates/pdb.yaml @@ -0,0 +1,14 @@ +{{- if and .Values.podDisruptionBudget (gt (int .Values.replicaCount) 1) }} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ include "podinfo.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "podinfo.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "podinfo.selectorLabels" . | nindent 6 }} + {{- toYaml .Values.podDisruptionBudget | nindent 2 }} +{{- end }} diff --git a/charts/podinfo/values.yaml b/charts/podinfo/values.yaml index 98ddbbb3..fddbf735 100644 --- a/charts/podinfo/values.yaml +++ b/charts/podinfo/values.yaml @@ -142,6 +142,13 @@ affinity: {} podAnnotations: {} +# https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/ +topologySpreadConstraints: [] + +# Disruption budget will be configured only when the replicaCount is greater than 1 +podDisruptionBudget: {} +# maxUnavailable: 1 + # https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes probes: readiness: