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