From 355cdbeb86faf71d30066c036f75652c3e926b69 Mon Sep 17 00:00:00 2001 From: Jason Witkowski Date: Wed, 15 Feb 2023 00:54:01 -0500 Subject: [PATCH] helm: Fix PDB apiVersion to allow K8s 1.25+ deployment (#13783) --- helm/druid/Chart.yaml | 2 +- helm/druid/templates/_capabilities.tpl | 17 +++++++++++++++++ helm/druid/templates/historical/pdb.yaml | 2 +- helm/druid/templates/middleManager/pdb.yaml | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 helm/druid/templates/_capabilities.tpl diff --git a/helm/druid/Chart.yaml b/helm/druid/Chart.yaml index 8bbc003de34..cc4083be290 100644 --- a/helm/druid/Chart.yaml +++ b/helm/druid/Chart.yaml @@ -30,7 +30,7 @@ dependencies: version: 8.6.4 repository: https://charts.helm.sh/stable condition: postgresql.enabled -version: 0.3.3 +version: 0.3.4 home: https://druid.apache.org/ icon: https://druid.apache.org/img/favicon.png sources: diff --git a/helm/druid/templates/_capabilities.tpl b/helm/druid/templates/_capabilities.tpl new file mode 100644 index 00000000000..f0a0c861556 --- /dev/null +++ b/helm/druid/templates/_capabilities.tpl @@ -0,0 +1,17 @@ +{{/* +Return the target Kubernetes version +*/}} +{{- define "capabilities.kubeVersion" -}} +{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}} +{{- end -}} + +{{/* +Return the appropriate apiVersion for poddisruptionbudget. +*/}} +{{- define "capabilities.policy.apiVersion" -}} +{{- if semverCompare "<1.21-0" (include "capabilities.kubeVersion" .) -}} +{{- print "policy/v1beta1" -}} +{{- else -}} +{{- print "policy/v1" -}} +{{- end -}} +{{- end -}} diff --git a/helm/druid/templates/historical/pdb.yaml b/helm/druid/templates/historical/pdb.yaml index 13b000034c7..c921b1909da 100644 --- a/helm/druid/templates/historical/pdb.yaml +++ b/helm/druid/templates/historical/pdb.yaml @@ -18,7 +18,7 @@ */}} {{- if .Values.historical.podDisruptionBudget.enabled }} -apiVersion: policy/v1beta1 +apiVersion: {{ include "capabilities.policy.apiVersion" . }} kind: PodDisruptionBudget metadata: labels: diff --git a/helm/druid/templates/middleManager/pdb.yaml b/helm/druid/templates/middleManager/pdb.yaml index 5e3bccf1aa7..71a592979a7 100644 --- a/helm/druid/templates/middleManager/pdb.yaml +++ b/helm/druid/templates/middleManager/pdb.yaml @@ -18,7 +18,7 @@ */}} {{- if .Values.middleManager.podDisruptionBudget.enabled }} -apiVersion: policy/v1beta1 +apiVersion: {{ include "capabilities.policy.apiVersion" . }} kind: PodDisruptionBudget metadata: labels: