Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasKwan-shopline committed Dec 11, 2024
1 parent 609071b commit 4098c14
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 20 deletions.
6 changes: 6 additions & 0 deletions cronjob/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: workflow-lib
repository: file://../workflow-lib
version: 0.1.0
digest: sha256:a825bc58a89b9828010f616699d3b7a9bbddb768148dbc81e7365bcfd3f674de
generated: "2024-12-11T18:01:18.461727+08:00"
7 changes: 6 additions & 1 deletion cronjob/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
apiVersion: v1
apiVersion: v2
description: Helm chart with simple cronjob template
name: cronjob
version: 1.1.0
appVersion: 1.0.0
tillerVersion: ">=2.14.3"

dependencies:
- name: workflow-lib
version: 0.1.0
repository: file://../workflow-lib
Binary file added cronjob/charts/workflow-lib-0.1.0.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion cronjob/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ spec:
workflowTemplateRef:
name: po-{{ .Values.name }}
{{- else }}
{{- include "cronjob.argo_cron_workflow" . | nindent 4 }}
{{- include "workflow-lib.argo_cron_workflow" . | nindent 4 }}
{{- end }}
{{- else }}
{{ template "cronjob.k8s_cronjob" . }}
Expand Down
2 changes: 1 addition & 1 deletion cronjob/templates/workflowtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ metadata:
labels:
businessid: {{ required "businessid must be provided" .Values.businessid | quote }}
spec:
{{ include "cronjob.argo_cron_workflow" . | nindent 2 }}
{{ include "workflow-lib.argo_cron_workflow" . | nindent 2 }}
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions workflow-lib/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions workflow-lib/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: workflow-lib
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: library

# 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.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- define "cronjob.argo_cron_workflow" -}}
{{- define "workflow-lib.argo_cron_workflow" -}}
podMetadata:
labels:
name: {{ .Values.name }}
Expand Down Expand Up @@ -120,23 +120,23 @@ templates:

{{- if .Values.steps }}
{{- range .Values.steps }}
- {{- include "cronjob.argo_cron_workflow.step_template" . | nindent 8 }}
- {{- include "workflow-lib.argo_cron_workflow.step_template" . | nindent 8 }}
{{- end }}
{{- else }}
{{- /* if no steps, use single step */}}
{{- $defaultValue := merge (fromJson "{\"name\":\"entry\",\"steps\":[[{\"name\":\"step1\",\"template\":\"template\"}]]}") $.Values }}
- {{- include "cronjob.argo_cron_workflow.step_template" $defaultValue | nindent 8 }}
- {{- include "workflow-lib.argo_cron_workflow.step_template" $defaultValue | nindent 8 }}
{{- end }}

{{- if .Values.containers }}
{{- range .Values.containers }}
{{ $value := list . $.Release.Namespace $.Values.name }}
- {{- include "cronjob.argo_cron_workflow.container_template" $value | nindent 8}}
- {{- include "workflow-lib.argo_cron_workflow.container_template" $value | nindent 8}}
{{- end }}
{{- else }}
{{- $defaultValue := merge (fromJson "{\"name\":\"template\"}") $.Values }}
{{- $value := list $defaultValue $.Release.Namespace $.Values.name }}
- {{- include "cronjob.argo_cron_workflow.container_template" $value | nindent 8 }}
- {{- include "workflow-lib.argo_cron_workflow.container_template" $value | nindent 8 }}
{{- end }}

