From 839f46fd48608fa0500096234f62f2a117d5e398 Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Sat, 13 Aug 2022 16:52:12 +0200 Subject: [PATCH] Add Pod Disruption Budget for Stateful Set --- README.md | 3 +++ templates/pod-disruption-budget.yaml | 25 +++++++++++++++++++++++++ values.yaml | 7 +++++++ 3 files changed, 35 insertions(+) create mode 100644 templates/pod-disruption-budget.yaml diff --git a/README.md b/README.md index 2b73047..bd368b2 100755 --- a/README.md +++ b/README.md @@ -122,6 +122,9 @@ Parameters related to Kubernetes. | `podAnnotations` | Enable the multi-master replication | `true` | | `podAffinityPreset` | podAffinityPreset Pod affinity preset. Ignored if `affinity` is set. Allowed values: `soft` or `hard`| `` | | `podAntiAffinityPreset` | podAntiAffinityPreset Pod anti-affinity preset. Ignored if `affinity` is set. Allowed values: `soft` or `hard` | `soft` | +| `pdb.enabled` | Enable Pod Disruption Budget | `false` | +| `pdb.minAvailable` | Configure PDB to have at least this many health replicas. | `1` | +| `pdb.maxUnavailable` | Configure PDB to have at most this many unhealth replicas. | `` | | `nodeAffinityPreset` | nodeAffinityPreset.type Node affinity preset type. Ignored if `affinity` is set. Allowed values: `soft` or `hard` | `true` | | `affinity` | affinity Affinity for OPENLDAP pods assignment | `` | | `nodeSelector` | nodeSelector Node labels for OPENLDAP pods assignment | `` | diff --git a/templates/pod-disruption-budget.yaml b/templates/pod-disruption-budget.yaml new file mode 100644 index 0000000..9b12151 --- /dev/null +++ b/templates/pod-disruption-budget.yaml @@ -0,0 +1,25 @@ +{{- if .Values.pdb.enabled }} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ template "openldap.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/component: {{ template "openldap.fullname" . }} + chart: {{ template "openldap.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if .Values.extraLabels }} +{{ toYaml .Values.extraLabels | indent 4 }} +{{- end }} +spec: + {{- if .Values.pdb.maxUnavailable }} + maxUnavailable: {{ .Values.pdb.maxUnavailable }} + {{- end }} + {{- if .Values.pdb.minAvailable }} + minAvailable: {{ .Values.pdb.minAvailable }} + {{- end }} + selector: + app.kubernetes.io/component: {{ template "openldap.fullname" . }} + release: {{ .Release.Name }} +{{- end }} diff --git a/values.yaml b/values.yaml index c18df21..1755c19 100644 --- a/values.yaml +++ b/values.yaml @@ -115,6 +115,13 @@ env: LDAP_TLS_PROTOCOL_MIN: "3.0" LDAP_TLS_CIPHER_SUITE: "NORMAL" +# Pod Disruption Budget for Stateful Set +# Disabled by default, to ensure backwards compatibility +pdb: + enabled: false + minAvailable: 1 + maxUnavailable: "" + # Custom openldap configuration files used to override default settings # customLdifFiles: # 01-default-users.ldif: |-