Argo Workflows workflow template
在之前的例子中,我们是把 workflow 的 描述内容直接写进了 sensor
本例中将从一个 template 中引用
下面是 template 配置文件
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: buildkit
namespace: argo
spec:
templates:
- name: clean
container:
name: ''
image: k8s.gcr.io/busybox
imagePullPolicy: IfNotPresent
command:
- /bin/sh
args:
- '-c'
- 'rm -rf /work/*'
workingDir: /work
volumeMounts:
- name: work
mountPath: /work
- name: clone
inputs:
artifacts:
- name: argo-source
path: /src
git:
repo: '{{workflow.parameters.repo}}'
revision: '{{workflow.parameters.branch}}'
usernameSecret:
name: github-creds
key: username
passwordSecret:
name: github-creds
key: password
container:
image: k8s.gcr.io/busybox
command:
- /bin/sh
args:
- '-c'
- cp -rf /src/. /work/ && ls /work
workingDir: /src
volumeMounts:
- name: work
mountPath: /work
- name: getcommitid
inputs: {}
outputs: {}
metadata: {}
container:
name: ''
image: xxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/getcommitid
command:
- /bin/bash
args:
- '-c'
- /getcommitid.sh
workingDir: /work
volumeMounts:
- name: work
mountPath: /work
- name: mountcommitid
outputs:
parameters:
- name: commitid
valueFrom:
path: /work/commitid.txt
default: mockup_commitid
metadata: {}
container:
name: ''
image: k8s.gcr.io/busybox
command:
- /bin/sh
args:
- '-c'
- ls /work
workingDir: /work
resources: {}
volumeMounts:
- name: work
mountPath: /work
- name: build
container:
name: ''
image: 'xxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/node-alpine-3-13'
command:
- sh
args:
- -c
- 'yarn install && yarn build'
workingDir: /work
env:
- name: ENVTEST
value: helloworld
volumeMounts:
- name: work
mountPath: /work
- name: buildbe
container:
name: ''
image: 'xxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/lizhewebbemvnbuilder'
command:
- mvn
args:
- 'clean'
- 'install'
- 'package'
workingDir: /work/lizheweb-server
env:
- name: ENVTEST
value: helloworld
volumeMounts:
- name: work
mountPath: /work
- name: build-storybook
container:
name: ''
image: 'xxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/node-alpine-3-13'
command:
- sh
args:
- -c
- 'yarn install && yarn build-storybook'
workingDir: /work/packages/components
env:
- name: ENVTEST
value: helloworld
volumeMounts:
- name: work
mountPath: /work
- name: image
inputs:
parameters:
- name: image
- name: commitid
- name: dockercontext
- name: dockerfile
container:
name: ''
image: gcr.io/kaniko-project/executor@sha256:f652f28537fa76e8f4f9393de13a064f0206003c451ce2ad6e4359fd5a21acbc
args:
- '-f'
- '{{inputs.parameters.dockercontext}}/{{inputs.parameters.dockerfile}}'
- '-c'
- '{{inputs.parameters.dockercontext}}'
- --destination={{inputs.parameters.image}}:{{inputs.parameters.commitid}}
workingDir: /work
env:
- name: envkey
value: envvalue
resources: {}
volumeMounts:
- name: docker-config
mountPath: /kaniko/.docker/
- name: aws-secret
mountPath: /root/.aws/
- name: work
mountPath: /work
volumes:
- name: docker-config
configMap:
name: docker-config
- name: aws-secret
secret:
secretName: aws-secret
- name: deploy
inputs:
parameters:
- name: depfileyaml
container:
name: ''
image: 'xxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/sedcommitid:latest'
command:
- /main.sh
args:
- '{{inputs.parameters.depfileyaml}}'
workingDir: /
env:
- name: GIT_URL
valueFrom:
secretKeyRef:
key: fecom
name: giturl
- name: REPO
value: lizhe-devops
- name: BRANCH
value: main
- name: USER_NAME
value: lizhe
- name: USER_EMAIL
value: YOUR@EMAIL.COM
volumeMounts:
- name: work
mountPath: /work
- name: deploy-exit-handler
container:
image: docker/whalesay
command: [cowsay]
args: ["task cleanup"]
- name: exit-handler
inputs:
parameters:
- name: projectname
container:
image: xxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/lizhewfmailsender
command:
- /bin/bash
args:
- -c
- "/main {{workflow.name}} {{workflow.status}} {{workflow.failures}} /work/commitid.txt"
workingDir: /work
env:
- name: projectname
value: '{{workflow.parameters.projectname}}'
- name: smtppass
valueFrom:
secretKeyRef:
key: password
name: smtpaccount
- name: smtpuser
valueFrom:
secretKeyRef:
key: username
name: smtpaccount
- name: smtphost
value: smtp.gmail.com
- name: smtpport
value: "587"
- name: sender
value: SENDER@GMAIL.COM
# - name: receivers
# value: XXX@EMAIL.COM,XXX@EMAIL.COM
- name: smtpCc
value: XXX@EMAIL.COM,XXX@EMAIL.COM
- name: subject
value: mockup_subject
- name: body
value: mockup_body
volumeMounts:
- name: work
mountPath: /work