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