"plumb" the job "controller"

This commit is contained in:
Stavros kois
2023-01-17 16:14:23 +02:00
parent 0ab3ac7995
commit af32a648f5
3 changed files with 39 additions and 2 deletions

View File

@@ -3,3 +3,10 @@ service:
ports:
main:
port: 65535
# controller:
# type: Job
# cron:
# enabled: true
# schedule: "* * * * *"

View File

@@ -19,8 +19,10 @@
{{- include "ix.v1.common.daemonset" . | nindent 0 -}}
{{- else if eq .Values.controller.type "StatefulSet" -}}
{{- include "ix.v1.common.statefulset" . | nindent 0 -}}
{{- else if eq .Values.controller.type "Job" -}}
{{/* Pass, it will render from the spawner.jobAndCronJob bellow */}}
{{- else -}}
{{- fail (printf "Not a valid controller.type (%s). Valid options are Deployment, DaemonSet, StatefulSet" .Values.controller.type) -}}
{{- fail (printf "Not a valid controller.type (%s). Valid options are Deployment, DaemonSet, StatefulSet, Job" .Values.controller.type) -}}
{{- end -}}
{{- end -}}

View File

@@ -1,5 +1,33 @@
{{- define "ix.v1.common.spawner.jobAndCronJob" -}}
{{- range $jobName, $job := .Values.jobs -}}
{{- $jobs := dict -}}
{{- if eq .Values.controller.type "Job" -}}
{{- $jobValues := dict -}}
{{- $_ := set $jobValues "enabled" true -}}
{{- $_ := set $jobValues "podSpec" dict -}}
{{- if hasKey .Values "cron" -}}
{{- $_ := set $jobValues "cron" .Values.cron -}}
{{- end -}}
{{- $_ := set $jobValues.podSpec "containers" dict -}}
{{- $_ := set $jobValues.podSpec.containers "main" .Values -}}
{{- $_ := set $jobValues.podSpec.containers.main "enabled" "true" -}}
{{- $_ := unset $jobValues.podSpec.containers.main "probes" -}}
{{- $_ := unset $jobValues.podSpec.containers.main "lifecycle" -}}
{{- if not $jobValues.nameOverride -}}
{{- $_ := set $jobValues "nameOverride" (include "ix.v1.common.names.fullname" $) -}}
{{- end -}}
{{- $_ := set $jobs "main" $jobValues -}}
{{- else -}}
{{- $jobs = .Values.jobs -}}
{{- end -}}
{{- range $jobName, $job := $jobs -}}
{{- if $job.enabled -}}
{{- $jobValues := $job -}}