# The template of exist-handler if any .Values.exitNotifications config is set
Expand Down Expand Up @@ -188,15 +188,15 @@ templates:
{{- end }}
# If .Values.exitNotifications.slackApp is set, Slack app notification template will be loaded
{{- if .Values.exitNotifications.slackApp }}
{{ include "cronjob._exit_handler_slack_app" . | nindent 2 }}
{{ include "workflow-lib._exit_handler_slack_app" . | nindent 2 }}
{{- end }}
# If .Values.exitNotifications.newRelic is set, New Relic notification template will be loaded
{{- if .Values.exitNotifications.newRelic }}
{{ include "cronjob._exit_handler_newrelic" . | nindent 2 }}
{{ include "workflow-lib._exit_handler_newrelic" . | nindent 2 }}
{{- end }}
# If .Values.exitNotifications.healthcheckIo is set, Healthcheck IO notification template will be loaded
{{- if .Values.exitNotifications.healthcheckIo }}
{{ include "cronjob._exit_handler_healthcheck_io" . | nindent 2 }}
{{ include "workflow-lib._exit_handler_healthcheck_io" . | nindent 2 }}
{{- end }}
{{- end }}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- define "cronjob.argo_cron_workflow.container_template" -}}
{{- define "workflow-lib.argo_cron_workflow.container_template" -}}
{{- $input := index . 0 -}}
{{- $namespace := index . 1 -}}
{{- $workflowName := index . 2 -}}
Expand All @@ -17,7 +17,7 @@ inputs: {{ toYaml . | nindent 2 }}
outputs: {{ toYaml . | nindent 2 }}
{{- end }}
container:
image: {{ template "cronjob.argo_cron_workflow.image" $input.image }}
image: {{ template "workflow-lib.argo_cron_workflow.image" $input.image }}
{{- with $input.command }}
command: {{- toYaml . | nindent 4 }}
{{- end }}
Expand All @@ -29,7 +29,7 @@ container:
resources: {{- toYaml $input.resources | nindent 4 }}
{{- else }}
# default settings on resources
resources: {{- include "cronjob.argo_cron_workflow.default_resource" . | nindent 4 }}
resources: {{- include "workflow-lib.argo_cron_workflow.default_resource" . | nindent 4 }}
{{- end }}
{{- with $input.securityContext }}
securityContext: {{ toYaml . | nindent 4 }}
Expand Down Expand Up @@ -62,7 +62,7 @@ container:
{{- end }}
{{- end -}}

{{- define "cronjob.argo_cron_workflow.default_resource" -}}
{{- define "workflow-lib.argo_cron_workflow.default_resource" -}}
limits:
memory: "2Gi"
cpu: "1"
Expand All @@ -71,6 +71,6 @@ requests:
memory: "1Gi"
{{- end -}}

{{- define "cronjob.argo_cron_workflow.image" -}}
{{- define "workflow-lib.argo_cron_workflow.image" -}}
'{{ required "image.repository must be provided" .repository }}:{{ required "image.tag must be provided" .tag }}'
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- define "cronjob.argo_cron_workflow.step_template" -}}
{{- define "workflow-lib.argo_cron_workflow.step_template" -}}
name: {{ .name }}
{{- with .inputs }}
inputs: {{ toYaml . | nindent 2 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- define "cronjob._exit_handler_healthcheck_io" -}}
{{- define "workflow-lib._exit_handler_healthcheck_io" -}}
{{- $healthcheckIo := .Values.exitNotifications.healthcheckIo | default dict -}}
- name: notice-healthcheck-io-succeeded # For cronjob health check, as the schedule may different therefore each cronjob will have different uuid
container:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- define "cronjob._exit_handler_newrelic" -}}
{{- define "workflow-lib._exit_handler_newrelic" -}}
{{- $newRelic := .Values.exitNotifications.newRelic | default dict -}}
{{- $image := $newRelic.image | default dict -}}
- name: notice-newrelic-failed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- define "cronjob._exit_handler_slack_app" -}}
{{- define "workflow-lib._exit_handler_slack_app" -}}
{{- $slackApp := .Values.exitNotifications.slackApp | default dict -}}
{{- $sendOnSuccess := list nil true "true" | has $slackApp.sendOnSuccess -}}
{{- $sendOnFailure := list nil true "true" | has $slackApp.sendOnFailure -}}
Expand Down

0 comments on commit 4098c14

Please sign in to comment.