From 58848cf5462abad60086fbc846d8ad47412b19a2 Mon Sep 17 00:00:00 2001 From: Punit Kulal Date: Tue, 30 Jul 2024 17:08:29 +0530 Subject: [PATCH 1/5] feat: add support for Pod disruption budget --- stable/app/templates/pdb.yaml | 16 ++++++++++++++++ stable/app/values.yaml | 5 +++++ 2 files changed, 21 insertions(+) create mode 100644 stable/app/templates/pdb.yaml diff --git a/stable/app/templates/pdb.yaml b/stable/app/templates/pdb.yaml new file mode 100644 index 00000000..0ad3b87e --- /dev/null +++ b/stable/app/templates/pdb.yaml @@ -0,0 +1,16 @@ +{{- if .Values.pdb.enabled -}} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ include "app.fullname" . }}-pdb + labels: + {{- include "app.labels" . | nindent 4 }} +spec: + {{- if .Values.pdb.maxUnavailable }} + maxUnavailable: {{ .Values.pdb.maxUnavailable }} + {{- end }} + minAvailable: {{ .Values.pdb.minAvailable | default 0 }} + selector: + matchLabels: + {{- include "app.selectorLabels" . | nindent 6 }} +{{- end }} \ No newline at end of file diff --git a/stable/app/values.yaml b/stable/app/values.yaml index c9da4635..91fef64e 100644 --- a/stable/app/values.yaml +++ b/stable/app/values.yaml @@ -165,3 +165,8 @@ autoscaling: maxReplicas: 2 targetMemory: 80 targetCPU: 80 + +pdb: + enabled: false + # minAvailable: 0 + # maxUnavailable: 1 From 9669d58b15a8c9e341f95db0589271718947e0a0 Mon Sep 17 00:00:00 2001 From: Punit Kulal Date: Tue, 30 Jul 2024 17:15:00 +0530 Subject: [PATCH 2/5] updated readme and chart version --- stable/app/Chart.yaml | 2 +- stable/app/README.md | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/stable/app/Chart.yaml b/stable/app/Chart.yaml index 55c14cd1..9d2d091a 100644 --- a/stable/app/Chart.yaml +++ b/stable/app/Chart.yaml @@ -15,4 +15,4 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.5.4 +version: 0.5.5 diff --git a/stable/app/README.md b/stable/app/README.md index aa74a443..1f63cf70 100644 --- a/stable/app/README.md +++ b/stable/app/README.md @@ -91,6 +91,9 @@ The following table lists the configurable parameters of the Siren chart and the | telegraf.containerPort | int | `8125` | | | telegraf.protocol | string | `UDP` | | | telegraf.config | string | `""` | telegraf config file content | +| pdb.enabled | bool | `false` | Whether to enable pod disruption budget on the release | +| pdb.minAvailable | int | `0` | minimum number of pods that should be available according to PDB | +| pdb.maxUnavailable | int | `` | maximum number of pods that can be unavailable according to PDB | --- From 566b8ccc4e587407e9c8d2c1e3767320ed7c87e8 Mon Sep 17 00:00:00 2001 From: Punit Kulal Date: Wed, 31 Jul 2024 10:17:17 +0530 Subject: [PATCH 3/5] bump chart to 0.6.0 --- stable/app/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stable/app/Chart.yaml b/stable/app/Chart.yaml index 9d2d091a..b393e80a 100644 --- a/stable/app/Chart.yaml +++ b/stable/app/Chart.yaml @@ -15,4 +15,4 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.5.5 +version: 0.6.0 From 4af085d916020b2f6750b81d1e08cd1fd8ed28ef Mon Sep 17 00:00:00 2001 From: Punit Kulal Date: Wed, 31 Jul 2024 10:54:11 +0530 Subject: [PATCH 4/5] feat: ensure both conditions are not set for pdb --- stable/app/templates/pdb.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stable/app/templates/pdb.yaml b/stable/app/templates/pdb.yaml index 0ad3b87e..0f168ad3 100644 --- a/stable/app/templates/pdb.yaml +++ b/stable/app/templates/pdb.yaml @@ -9,7 +9,9 @@ spec: {{- if .Values.pdb.maxUnavailable }} maxUnavailable: {{ .Values.pdb.maxUnavailable }} {{- end }} + {{- if not .Values.pdb.maxUnavailable }} minAvailable: {{ .Values.pdb.minAvailable | default 0 }} + {{- end }} selector: matchLabels: {{- include "app.selectorLabels" . | nindent 6 }} From c4184524bb93f4ba5b026abd20afb90a78362c47 Mon Sep 17 00:00:00 2001 From: Punit Kulal Date: Wed, 31 Jul 2024 11:20:23 +0530 Subject: [PATCH 5/5] feat: updated selector labels for deployment to make pdb compatible --- stable/app/templates/cron.yaml | 1 + stable/app/templates/deployment.yaml | 2 ++ stable/app/templates/migration-job.yaml | 3 ++- stable/app/templates/pdb.yaml | 1 + stable/app/templates/service.yaml | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/stable/app/templates/cron.yaml b/stable/app/templates/cron.yaml index 528f76d3..4a14c872 100644 --- a/stable/app/templates/cron.yaml +++ b/stable/app/templates/cron.yaml @@ -18,6 +18,7 @@ spec: template: metadata: labels: + app.kubernetes.io/type: cronjob {{- $appSelectorLabels | nindent 12 }} spec: containers: diff --git a/stable/app/templates/deployment.yaml b/stable/app/templates/deployment.yaml index 24bff9ce..c1c669c4 100644 --- a/stable/app/templates/deployment.yaml +++ b/stable/app/templates/deployment.yaml @@ -9,6 +9,7 @@ spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: + app.kubernetes.io/type: deployment {{- include "app.selectorLabels" . | nindent 6 }} template: metadata: @@ -21,6 +22,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: + app.kubernetes.io/type: deployment {{- include "app.selectorLabels" . | nindent 8 }} spec: {{- with .Values.imagePullSecrets }} diff --git a/stable/app/templates/migration-job.yaml b/stable/app/templates/migration-job.yaml index 2777e9cd..13b98a4a 100644 --- a/stable/app/templates/migration-job.yaml +++ b/stable/app/templates/migration-job.yaml @@ -18,7 +18,8 @@ spec: template: metadata: labels: - {{- include "app.selectorLabels" . | nindent 8 }} + app.kubernetes.io/type: job + {{- include "app.selectorLabels" . | nindent 8 }} spec: restartPolicy: Never containers: diff --git a/stable/app/templates/pdb.yaml b/stable/app/templates/pdb.yaml index 0f168ad3..8e54d020 100644 --- a/stable/app/templates/pdb.yaml +++ b/stable/app/templates/pdb.yaml @@ -14,5 +14,6 @@ spec: {{- end }} selector: matchLabels: + app.kubernetes.io/type: deployment {{- include "app.selectorLabels" . | nindent 6 }} {{- end }} \ No newline at end of file diff --git a/stable/app/templates/service.yaml b/stable/app/templates/service.yaml index 23853ee7..fc8e736f 100644 --- a/stable/app/templates/service.yaml +++ b/stable/app/templates/service.yaml @@ -19,4 +19,5 @@ spec: name: {{ $port.name }} {{- end }} selector: + app.kubernetes.io/type: deployment {{- include "app.selectorLabels" . | nindent 4 }}