From 8849085f5906de58a87ba7bee7772ce6112d91b2 Mon Sep 17 00:00:00 2001 From: i502474 Date: Mon, 20 Nov 2023 16:20:53 +0100 Subject: [PATCH] Add pdb to fluentd helm chart Signed-off-by: i502474 --- charts/fluentd/templates/_helpers.tpl | 12 ++++++++++++ charts/fluentd/templates/pdb.yaml | 21 +++++++++++++++++++++ charts/fluentd/values.yaml | 7 +++++++ 3 files changed, 40 insertions(+) create mode 100644 charts/fluentd/templates/pdb.yaml diff --git a/charts/fluentd/templates/_helpers.tpl b/charts/fluentd/templates/_helpers.tpl index 72e878df..d02e7658 100644 --- a/charts/fluentd/templates/_helpers.tpl +++ b/charts/fluentd/templates/_helpers.tpl @@ -90,3 +90,15 @@ Name of the configMap used for additional configuration files; allows users to o {{ printf "%s-%s" "fluentd-config" ( include "fluentd.shortReleaseName" . ) }} {{- end -}} {{- end -}} + + +{{/* +Pdb apiVersion according k8s version and capabilities +*/}} +{{- define "fluentd.pdb.apiVersion" -}} +{{- if and (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">=1.21-0" .Capabilities.KubeVersion.GitVersion) -}} +policy/v1 +{{- else -}} +policy/v1beta1 +{{- end }} +{{- end -}} diff --git a/charts/fluentd/templates/pdb.yaml b/charts/fluentd/templates/pdb.yaml new file mode 100644 index 00000000..14e4b44c --- /dev/null +++ b/charts/fluentd/templates/pdb.yaml @@ -0,0 +1,21 @@ +{{- if and (or ( eq .Values.kind "Deployment" ) ( eq .Values.kind "StatefulSet" )) .Values.podDisruptionBudget.enabled }} +apiVersion: {{ include "fluentd.pdb.apiVersion" . }} +kind: PodDisruptionBudget +metadata: + name: {{ include "fluentd.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "fluentd.labels" . | nindent 4 }} +{{- with .Values.podDisruptionBudget.annotations }} + annotations: + {{- toYaml . | nindent 4 }} +{{- end }} +spec: + maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }} + selector: + matchLabels: + {{- include "fluentd.selectorLabels" . | nindent 6 }} + {{- with .Values.labels }} + {{- toYaml . | nindent 6 }} + {{- end }} +{{- end }} diff --git a/charts/fluentd/values.yaml b/charts/fluentd/values.yaml index 59a66531..7408b776 100644 --- a/charts/fluentd/values.yaml +++ b/charts/fluentd/values.yaml @@ -391,3 +391,10 @@ ingress: # - secretName: fluentd-tls # hosts: # - fluentd.example.tld + + +## only available if kind is Deployment or StatefulSet +podDisruptionBudget: + enabled: false + annotations: {} + maxUnavailable: "30%"