Skip to content

Commit

Permalink
Use CronJob batch/v1 resource version if available
Browse files Browse the repository at this point in the history
The batch/v2alpha1 CronJob type definitions and clients are
deprecated and removed in Kubernetes v1.21

Signed-off-by: Konstantin Misyutin <[email protected]>
  • Loading branch information
ikeeip committed Dec 2, 2021
1 parent 755ebc3 commit d2b4d36
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions deploy/helm/kubernetes/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- end -}}
{{- end -}}

{{/*
Generate compatible "CronJob" resource API version.
*/}}
{{- define "apiVersion.CronJob" -}}
{{- if .Capabilities.APIVersions.Has "batch/v1/CronJob" -}}batch/v1{{- else -}}batch/v1beta1{{- end -}}
{{- end -}}

{{/*
Create a default certificate name.
*/}}
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/kubernetes/templates/etcd-backup-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{- if .Values.etcd.backup.enabled }}
{{- $fullName := include "kubernetes.fullname" . -}}
---
apiVersion: batch/v1beta1
apiVersion: {{ include "apiVersion.CronJob" . }}
kind: CronJob
metadata:
name: {{ $fullName }}-etcd-backup
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/kubernetes/templates/kubeadm-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{- if .Values.admin.job.enabled }}
{{- $fullName := include "kubernetes.fullname" . -}}
---
apiVersion: batch/v1beta1
apiVersion: {{ include "apiVersion.CronJob" . }}
kind: CronJob
metadata:
name: "{{ $fullName }}-kubeadm-tasks"
Expand Down

0 comments on commit d2b4d36

Please sign in to comment.