-
Notifications
You must be signed in to change notification settings - Fork 32
/
deployment_workflow.yaml
59 lines (53 loc) · 1.61 KB
/
deployment_workflow.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: "synthetic-deployment-"
namespace: kube-system
spec:
entrypoint: synthetic-example
onExit: exit-handler
templates:
- name: synthetic-example
steps:
- - name: create-deployment
template: create-deployment
- - name: sleep
template: sleep-n-sec
- - name: check-deployment
template: check-deployment
- - name: delete-deployment
template: delete-deployment
- name: exit-handler
steps:
- - name: cleanup
template: cleanup-workflow
when: "{{workflow.status}} == Failed"
- name: create-deployment
script:
image: lachlanevenson/k8s-kubectl
command: [sh]
source: |
kubectl run operator-nginx --image=nginx:latest --replicas=2 --port=80 -n monitoring
- name: sleep-n-sec
container:
image: alpine:latest
command: [sh, -c]
args: ["echo sleeping for 40 seconds; sleep 40; echo done"]
- name: check-deployment
script:
image: lachlanevenson/k8s-kubectl
command: [sh]
source: |
kubectl get po -n monitoring | grep operator-nginx | grep Running
- name: delete-deployment
script:
image: lachlanevenson/k8s-kubectl
command: [sh]
source: |
kubectl delete deploy operator-nginx -n monitoring; [[ $? == 0 ]] && echo "Workflow ran successfully"
- name: cleanup-workflow
script:
image: lachlanevenson/k8s-kubectl
command: [sh]
source: |
kubectl delete deploy operator-nginx -n monitoring; [[ $? == 0 ]] && echo "Workflow failed and completed cleanup"