3e661c46985703dc3062993f780860be80e121f0
[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-update-crossplane-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 - Generic cluster creation
39     - name: cluster_kustomization_name
40     - name: cluster_name
41     - name: cluster_type
42     - name: providerconfig_name
43     - name: vm_size
44     - name: node_count
45     - name: cluster_location
46     - name: k8s_version
47
48     # Specific parameters - Bootstrap and credentials
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     # Using `git_fleet_url` instead:
55     # - name: fleet_repo_url
56     # Using `git_sw_catalogs_url` instead:
57     # - name: sw_catalogs_repo_url
58     - name: mgmt_project_name
59       value: "osm_admin"
60
61     # Specific parameters - AKS only
62     - name: rg_name
63       values: ""
64
65     # Specific parameters - GKE only
66     - name: preemptible_nodes
67       values: "false"
68
69     # Advanced parameters - Recommended to keep defaults
70     - name: mgmt_cluster_name
71       value: "_management"
72     - name: base_templates_path
73       value: "cloud-resources"
74     - name: cloned_fleet_folder_name
75       value: "fleet-osm"
76     - name: cloned_sw_catalogs_folder_name
77       value: "sw-catalogs-osm"
78
79     # Debug/dry run?
80     - name: debug
81       value: "false"
82     - name: dry_run
83       value: "false"
84
85
86   # # Cleanup policy
87   # ttlStrategy:
88   #   secondsAfterCompletion: 100 # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
89   #   secondsAfterSuccess: 50     # Time to live after workflow is successful
90   #   secondsAfterFailure: 50     # Time to live after workflow fails
91
92   entrypoint: update-cluster-and-bootstrap
93
94   templates:
95   # Main template
96   - name: update-cluster-and-bootstrap
97     inputs:
98       parameters:
99       # Fleet repo
100       - name: git_fleet_url
101       - name: fleet_destination_folder
102       - name: git_fleet_cred_secret
103       # SW-Catalogs repo
104       - name: git_sw_catalogs_url
105       - name: sw_catalogs_destination_folder
106       - name: git_sw_catalogs_cred_secret
107       # Specific parameters
108       - name: cluster_kustomization_name
109       - name: cluster_name
110       - name: cluster_type
111       - name: providerconfig_name
112       - name: vm_size
113       - name: node_count
114       - name: cluster_location
115       - name: k8s_version
116       - name: public_key_mgmt
117       - name: public_key_new_cluster
118       - name: secret_name_private_age_key_for_new_cluster
119       - name: key_name_in_secret
120       # - name: fleet_repo_url
121       # - name: sw_catalogs_repo_url
122       - name: mgmt_project_name
123       # - name: skip_bootstrap
124       ## AKS only (otherwise, ignored)
125       - name: rg_name
126       ## GKE only (otherwise, ignored)
127       - name: preemptible_nodes
128       # Other parameters - Recommended to keep defaults
129       - name: mgmt_cluster_name
130       - name: base_templates_path
131       - name: cloned_fleet_folder_name
132       - name: cloned_sw_catalogs_folder_name
133       # Debug/dry run?
134       - name: debug
135       - name: dry_run
136
137     steps:
138     # ------ Preparations for transaction
139     - - name: generate-fleet-volume-repo
140         templateRef:
141           name: k8s-resources-wft
142           template: generate-volume
143         arguments:
144           parameters:
145             - name: pvc-size
146               value: '100Mi'
147       - name: generate-sw-catalogs-volume-repo
148         templateRef:
149           name: k8s-resources-wft
150           template: generate-volume
151         arguments:
152           parameters:
153             - name: pvc-size
154               value: '100Mi'
155     - - name: clone-fleet
156         templateRef:
157           name: git-wft
158           template: git-clone
159         arguments:
160           parameters:
161           - name: mount_path
162             value: "/fleet"
163           - name: repo_url
164             value: "{{inputs.parameters.git_fleet_url}}"
165           - name: destination_folder
166             value: "{{inputs.parameters.fleet_destination_folder}}"
167           - name: git_cred_secret
168             value: "{{inputs.parameters.git_fleet_cred_secret}}"
169           - name: git_volume_name
170             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
171       - name: clone-sw-catalogs
172         templateRef:
173           name: git-wft
174           template: git-clone
175         arguments:
176           parameters:
177           - name: mount_path
178             value: "/sw-catalogs"
179           - name: repo_url
180             value: "{{inputs.parameters.git_sw_catalogs_url}}"
181           - name: destination_folder
182             value: "{{inputs.parameters.sw_catalogs_destination_folder}}"
183           - name: git_cred_secret
184             value: "{{inputs.parameters.git_sw_catalogs_cred_secret}}"
185           - name: git_volume_name
186             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
187     # ------ end of preparations for transaction
188
189     # ------ Transformations
190     # Create cluster in target cloud
191     - - name: update-cluster
192         templateRef:
193           name: cluster-management-wft
194           template: update-crossplane-cluster
195         arguments:
196           parameters:
197           # Volumes with cloned repos
198           - name: fleet_volume_name
199             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
200           - name: fleet_mount_path
201             value: "/fleet"
202           - name: sw_catalogs_volume_name
203             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
204           - name: sw_catalogs_mount_path
205             value: "/sw-catalogs"
206           # Specific parameters
207           - name: cluster_kustomization_name
208             value: "{{inputs.parameters.cluster_kustomization_name}}"
209           - name: cluster_name
210             value: "{{inputs.parameters.cluster_name}}"
211           - name: cluster_type
212             value: "{{inputs.parameters.cluster_type}}"
213           - name: providerconfig_name
214             value: "{{inputs.parameters.providerconfig_name}}"
215           - name: vm_size
216             value: "{{inputs.parameters.vm_size}}"
217           - name: node_count
218             value: "{{inputs.parameters.node_count}}"
219           - name: cluster_location
220             value: "{{inputs.parameters.cluster_location}}"
221           - name: k8s_version
222             value: "{{inputs.parameters.k8s_version}}"
223           - name: public_key_mgmt
224             value: "{{inputs.parameters.public_key_mgmt}}"
225           - name: public_key_new_cluster
226             value: "{{inputs.parameters.public_key_new_cluster}}"
227           - name: secret_name_private_age_key_for_new_cluster
228             value: "{{inputs.parameters.secret_name_private_age_key_for_new_cluster}}"
229           - name: key_name_in_secret
230             value: "{{inputs.parameters.key_name_in_secret}}"
231           ## Fed with `git_fleet_url` to avoid duplicates
232           - name: fleet_repo_url
233             value: "{{inputs.parameters.git_fleet_url}}"
234           ## Fed with `git_sw_catalogs_url` to avoid duplicates
235           - name: sw_catalogs_repo_url
236             value: "{{inputs.parameters.git_sw_catalogs_url}}"
237           - name: mgmt_project_name
238             value: "{{inputs.parameters.mgmt_project_name}}"
239           # - name: skip_bootstrap
240           #   value: "{{inputs.parameters.skip_bootstrap}}"
241           ## AKS only
242           - name: rg_name
243             value: "{{inputs.parameters.rg_name}}"
244           ## GKE only
245           - name: preemptible_nodes
246             value: "{{inputs.parameters.preemptible_nodes}}"
247           # Other parameters - Recommended to keep defaults
248           - name: mgmt_cluster_name
249             value: "{{inputs.parameters.mgmt_cluster_name}}"
250           - name: base_templates_path
251             value: "{{inputs.parameters.base_templates_path}}"
252           - name: cloned_fleet_folder_name
253             value: "{{inputs.parameters.cloned_fleet_folder_name}}"
254           - name: cloned_sw_catalogs_folder_name
255             value: "{{inputs.parameters.cloned_sw_catalogs_folder_name}}"
256           # Debug?
257           - name: debug
258             value: "{{inputs.parameters.debug}}"
259     # ------ end of transformations
260
261     # ------ Commit transaction
262     - - name: push-to-fleet
263         templateRef:
264           name: git-wft
265           template: git-commit-merge-push
266         arguments:
267           parameters:
268           - name: mount_path
269             value: "/fleet"
270           - name: repo_folder
271             value: "{{inputs.parameters.fleet_destination_folder}}"
272           - name: git_cred_secret
273             value: "{{inputs.parameters.git_fleet_cred_secret}}"
274           - name: git_volume_name
275             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
276           - name: commit_message
277             value: "Create AKS cluster {{inputs.parameters.cluster_kustomization_name}}"
278           - name: main_branch
279             value: main
280           - name: contrib_branch
281             value: osm_contrib
282           - name: dry_run
283             value: "{{inputs.parameters.dry_run}}"
284 # ------ end of commit transaction