Skip to content

Commit

Permalink
fix(cronjob) Update CronJobs to use stable api in k8s 1.21 (#105)
Browse files Browse the repository at this point in the history
* Update CronJobs to use stable api in k8s 1.21

* Bumps chart version
  • Loading branch information
pedro93 authored Apr 1, 2022
1 parent ee62486 commit 558de6b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion charts/datahub/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A Helm chart for LinkedIn DataHub
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 0.2.65
version: 0.2.66
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 0.8.32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,14 @@ Create the name of the service account to use
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for cronjob.
*/}}
{{- define "datahub-ingestion-cron.cronjob.apiVersion" -}}
{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.Version -}}
{{- print "batch/v1" -}}
{{- else -}}
{{- print "batch/v1beta1" -}}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{- $labels := include "datahub-ingestion-cron.labels" .}}
{{- range $jobName, $val := .Values.crons }}
{{- $defaultCommand := printf "datahub ingest -c /etc/recipe/%s" $val.recipe.fileName }}
apiVersion: batch/v1beta1
apiVersion: {{ template "datahub-ingestion-cron.cronjob.apiVersion" . }}
kind: CronJob
metadata:
name: "{{ $baseName }}-{{ $jobName }}"
Expand Down
11 changes: 11 additions & 0 deletions charts/datahub/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,14 @@ Create the name of the service account to use
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for cronjob.
*/}}
{{- define "datahub-ingestion-cron.cronjob.apiVersion" -}}
{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.Version -}}
{{- print "batch/v1" -}}
{{- else -}}
{{- print "batch/v1beta1" -}}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Creates a suspended cronJob that you can use to create an adhoc job when ready to run clean up.
# Run the following command to do so
# kubectl create job --from=cronjob/<<release-name>>-datahub-cleanup-job-template datahub-cleanup-job
apiVersion: batch/v1beta1
apiVersion: {{ template "datahub-ingestion-cron.cronjob.apiVersion" . }}
kind: CronJob
metadata:
name: {{ .Release.Name }}-datahub-cleanup-job-template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Creates a suspended cronJob that you can use to create an adhoc job when ready to run clean up.
# Run the following command to do so
# kubectl create job --from=cronjob/<<release-name>>-datahub-restore-indices-job-template datahub-restore-indices-job
apiVersion: batch/v1beta1
apiVersion: {{ template "datahub-ingestion-cron.cronjob.apiVersion" . }}
kind: CronJob
metadata:
name: {{ .Release.Name }}-datahub-restore-indices-job-template
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.datahubUpgrade.enabled -}}
apiVersion: batch/v1
apiVersion: {{ template "datahub-ingestion-cron.cronjob.apiVersion" . }}
kind: Job
metadata:
name: {{ .Release.Name }}-datahub-upgrade-job
Expand Down

0 comments on commit 558de6b

Please sign in to comment.