From a1dda073370830787a2a39f74ecbacf4738bdba5 Mon Sep 17 00:00:00 2001 From: Rafael da Fonseca Date: Fri, 7 Feb 2025 16:28:03 +0000 Subject: [PATCH] feat: Add PodDisruptionBudget to helm chart (#246) * feat: Add PodDisruptionBudget to helm chart Signed-off-by: Rafael da Fonseca * Specify namespace in pdb Signed-off-by: Rafael da Fonseca * Fix outdated/removed python version (#245) * Fix outdated/removed python version Signed-off-by: Rafael da Fonseca * Fix outdated/removed python version Signed-off-by: Rafael da Fonseca --------- Signed-off-by: Rafael da Fonseca * fix: codegen Signed-off-by: Vishal Choudhary Signed-off-by: Rafael da Fonseca --------- Signed-off-by: Rafael da Fonseca Signed-off-by: Vishal Choudhary Co-authored-by: Vishal Choudhary --- charts/reports-server/README.md | 4 ++++ .../templates/pod-disruption-budget.yaml | 16 ++++++++++++++++ charts/reports-server/values.yaml | 10 ++++++++++ config/install-etcd.yaml | 11 +++++++++++ config/install.yaml | 11 +++++++++++ 5 files changed, 52 insertions(+) create mode 100644 charts/reports-server/templates/pod-disruption-budget.yaml diff --git a/charts/reports-server/README.md b/charts/reports-server/README.md index 9b625a2e..91cbd3fe 100644 --- a/charts/reports-server/README.md +++ b/charts/reports-server/README.md @@ -56,6 +56,10 @@ helm install reports-server --namespace reports-server --create-namespace report | autoscaling.maxReplicas | int | `100` | Max number of replicas | | autoscaling.targetCPUUtilizationPercentage | int | `80` | Target CPU utilisation | | autoscaling.targetMemoryUtilizationPercentage | string | `nil` | Target Memory utilisation | +| pdb | object | `{"enabled":true,"maxUnavailable":"50%","minAvailable":null}` | Using a PDB is highly recommended for highly available deployments. Defaults to enabled. The default configuration doesn't prevent disruption when using a single replica | +| pdb.enabled | bool | `true` | Enable PodDisruptionBudget | +| pdb.minAvailable | string | `nil` | minAvailable pods for PDB, cannot be used together with maxUnavailable | +| pdb.maxUnavailable | string | `"50%"` | maxUnavailable pods for PDB, will take precedence over minAvailable if both are defined | | nodeSelector | object | `{}` | Node selector | | tolerations | list | `[]` | Tolerations | | affinity | object | `{}` | Affinity | diff --git a/charts/reports-server/templates/pod-disruption-budget.yaml b/charts/reports-server/templates/pod-disruption-budget.yaml new file mode 100644 index 00000000..df35a9e5 --- /dev/null +++ b/charts/reports-server/templates/pod-disruption-budget.yaml @@ -0,0 +1,16 @@ +{{- if eq .Values.pdb.enabled true }} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ include "reports-server.fullname" . }} + namespace: {{ $.Release.Namespace }} +spec: + selector: + matchLabels: + app.kubernetes.io/name: {{ include "reports-server.name" . }} + {{- if .Values.pdb.maxUnavailable }} + maxUnavailable: {{ .Values.pdb.maxUnavailable }} + {{- else if .Values.pdb.minAvailable }} + minAvailable: {{ .Values.pdb.minAvailable }} + {{- end }} +{{- end }} diff --git a/charts/reports-server/values.yaml b/charts/reports-server/values.yaml index a2a0292c..8d176762 100644 --- a/charts/reports-server/values.yaml +++ b/charts/reports-server/values.yaml @@ -144,6 +144,16 @@ autoscaling: # -- Target Memory utilisation targetMemoryUtilizationPercentage: ~ + +# -- Using a PDB is highly recommended for highly available deployments. Defaults to enabled. The default configuration doesn't prevent disruption when using a single replica +pdb: + # -- Enable PodDisruptionBudget + enabled: true + # -- minAvailable pods for PDB, cannot be used together with maxUnavailable + minAvailable: ~ + # -- maxUnavailable pods for PDB, will take precedence over minAvailable if both are defined + maxUnavailable: 50% + # -- Node selector nodeSelector: {} diff --git a/config/install-etcd.yaml b/config/install-etcd.yaml index f29df750..3eedd059 100644 --- a/config/install-etcd.yaml +++ b/config/install-etcd.yaml @@ -4,6 +4,17 @@ kind: Namespace metadata: name: reports-server --- +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: reports-server + namespace: reports-server +spec: + selector: + matchLabels: + app.kubernetes.io/name: reports-server + maxUnavailable: 50% +--- apiVersion: v1 kind: ServiceAccount metadata: diff --git a/config/install.yaml b/config/install.yaml index 309005a4..95e45580 100644 --- a/config/install.yaml +++ b/config/install.yaml @@ -4,6 +4,17 @@ kind: Namespace metadata: name: reports-server --- +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: reports-server + namespace: reports-server +spec: + selector: + matchLabels: + app.kubernetes.io/name: reports-server + maxUnavailable: 50% +--- apiVersion: v1 kind: ServiceAccount metadata: