From f29f5d2fbd96bfb5bf0064585dbee9739a917613 Mon Sep 17 00:00:00 2001 From: camaeel <12999736+camaeel@users.noreply.github.com> Date: Thu, 28 Dec 2023 15:57:23 +0100 Subject: [PATCH] feat: Pod disruption budget Signed-off-by: camaeel <12999736+camaeel@users.noreply.github.com> Update pdb.yaml fix update docs --- deploy/charts/vault-operator/README.md | 2 ++ .../charts/vault-operator/templates/pdb.yaml | 24 +++++++++++++++++++ deploy/charts/vault-operator/values.yaml | 8 +++++++ 3 files changed, 34 insertions(+) create mode 100644 deploy/charts/vault-operator/templates/pdb.yaml diff --git a/deploy/charts/vault-operator/README.md b/deploy/charts/vault-operator/README.md index 53d24dca..2b443fce 100644 --- a/deploy/charts/vault-operator/README.md +++ b/deploy/charts/vault-operator/README.md @@ -17,6 +17,8 @@ The following table lists the configurable parameters of the Helm chart. | Parameter | Type | Default | Description | | --- | ---- | ------- | ----------- | | `replicaCount` | int | `1` | Number of replicas (pods) to launch. | +| `pdb.create` | bool | `true` | Create pod disruption budget if replicaCount > 1. | +| `pdb.minAvailable` | int | `1` | Min available for PDB. | | `image.repository` | string | `"ghcr.io/bank-vaults/vault-operator"` | Name of the image repository to pull the container image from. | | `image.pullPolicy` | string | `"IfNotPresent"` | [Image pull policy](https://kubernetes.io/docs/concepts/containers/images/#updating-images) for updating already existing images on a node. | | `image.tag` | string | `""` | Image tag override for the default value (chart appVersion). | diff --git a/deploy/charts/vault-operator/templates/pdb.yaml b/deploy/charts/vault-operator/templates/pdb.yaml new file mode 100644 index 00000000..2aa09ce7 --- /dev/null +++ b/deploy/charts/vault-operator/templates/pdb.yaml @@ -0,0 +1,24 @@ +{{- if and .Values.pdb.create (gt (int .Values.replicaCount) 1) }} +apiVersion: {{ include "common.capabilities.policy.apiVersion" . }} +kind: PodDisruptionBudget +metadata: + name: {{ include "vault-operator.fullname" . }} + labels: + helm.sh/chart: {{ include "vault-operator.chart" . }} + app.kubernetes.io/name: {{ include "vault-operator.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- with .Values.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.pdb.minAvailable }} + minAvailable: {{ .Values.pdb.minAvailable }} + {{- end }} + {{- if .Values.pdb.maxUnavailable }} + maxUnavailable: {{ .Values.pdb.maxUnavailable }} + {{- end }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "vault-operator.name" . }} +{{- end }} diff --git a/deploy/charts/vault-operator/values.yaml b/deploy/charts/vault-operator/values.yaml index 6a0df6b9..a37ec760 100644 --- a/deploy/charts/vault-operator/values.yaml +++ b/deploy/charts/vault-operator/values.yaml @@ -5,6 +5,14 @@ # -- Number of replicas (pods) to launch. replicaCount: 1 +pdb: + # -- Create pod disruption budget if replicaCount > 1. + create: true + # -- Min available for PDB. + minAvailable: 1 + # -- Max unavailable for PDB. + # maxUnavailable: 1 + image: # -- Name of the image repository to pull the container image from. repository: ghcr.io/bank-vaults/vault-operator