@@ -504,3 +504,132 @@ spec:
504504 {{- end }}
505505
506506{{- end }}
507+ {{- range .Values.jobs.extra_hooks -}}
508+ {{- $name := print "extra-helm-hook" (include "stackstorm-ha.hyphenPrefix" (required "You must name each entry in jobs.extra_hooks." .name)) }}
509+ ---
510+ apiVersion : batch/v1
511+ kind : Job
512+ metadata :
513+ name : {{ $.Release.Name }}-job-{{ $name }}
514+ labels :
515+ app : {{ $name }}
516+ tier : backend
517+ vendor : stackstorm
518+ chart : {{ $.Chart.Name }}-{{ $.Chart.Version }}
519+ release : {{ $.Release.Name }}
520+ heritage : {{ $.Release.Service }}
521+ annotations :
522+ helm.sh/hook : {{ required "Each entry in jobs.extra_hooks must include 'hook' (the helm.sh/hook value)" .hook }}
523+ helm.sh/hook-delete-policy : before-hook-creation
524+ helm.sh/hook-weight : {{ .hook_weight | default 10 | toString | quote }}
525+ {{- if $.Values.jobs.annotations }}
526+ {{- toYaml $.Values.jobs.annotations | nindent 4 }}
527+ {{- end }}
528+ spec :
529+ template :
530+ metadata :
531+ name : job-{{ $name }}
532+ labels :
533+ app : {{ $name }}
534+ tier : backend
535+ vendor : stackstorm
536+ chart : {{ $.Chart.Name }}-{{ $.Chart.Version }}
537+ release : {{ $.Release.Name }}
538+ heritage : {{ $.Release.Service }}
539+ annotations :
540+ checksum/config : {{ include (print $.Template.BasePath "/configmaps_st2-conf.yaml") $ | sha256sum }}
541+ checksum/packs : {{ include (print $.Template.BasePath "/configmaps_packs.yaml") $ | sha256sum }}
542+ {{- if $.Values.jobs.annotations }}
543+ {{- toYaml $.Values.jobs.annotations | nindent 8 }}
544+ {{- end }}
545+ spec :
546+ imagePullSecrets :
547+ {{- if $.Values.image.pullSecret }}
548+ - name : {{ $.Values.image.pullSecret }}
549+ {{- end }}
550+ {{- if $.Values.st2.packs.images -}}
551+ {{- include "stackstorm-ha.packs-pullSecrets" $ | nindent 6 }}
552+ {{- end }}
553+ initContainers :
554+ {{- include "stackstorm-ha.init-containers-wait-for-db" $ | nindent 6 }}
555+ {{- include "stackstorm-ha.packs-initContainers" $ | nindent 6 }}
556+ - name : generate-st2client-config
557+ image : ' {{ template "stackstorm-ha.imageRepository" $ }}/st2actionrunner:{{ tpl ($.Values.jobs.image.tag | default ($.Values.st2actionrunner.image.tag | default $.Values.image.tag)) $ }}'
558+ imagePullPolicy : {{ $.Values.image.pullPolicy }}
559+ {{- with $.Values.securityContext }}
560+ securityContext : {{- toYaml . | nindent 10 }}
561+ {{- end }}
562+ envFrom :
563+ - configMapRef :
564+ name : {{ $.Release.Name }}-st2-urls
565+ - secretRef :
566+ name : {{ $.Release.Name }}-st2-auth
567+ {{- range $.Values.jobs.envFromSecrets }}
568+ - secretRef :
569+ name : {{ . }}
570+ {{- end }}
571+ volumeMounts :
572+ - name : st2client-config-vol
573+ mountPath : /root/.st2/
574+ # `st2 login` doesn't exit on failure correctly, use old methods instead. See bug: https://github.com/StackStorm/st2/issues/4338
575+ command :
576+ - ' sh'
577+ - ' -ec'
578+ - |
579+ cat <<EOT > /root/.st2/config
580+ [credentials]
581+ {{- tpl $.Values.jobs.st2clientConfig $ | nindent 12 }}
582+ EOT
583+ containers :
584+ - name : {{ $name }}
585+ image : ' {{ template "stackstorm-ha.imageRepository" $ }}/st2actionrunner:{{ tpl ($.Values.jobs.image.tag | default ($.Values.st2actionrunner.image.tag | default $.Values.image.tag)) $ }}'
586+ imagePullPolicy : {{ $.Values.image.pullPolicy }}
587+ {{- with $.Values.securityContext }}
588+ securityContext : {{- toYaml . | nindent 10 }}
589+ {{- end }}
590+ {{- if $.Values.jobs.env }}
591+ env : {{- include "stackstorm-ha.customEnv" $.Values.jobs | nindent 8 }}
592+ {{- end }}
593+ envFrom :
594+ {{- range $.Values.jobs.envFromSecrets }}
595+ - secretRef :
596+ name : {{ . }}
597+ {{- end }}
598+ command : {{- required "Each entry in jobs.extra_hooks must include the 'command' to run." .command | toYaml | nindent 10 }}
599+ volumeMounts :
600+ - name : st2client-config-vol
601+ mountPath : /root/.st2/
602+ {{- include "stackstorm-ha.st2-config-volume-mounts" $ | nindent 8 }}
603+ {{- include "stackstorm-ha.packs-volume-mounts-for-register-job" $ | nindent 8 }}
604+ {{- include "stackstorm-ha.pack-configs-volume-mount" $ | nindent 8 }}
605+ {{- if .resources }}
606+ resources : {{- toYaml .resources | nindent 10 }}
607+ {{- end }}
608+ volumes :
609+ - name : st2client-config-vol
610+ emptyDir :
611+ medium : Memory
612+ {{- include "stackstorm-ha.st2-config-volume" $ | nindent 8 }}
613+ {{- include "stackstorm-ha.packs-volumes" $ | nindent 8 }}
614+ {{- include "stackstorm-ha.pack-configs-volume" $ | nindent 8 }}
615+ restartPolicy : OnFailure
616+ {{- if $.Values.dnsPolicy }}
617+ dnsPolicy : {{ $.Values.dnsPolicy }}
618+ {{- end }}
619+ {{- with $.Values.dnsConfig }}
620+ dnsConfig : {{- toYaml . | nindent 8 }}
621+ {{- end }}
622+ {{- with $.Values.podSecurityContext }}
623+ securityContext : {{- toYaml . | nindent 8 }}
624+ {{- end }}
625+ {{- with $.Values.jobs.nodeSelector }}
626+ nodeSelector : {{- toYaml . | nindent 8 }}
627+ {{- end }}
628+ {{- with $.Values.jobs.affinity }}
629+ affinity : {{- toYaml . | nindent 8 }}
630+ {{- end }}
631+ {{- with $.Values.jobs.tolerations }}
632+ tolerations : {{- toYaml . | nindent 8 }}
633+ {{- end }}
634+
635+ {{- end }}
0 commit comments