From 5a12ae9cc9d8d199310aea837dec65ae8c0909f6 Mon Sep 17 00:00:00 2001
From: dnskr <dnskrv88@gmail.com>
Date: Sun, 11 Jun 2023 19:48:53 +0200
Subject: [PATCH] Cleanup Kubernetes < 1.23 support

---
 chart/templates/_helpers.yaml                          | 10 ----------
 chart/templates/cleanup/cleanup-cronjob.yaml           |  4 ----
 .../pgbouncer/pgbouncer-poddisruptionbudget.yaml       |  4 ----
 .../scheduler/scheduler-poddisruptionbudget.yaml       |  4 ----
 .../webserver/webserver-poddisruptionbudget.yaml       |  4 ----
 chart/values.schema.json                               |  6 ------
 chart/values.yaml                                      |  3 ---
 7 files changed, 35 deletions(-)

diff --git a/chart/templates/_helpers.yaml b/chart/templates/_helpers.yaml
index 10d90c091fd40..c34f99d791a23 100644
--- a/chart/templates/_helpers.yaml
+++ b/chart/templates/_helpers.yaml
@@ -720,16 +720,6 @@ server_tls_key_file = /etc/pgbouncer/server.key
   {{ $config | toJson | print }}
 {{- end }}
 
-{{/* Allow Kubernetes Version to be overridden. Credit to https://github.com/prometheus-community/helm-charts for Regex. */}}
-{{- define "kubeVersion" }}
-  {{- $kubeVersion := default .Capabilities.KubeVersion.Version .Values.kubeVersionOverride -}}
-  {{/* Special use case for Amazon EKS, Google GKE */}}
-  {{- if and (regexMatch "\\d+\\.\\d+\\.\\d+-(?:eks|gke).+" $kubeVersion) (not .Values.kubeVersionOverride) -}}
-    {{- $kubeVersion = regexFind "\\d+\\.\\d+\\.\\d+" $kubeVersion -}}
-  {{- end -}}
-  {{- $kubeVersion -}}
-{{- end }}
-
 {{/*
 Set the default value for pod securityContext
 If no value is passed for securityContexts.pod or <node>.securityContexts.pod or legacy securityContext and <node>.securityContext, defaults to global uid and gid.
diff --git a/chart/templates/cleanup/cleanup-cronjob.yaml b/chart/templates/cleanup/cleanup-cronjob.yaml
index 880f9e9589914..fb81dc8754785 100644
--- a/chart/templates/cleanup/cleanup-cronjob.yaml
+++ b/chart/templates/cleanup/cleanup-cronjob.yaml
@@ -26,11 +26,7 @@
 {{- $tolerations := or .Values.cleanup.tolerations .Values.tolerations }}
 {{- $topologySpreadConstraints := or .Values.cleanup.topologySpreadConstraints .Values.topologySpreadConstraints }}
 {{- $securityContext := include "airflowPodSecurityContext" (list . .Values.cleanup) }}
-{{- if semverCompare ">= 1.21.x" (include "kubeVersion" .) }}
 apiVersion: batch/v1
-{{- else }}
-apiVersion: batch/v1beta1
-{{- end }}
 kind: CronJob
 metadata:
   name: {{ .Release.Name }}-cleanup
diff --git a/chart/templates/pgbouncer/pgbouncer-poddisruptionbudget.yaml b/chart/templates/pgbouncer/pgbouncer-poddisruptionbudget.yaml
index 3b72a26eca5ab..16f9cf38a5157 100644
--- a/chart/templates/pgbouncer/pgbouncer-poddisruptionbudget.yaml
+++ b/chart/templates/pgbouncer/pgbouncer-poddisruptionbudget.yaml
@@ -22,11 +22,7 @@
 #################################
 {{- if and .Values.pgbouncer.enabled .Values.pgbouncer.podDisruptionBudget.enabled }}
 kind: PodDisruptionBudget
-{{- if semverCompare ">= 1.21.x" (include "kubeVersion" .) }}
 apiVersion: policy/v1
-{{- else }}
-apiVersion: policy/v1beta1
-{{- end }}
 metadata:
   name: {{ .Release.Name }}-pgbouncer-pdb
   labels:
diff --git a/chart/templates/scheduler/scheduler-poddisruptionbudget.yaml b/chart/templates/scheduler/scheduler-poddisruptionbudget.yaml
index 8c97bd029e3db..613b20bde3347 100644
--- a/chart/templates/scheduler/scheduler-poddisruptionbudget.yaml
+++ b/chart/templates/scheduler/scheduler-poddisruptionbudget.yaml
@@ -22,11 +22,7 @@
 #################################
 {{- if .Values.scheduler.podDisruptionBudget.enabled }}
 kind: PodDisruptionBudget
-{{- if semverCompare ">= 1.21.x" (include "kubeVersion" .) }}
 apiVersion: policy/v1
-{{- else }}
-apiVersion: policy/v1beta1
-{{- end }}
 metadata:
   name: {{ .Release.Name }}-scheduler-pdb
   labels:
diff --git a/chart/templates/webserver/webserver-poddisruptionbudget.yaml b/chart/templates/webserver/webserver-poddisruptionbudget.yaml
index 2c53f50be8dad..7b390c7590a1d 100644
--- a/chart/templates/webserver/webserver-poddisruptionbudget.yaml
+++ b/chart/templates/webserver/webserver-poddisruptionbudget.yaml
@@ -22,11 +22,7 @@
 #################################
 {{- if .Values.webserver.podDisruptionBudget.enabled }}
 kind: PodDisruptionBudget
-{{- if semverCompare ">= 1.21.x" (include "kubeVersion" .) }}
 apiVersion: policy/v1
-{{- else }}
-apiVersion: policy/v1beta1
-{{- end }}
 metadata:
   name: {{ .Release.Name }}-webserver-pdb
   labels:
diff --git a/chart/values.schema.json b/chart/values.schema.json
index 5897f34639061..b2d067441dff3 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -44,12 +44,6 @@
             "default": "",
             "x-docsSection": null
         },
-        "kubeVersionOverride": {
-            "description": "Provide a Kubernetes version (used for API Version selection) to override the auto-detected version",
-            "type": "string",
-            "default": "",
-            "x-docsSection": null
-        },
         "uid": {
             "description": "User of airflow user.",
             "type": "integer",
diff --git a/chart/values.yaml b/chart/values.yaml
index b574175c6486b..b791efae76456 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -25,9 +25,6 @@ fullnameOverride: ""
 # Provide a name to substitute for the name of the chart
 nameOverride: ""
 
-# Provide a Kubernetes version (used for API Version selection) to override the auto-detected version
-kubeVersionOverride: ""
-
 # Max number of old replicasets to retain. Can be overridden by each deployment's revisionHistoryLimit
 revisionHistoryLimit: ~
 
