e2cb443bf3e6a15e877ef65b65aa2e8dc01e1c41
[osm/devops.git] /
1 #######################################################################################
2 # Copyright ETSI Contributors and Others.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #    http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #######################################################################################
17
18 apiVersion: argoproj.io/v1alpha1
19 kind: WorkflowTemplate
20 metadata:
21   name: full-purge-delete-cluster-wft
22   namespace: osm-workflows
23
24 spec:
25   arguments:
26     parameters:
27
28     # Fleet repo
29     - name: git_fleet_url
30     - name: fleet_destination_folder
31     - name: git_fleet_cred_secret
32
33     # Specific parameters
34     - name: cluster_kustomization_name
35     - name: project_name
36       value: "osm_admin"
37     - name: temp_kubeconfig_secret_name
38     - name: purge
39       value: "true"
40
41     # Debugging
42     - name: dry_run
43       value: false
44
45
46   # # Cleanup policy
47   # ttlStrategy:
48   #   secondsAfterCompletion: 100 # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
49   #   secondsAfterSuccess: 50     # Time to live after workflow is successful
50   #   secondsAfterFailure: 50     # Time to live after workflow fails
51
52   entrypoint: delete-cluster
53
54   templates:
55
56   # Main template
57   - name: delete-cluster
58     inputs:
59       parameters:
60       # Git repos
61       - name: git_fleet_url
62       - name: fleet_destination_folder
63       - name: git_fleet_cred_secret
64
65       # Specific parameters
66       - name: cluster_kustomization_name
67       - name: project_name
68       - name: purge
69       - name: temp_kubeconfig_secret_name
70
71       # Debugging
72       - name: dry_run
73
74     steps:
75
76     # ------ Preparations for transaction
77     - - name: generate-fleet-volume-repo
78         templateRef:
79           name: k8s-resources-wft
80           template: generate-volume
81         arguments:
82           parameters:
83             - name: pvc-size
84               value: '100Mi'
85     - - name: clone-fleet
86         templateRef:
87           name: git-wft
88           template: git-clone
89         arguments:
90           parameters:
91           - name: mount_path
92             value: "/fleet"
93           - name: repo_url
94             value: "{{inputs.parameters.git_fleet_url}}"
95           - name: destination_folder
96             value: "{{inputs.parameters.fleet_destination_folder}}"
97           - name: git_cred_secret
98             value: "{{inputs.parameters.git_fleet_cred_secret}}"
99           - name: git_volume_name
100             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
101     # ------ end of preparations for transaction
102
103     # ------ Transformations
104     - - name: purge-delete-cluster
105         templateRef:
106           name: cluster-management-wft
107           template: purge-delete-cluster
108         arguments:
109           parameters:
110           # Volumes with cloned repos
111           - name: fleet_volume_name
112             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
113           - name: fleet_mount_path
114             value: "/fleet"
115           # Specific parameters
116           - name: cluster_kustomization_name
117             value: "{{inputs.parameters.cluster_kustomization_name}}"
118           - name: project_name
119             value: "{{inputs.parameters.project_name}}"
120           - name: purge
121             value: "{{inputs.parameters.purge}}"
122           - name: temp_kubeconfig_secret_name
123             value: "{{inputs.parameters.temp_kubeconfig_secret_name}}"
124     # ------ end of transformations
125
126     # ------ Commit transaction
127     - - name: push-to-fleet
128         templateRef:
129           name: git-wft
130           template: git-commit-merge-push
131         arguments:
132           parameters:
133           - name: mount_path
134             value: "/fleet"
135           - name: repo_folder
136             value: "{{inputs.parameters.fleet_destination_folder}}"
137           - name: git_cred_secret
138             value: "{{inputs.parameters.git_fleet_cred_secret}}"
139           - name: git_volume_name
140             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
141           - name: commit_message
142             value: "Delete cluster {{inputs.parameters.cluster_kustomization_name}}"
143           - name: main_branch
144             value: main
145           - name: contrib_branch
146             value: osm_contrib
147           - name: dry_run
148             value: "{{inputs.parameters.dry_run}}"
149 # ------ end of commit transaction