-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from shoplineapp/feature/PLAT-878-argo-workfl…
…ow-support-multi-step Cronjob support multi step
- Loading branch information
Showing
5 changed files
with
218 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
apiVersion: v1 | ||
description: Helm chart with simple cronjob template | ||
name: cronjob | ||
version: 0.8.0 | ||
version: 0.9.0 | ||
appVersion: 1.0.0 | ||
tillerVersion: ">=2.14.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
cronjob/templates/_argo_cron_workflow_container_template.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{{- define "cronjob.argo_cron_workflow.container_template" -}} | ||
{{- $input := index . 0 -}} | ||
{{- $namespace := index . 1 -}} | ||
{{- $workflowName := index . 2 -}} | ||
name: {{ $input.name }} | ||
metadata: | ||
namespace: {{ $namespace }} | ||
{{- with $input.podSpecPatch }} | ||
podSpecPatch: {{ quote . }} | ||
{{- end }} | ||
{{- with $input.inputs }} | ||
inputs: {{ toYaml . | nindent 2 }} | ||
{{- end }} | ||
{{- with $input.outputs }} | ||
outputs: {{ toYaml . | nindent 2 }} | ||
{{- end }} | ||
container: | ||
image: {{ template "cronjob.argo_cron_workflow.image" $input.image }} | ||
{{- with $input.command }} | ||
command: {{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- with $input.args }} | ||
args: {{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- if $input.resources }} | ||
# The resource will be apply if "resource is set" | ||
resources: {{- toYaml $input.resources | nindent 4 }} | ||
{{- else }} | ||
# default settings on resources | ||
resources: {{- include "cronjob.argo_cron_workflow.default_resource" . | nindent 4 }} | ||
{{- end }} | ||
{{- with $input.securityContext }} | ||
securityContext: {{ toYaml . | nindent 4 }} | ||
{{- end }} | ||
env: | ||
- name: POD_NAME | ||
value: {{ $workflowName }} | ||
{{- range $key, $value := $input.env }} | ||
- name: {{ $key }} | ||
value: {{ $value | quote }} | ||
{{- end }} | ||
{{- range $key, $name := $input.envSecrets }} | ||
- name: {{ $key }} | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ $name }} | ||
key: {{ $key | quote }} | ||
{{- end }} | ||
# Apply .envFrom if it is set | ||
{{- if $input.envFrom }} | ||
envFrom: | ||
{{- range $input.envFrom.configMapRef }} | ||
- configMapRef: | ||
name: {{ . }} | ||
{{- end }} | ||
{{- range $input.envFrom.secretRef }} | ||
- secretRef: | ||
name: {{ . }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end -}} | ||
|
||
{{- define "cronjob.argo_cron_workflow.default_resource" -}} | ||
limits: | ||
memory: "2Gi" | ||
cpu: "1" | ||
requests: | ||
cpu: "300m" | ||
memory: "1Gi" | ||
{{- end -}} | ||
|
||
{{- define "cronjob.argo_cron_workflow.image" -}} | ||
'{{ required "image.repository must be provided" .repository }}:{{ required "image.tag must be provided" .tag }}' | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{{- define "cronjob.argo_cron_workflow.step_template" -}} | ||
name: {{ .name }} | ||
{{- with .inputs }} | ||
inputs: {{ toYaml . | nindent 2 }} | ||
{{- end }} | ||
{{- with .outputs }} | ||
outputs: {{ toYaml . | nindent 2 }} | ||
{{- end }} | ||
steps: {{ toYaml .steps | nindent 2 }} | ||
{{- if (.job).retries }} | ||
retryStrategy: | ||
# Limit of retries if the job is fail | ||
limit: {{ .job.retries }} | ||
{{- with .job.retryPolicy }} | ||
# Valid Value: "Always" | "OnFailure" | "OnError" | "OnTransientError", Default: "OnFailure" | ||
retryPolicy: {{ . }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters