Skip to content

Commit d2b4d36

Browse files
committed
Use CronJob batch/v1 resource version if available
The batch/v2alpha1 CronJob type definitions and clients are deprecated and removed in Kubernetes v1.21 Signed-off-by: Konstantin Misyutin <[email protected]>
1 parent 755ebc3 commit d2b4d36

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

deploy/helm/kubernetes/templates/_helpers.tpl

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
2323
{{- end -}}
2424
{{- end -}}
2525

26+
{{/*
27+
Generate compatible "CronJob" resource API version.
28+
*/}}
29+
{{- define "apiVersion.CronJob" -}}
30+
{{- if .Capabilities.APIVersions.Has "batch/v1/CronJob" -}}batch/v1{{- else -}}batch/v1beta1{{- end -}}
31+
{{- end -}}
32+
2633
{{/*
2734
Create a default certificate name.
2835
*/}}

deploy/helm/kubernetes/templates/etcd-backup-cronjob.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{- if .Values.etcd.backup.enabled }}
22
{{- $fullName := include "kubernetes.fullname" . -}}
33
---
4-
apiVersion: batch/v1beta1
4+
apiVersion: {{ include "apiVersion.CronJob" . }}
55
kind: CronJob
66
metadata:
77
name: {{ $fullName }}-etcd-backup

deploy/helm/kubernetes/templates/kubeadm-cronjob.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{- if .Values.admin.job.enabled }}
22
{{- $fullName := include "kubernetes.fullname" . -}}
33
---
4-
apiVersion: batch/v1beta1
4+
apiVersion: {{ include "apiVersion.CronJob" . }}
55
kind: CronJob
66
metadata:
77
name: "{{ $fullName }}-kubeadm-tasks"

0 commit comments

Comments
 (0)