76ac3eb12bb0b8a5bbe9f91ef9fe56fbddcd251d
[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-create-aks-cluster-and-bootstrap-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     # SW-Catalogs repo
34     - name: git_sw_catalogs_url
35     - name: sw_catalogs_destination_folder
36     - name: git_sw_catalogs_cred_secret
37
38     # Specific parameters - AKS cluster
39     - name: cluster_name
40     - name: vm_size
41     - name: node_count
42     - name: cluster_location
43     - name: rg_name
44     - name: k8s_version
45     - name: providerconfig_name
46     - name: cluster_kustomization_name
47
48     # Specific parameters - Bootstrap
49     - name: public_key_mgmt
50     - name: public_key_new_cluster
51     - name: secret_name_private_age_key_for_new_cluster
52     - name: key_name_in_secret
53       value: "agekey"
54     - name: fleet_repo_url
55     - name: sw_catalogs_repo_url
56
57     # Debugging
58     - name: dry_run
59       value: false
60
61
62   # # Cleanup policy
63   # ttlStrategy:
64   #   secondsAfterCompletion: 100 # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
65   #   secondsAfterSuccess: 50     # Time to live after workflow is successful
66   #   secondsAfterFailure: 50     # Time to live after workflow fails
67
68   entrypoint: create-aks-cluster-and-bootstrap
69
70   templates:
71
72   # Main template
73   - name: create-aks-cluster-and-bootstrap
74     inputs:
75       parameters:
76       # Git repos
77       - name: git_fleet_url
78       - name: fleet_destination_folder
79       - name: git_fleet_cred_secret
80       - name: git_sw_catalogs_url
81       - name: sw_catalogs_destination_folder
82       - name: git_sw_catalogs_cred_secret
83
84       # Specific parameters - AKS cluster
85       - name: cluster_name
86       - name: vm_size
87       - name: node_count
88       - name: cluster_location
89       - name: rg_name
90       - name: k8s_version
91       - name: providerconfig_name
92       - name: cluster_kustomization_name
93
94       # Specific parameters - Bootstrap
95       - name: public_key_mgmt
96       - name: public_key_new_cluster
97       - name: secret_name_private_age_key_for_new_cluster
98       - name: key_name_in_secret
99       - name: fleet_repo_url
100       - name: sw_catalogs_repo_url
101
102       # Debugging
103       - name: dry_run
104     steps:
105
106     # ------ Preparations for transaction
107     - - name: generate-fleet-volume-repo
108         templateRef:
109           name: k8s-resources-wft
110           template: generate-volume
111         arguments:
112           parameters:
113             - name: pvc-size
114               value: '100Mi'
115       - name: generate-sw-catalogs-volume-repo
116         templateRef:
117           name: k8s-resources-wft
118           template: generate-volume
119         arguments:
120           parameters:
121             - name: pvc-size
122               value: '100Mi'
123     - - name: clone-fleet
124         templateRef:
125           name: git-wft
126           template: git-clone
127         arguments:
128           parameters:
129           - name: mount_path
130             value: "/fleet"
131           - name: repo_url
132             value: "{{inputs.parameters.git_fleet_url}}"
133           - name: destination_folder
134             value: "{{inputs.parameters.fleet_destination_folder}}"
135           - name: git_cred_secret
136             value: "{{inputs.parameters.git_fleet_cred_secret}}"
137           - name: git_volume_name
138             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
139       - name: clone-sw-catalogs
140         templateRef:
141           name: git-wft
142           template: git-clone
143         arguments:
144           parameters:
145           - name: mount_path
146             value: "/sw-catalogs"
147           - name: repo_url
148             value: "{{inputs.parameters.git_sw_catalogs_url}}"
149           - name: destination_folder
150             value: "{{inputs.parameters.sw_catalogs_destination_folder}}"
151           - name: git_cred_secret
152             value: "{{inputs.parameters.git_sw_catalogs_cred_secret}}"
153           - name: git_volume_name
154             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
155     # ------ end of preparations for transaction
156
157     # ------ Transformations
158     # Create cluster in target cloud
159     - - name: create-cluster-aks
160         templateRef:
161           name: cluster-management-wft
162           template: create-cluster-aks
163         arguments:
164           parameters:
165           # Volumes with cloned repos
166           - name: fleet_volume_name
167             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
168           - name: fleet_mount_path
169             value: "/fleet"
170           - name: sw_catalogs_volume_name
171             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
172           - name: sw_catalogs_mount_path
173             value: "/sw-catalogs"
174           # Specific parameters
175           - name: cluster_name
176             value: "{{inputs.parameters.cluster_name}}"
177           - name: vm_size
178             value: "{{inputs.parameters.vm_size}}"
179           - name: node_count
180             value: "{{inputs.parameters.node_count}}"
181           - name: cluster_location
182             value: "{{inputs.parameters.cluster_location}}"
183           - name: rg_name
184             value: "{{inputs.parameters.rg_name}}"
185           - name: k8s_version
186             value: "{{inputs.parameters.k8s_version}}"
187           - name: providerconfig_name
188             value: "{{inputs.parameters.providerconfig_name}}"
189           - name: cluster_kustomization_name
190             value: "{{inputs.parameters.cluster_kustomization_name}}"
191
192     # Bootstrap the new remote cluster
193     - - name: bootstrap-new-cluster
194         templateRef:
195           name: cluster-management-wft
196           template: bootstrap-remote-cluster
197         arguments:
198           parameters:
199           # Volumes with cloned repos
200           - name: fleet_volume_name
201             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
202           - name: fleet_mount_path
203             value: "/fleet"
204           - name: sw_catalogs_volume_name
205             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
206           - name: sw_catalogs_mount_path
207             value: "/sw-catalogs"
208
209           # Specific parameters
210           - name: cluster_name
211             value: "{{inputs.parameters.cluster_name}}"
212           - name: cluster_kustomization_name
213             value: "{{inputs.parameters.cluster_kustomization_name}}"
214           - name: public_key_mgmt
215             value: "{{inputs.parameters.public_key_mgmt}}"
216           - name: public_key_new_cluster
217             value: "{{inputs.parameters.public_key_new_cluster}}"
218           - name: secret_name_private_age_key_for_new_cluster
219             value: "{{inputs.parameters.secret_name_private_age_key_for_new_cluster}}"
220           - name: key_name_in_secret
221             value: "{{inputs.parameters.key_name_in_secret}}"
222           - name: fleet_repo_url
223             value: "{{inputs.parameters.fleet_repo_url}}"
224           - name: sw_catalogs_repo_url
225             value: "{{inputs.parameters.sw_catalogs_repo_url}}"
226     # ------ end of transformations
227
228     # ------ Commit transaction
229     - - name: push-to-fleet
230         templateRef:
231           name: git-wft
232           template: git-commit-merge-push
233         arguments:
234           parameters:
235           - name: mount_path
236             value: "/fleet"
237           - name: repo_folder
238             value: "{{inputs.parameters.fleet_destination_folder}}"
239           - name: git_cred_secret
240             value: "{{inputs.parameters.git_fleet_cred_secret}}"
241           - name: git_volume_name
242             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
243           - name: commit_message
244             value: "Create AKS cluster {{inputs.parameters.cluster_kustomization_name}}"
245           - name: main_branch
246             value: main
247           - name: contrib_branch
248             value: osm_contrib
249           - name: dry_run
250             value: "{{inputs.parameters.dry_run}}"
251 # ------ end of commit transaction