f8c1331a04256170558ec577629a1cb3f79dd2cc
[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: mgmt_cluster_name
39       value: ""
40     - name: purge
41       value: "true"
42
43     # Debugging
44     - name: dry_run
45       value: false
46
47
48   # # Cleanup policy
49   # ttlStrategy:
50   #   secondsAfterCompletion: 100 # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
51   #   secondsAfterSuccess: 50     # Time to live after workflow is successful
52   #   secondsAfterFailure: 50     # Time to live after workflow fails
53
54   entrypoint: delete-cluster
55
56   templates:
57
58   # Main template
59   - name: delete-cluster
60     inputs:
61       parameters:
62       # Git repos
63       - name: git_fleet_url
64       - name: fleet_destination_folder
65       - name: git_fleet_cred_secret
66
67       # Specific parameters
68       - name: cluster_kustomization_name
69       - name: project_name
70       - name: temp_kubeconfig_secret_name
71       - name: mgmt_cluster_name
72       - name: purge
73
74       # Debugging
75       - name: dry_run
76
77     steps:
78
79     # ------ Preparations for transaction
80     - - name: generate-fleet-volume-repo
81         templateRef:
82           name: k8s-resources-wft
83           template: generate-volume
84         arguments:
85           parameters:
86             - name: pvc-size
87               value: '100Mi'
88     - - name: clone-fleet
89         templateRef:
90           name: git-wft
91           template: git-clone
92         arguments:
93           parameters:
94           - name: mount_path
95             value: "/fleet"
96           - name: repo_url
97             value: "{{inputs.parameters.git_fleet_url}}"
98           - name: destination_folder
99             value: "{{inputs.parameters.fleet_destination_folder}}"
100           - name: git_cred_secret
101             value: "{{inputs.parameters.git_fleet_cred_secret}}"
102           - name: git_volume_name
103             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
104     # ------ end of preparations for transaction
105
106     # ------ Transformations
107     - - name: purge-delete-cluster
108         templateRef:
109           name: cluster-management-wft
110           template: purge-delete-cluster
111         arguments:
112           parameters:
113           # Volumes with cloned repos
114           - name: fleet_volume_name
115             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
116           - name: fleet_mount_path
117             value: "/fleet"
118           # Specific parameters
119           - name: cluster_kustomization_name
120             value: "{{inputs.parameters.cluster_kustomization_name}}"
121           - name: project_name
122             value: "{{inputs.parameters.project_name}}"
123           - name: mgmt_cluster_name
124             value: "{{inputs.parameters.mgmt_cluster_name}}"
125           - name: purge
126             value: "{{inputs.parameters.purge}}"
127           - name: temp_kubeconfig_secret_name
128             value: "{{inputs.parameters.temp_kubeconfig_secret_name}}"
129     # ------ end of transformations
130
131     # ------ Commit transaction
132     - - name: push-to-fleet
133         templateRef:
134           name: git-wft
135           template: git-commit-merge-push
136         arguments:
137           parameters:
138           - name: mount_path
139             value: "/fleet"
140           - name: repo_folder
141             value: "{{inputs.parameters.fleet_destination_folder}}"
142           - name: git_cred_secret
143             value: "{{inputs.parameters.git_fleet_cred_secret}}"
144           - name: git_volume_name
145             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
146           - name: commit_message
147             value: "Delete cluster {{inputs.parameters.cluster_kustomization_name}}"
148           - name: main_branch
149             value: main
150           - name: contrib_branch
151             value: osm_contrib
152           - name: dry_run
153             value: "{{inputs.parameters.dry_run}}"
154 # ------ end of commit transaction