f70c6769b160ab87a5902bb36212802121e0fd2e
[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: cluster-management-wft
22   namespace: osm-workflows
23 spec:
24   templates:
25
26   # Create a PaaS cluster using CrossPlane (any cloud)
27   - name: create-crossplane-cluster
28     inputs:
29       parameters:
30       # Volumes with cloned repos
31       - name: fleet_volume_name
32       - name: fleet_mount_path
33         value: "/fleet"
34       - name: sw_catalogs_volume_name
35       - name: sw_catalogs_mount_path
36         value: "/sw-catalogs"
37
38       # Specific parameters
39       - name: cluster_kustomization_name
40       - name: cluster_name
41       ## As of today, one among `aks`, `eks` or `gke`:
42       - name: cluster_type
43       - name: providerconfig_name
44       - name: vm_size
45       - name: node_count
46       - name: cluster_location
47       - name: k8s_version
48       - name: public_key_mgmt
49       - name: public_key_new_cluster
50       - name: secret_name_private_age_key_for_new_cluster
51       - name: key_name_in_secret
52         value: "agekey"
53       - name: fleet_repo_url
54       - name: sw_catalogs_repo_url
55       - name: mgmt_project_name
56         value: "osm_admin"
57       ## Do we want to skip OSM's bootstrap?
58       - name: skip_bootstrap
59         value: "false"
60       ## AKS only (otherwise, empty)
61       - name: rg_name
62         values: ""
63       ## GKE only (otherwise, empty)
64       - name: preemptible_nodes
65         values: "false"
66       # Other parameters - Recommended to keep defaults
67       - name: mgmt_cluster_name
68         value: "_management"
69       - name: base_templates_path
70         value: "cloud-resources"
71       - name: cloned_fleet_folder_name
72         value: "fleet-osm"
73       - name: cloned_sw_catalogs_folder_name
74         value: "sw-catalogs-osm"
75       # Debug?
76       - name: debug
77         value: "false"
78
79     container:
80       image: ttl.sh/osm-krm-functions:24h
81       # imagePullPolicy: Always
82       env:
83       - name: PRIVATE_KEY_NEW_CLUSTER
84         valueFrom:
85           secretKeyRef:
86             name: "{{inputs.parameters.secret_name_private_age_key_for_new_cluster}}"
87             key: "{{inputs.parameters.key_name_in_secret}}"
88       - name: DEBUG
89         value: "{{inputs.parameters.debug}}"
90       command: ["/app/scripts/entrypoint.sh"]
91       args:
92       - create_crossplane_cluster
93       - "{{inputs.parameters.cluster_kustomization_name}}"
94       - "{{inputs.parameters.cluster_name}}"
95       - "{{inputs.parameters.cluster_type}}"
96       - "{{inputs.parameters.providerconfig_name}}"
97       - "{{inputs.parameters.vm_size}}"
98       - "{{inputs.parameters.node_count}}"
99       - "{{inputs.parameters.cluster_location}}"
100       - "{{inputs.parameters.k8s_version}}"
101       - "{{inputs.parameters.public_key_mgmt}}"
102       - "{{inputs.parameters.public_key_new_cluster}}"
103       - ''
104       - "{{inputs.parameters.rg_name}}"
105       - "{{inputs.parameters.preemptible_nodes}}"
106       - "{{inputs.parameters.fleet_mount_path}}/{{inputs.parameters.cloned_fleet_folder_name}}"
107       - "{{inputs.parameters.fleet_repo_url}}"
108       - "{{inputs.parameters.sw_catalogs_mount_path}}/{{inputs.parameters.cloned_sw_catalogs_folder_name}}"
109       - "{{inputs.parameters.sw_catalogs_repo_url}}"
110       - "{{inputs.parameters.skip_bootstrap}}"
111       - "{{inputs.parameters.mgmt_project_name}}"
112       - "{{inputs.parameters.mgmt_cluster_name}}"
113       - "{{inputs.parameters.base_templates_path}}"
114
115       volumeMounts:
116       - name: fleet-repo-volume
117         mountPath: '{{inputs.parameters.fleet_mount_path}}'
118       - name: sw-catalogs-repo-volume
119         mountPath: '{{inputs.parameters.sw_catalogs_mount_path}}'
120     volumes:
121       - name: fleet-repo-volume
122         persistentVolumeClaim:
123           claimName: '{{inputs.parameters.fleet_volume_name}}'
124       - name: sw-catalogs-repo-volume
125         persistentVolumeClaim:
126           claimName: '{{inputs.parameters.sw_catalogs_volume_name}}'
127     securityContext:
128       runAsUser: 10000
129     #   runAsGroup: 10000
130     #   fsGroup: 10000
131
132
133   # Update a PaaS cluster created using CrossPlane (any cloud)
134   - name: update-crossplane-cluster
135     inputs:
136       parameters:
137       # Volumes with cloned repos
138       - name: fleet_volume_name
139       - name: fleet_mount_path
140         value: "/fleet"
141       - name: sw_catalogs_volume_name
142       - name: sw_catalogs_mount_path
143         value: "/sw-catalogs"
144
145       # Specific parameters
146       - name: cluster_kustomization_name
147       - name: cluster_name
148       ## As of today, one among `aks`, `eks` or `gke`:
149       - name: cluster_type
150       - name: providerconfig_name
151       - name: vm_size
152       - name: node_count
153       - name: cluster_location
154       - name: k8s_version
155       - name: public_key_mgmt
156       - name: public_key_new_cluster
157       - name: secret_name_private_age_key_for_new_cluster
158       - name: key_name_in_secret
159         value: "agekey"
160       - name: fleet_repo_url
161       - name: sw_catalogs_repo_url
162       - name: mgmt_project_name
163         value: "osm_admin"
164       ## AKS only (otherwise, empty)
165       - name: rg_name
166         values: ""
167       ## GKE only (otherwise, empty)
168       - name: preemptible_nodes
169         values: "false"
170       # Other parameters - Recommended to keep defaults
171       - name: mgmt_cluster_name
172         value: "_management"
173       - name: base_templates_path
174         value: "cloud-resources"
175       - name: cloned_fleet_folder_name
176         value: "fleet-osm"
177       - name: cloned_sw_catalogs_folder_name
178         value: "sw-catalogs-osm"
179       # Debug?
180       - name: debug
181         value: "false"
182
183     container:
184       image: ttl.sh/osm-krm-functions:24h
185       # imagePullPolicy: Always
186       env:
187       - name: PRIVATE_KEY_NEW_CLUSTER
188         valueFrom:
189           secretKeyRef:
190             name: "{{inputs.parameters.secret_name_private_age_key_for_new_cluster}}"
191             key: "{{inputs.parameters.key_name_in_secret}}"
192       - name: DEBUG
193         value: "{{inputs.parameters.debug}}"
194       command: ["/app/scripts/entrypoint.sh"]
195       args:
196       - update_crossplane_cluster
197       - "{{inputs.parameters.cluster_kustomization_name}}"
198       - "{{inputs.parameters.cluster_name}}"
199       - "{{inputs.parameters.cluster_type}}"
200       - "{{inputs.parameters.providerconfig_name}}"
201       - "{{inputs.parameters.vm_size}}"
202       - "{{inputs.parameters.node_count}}"
203       - "{{inputs.parameters.cluster_location}}"
204       - "{{inputs.parameters.k8s_version}}"
205       - "{{inputs.parameters.public_key_mgmt}}"
206       - "{{inputs.parameters.public_key_new_cluster}}"
207       - ''
208       - "{{inputs.parameters.rg_name}}"
209       - "{{inputs.parameters.preemptible_nodes}}"
210       - "{{inputs.parameters.fleet_mount_path}}/{{inputs.parameters.cloned_fleet_folder_name}}"
211       - "{{inputs.parameters.fleet_repo_url}}"
212       - "{{inputs.parameters.sw_catalogs_mount_path}}/{{inputs.parameters.cloned_sw_catalogs_folder_name}}"
213       - "{{inputs.parameters.sw_catalogs_repo_url}}"
214       ## Note that during upgrades, OSM's bootstrap is avoided:
215       - "true"
216       - "{{inputs.parameters.mgmt_project_name}}"
217       - "{{inputs.parameters.mgmt_cluster_name}}"
218       - "{{inputs.parameters.base_templates_path}}"
219
220       volumeMounts:
221       - name: fleet-repo-volume
222         mountPath: '{{inputs.parameters.fleet_mount_path}}'
223       - name: sw-catalogs-repo-volume
224         mountPath: '{{inputs.parameters.sw_catalogs_mount_path}}'
225     volumes:
226       - name: fleet-repo-volume
227         persistentVolumeClaim:
228           claimName: '{{inputs.parameters.fleet_volume_name}}'
229       - name: sw-catalogs-repo-volume
230         persistentVolumeClaim:
231           claimName: '{{inputs.parameters.sw_catalogs_volume_name}}'
232     securityContext:
233       runAsUser: 10000
234     #   runAsGroup: 10000
235     #   fsGroup: 10000
236
237
238   # TODO: Deprecated - To be removed
239   # Create a PaaS cluster in Azure
240   - name: create-cluster-aks
241     inputs:
242       parameters:
243       # Volumes with cloned repos
244       - name: fleet_volume_name
245       - name: fleet_mount_path
246         value: "/fleet"
247       - name: sw_catalogs_volume_name
248       - name: sw_catalogs_mount_path
249         value: "/sw-catalogs"
250
251       # Specific parameters
252       - name: cluster_name
253       - name: vm_size
254       - name: node_count
255       - name: cluster_location
256       - name: rg_name
257       - name: k8s_version
258       - name: providerconfig_name
259       - name: cluster_kustomization_name
260       - name: mgmt_project_name
261         value: "osm_admin"
262
263       # Other parameters - Recommended to keep defaults
264       - name: fleet_repo_dir
265         value: "/fleet/fleet-osm/"
266       - name: sw_catalogs_repo_dir
267         value: "/sw-catalogs/sw-catalogs-osm/"
268       - name: target_folder
269         value: "{{inputs.parameters.fleet_repo_dir}}/{{inputs.parameters.mgmt_project_name}}/managed-resources/_management"
270       - name: manifest_filename
271         value: "{{inputs.parameters.cluster_name}}.yaml"
272       - name: templates
273         value: "{{inputs.parameters.sw_catalogs_repo_dir}}/cloud-resources/aks/templates/"
274       - name: template_manifest_filename
275         value: "aks01.yaml"
276     volumes:
277       - name: fleet-repo-volume
278         persistentVolumeClaim:
279           claimName: '{{inputs.parameters.fleet_volume_name}}'
280       - name: sw-catalogs-repo-volume
281         persistentVolumeClaim:
282           claimName: '{{inputs.parameters.sw_catalogs_volume_name}}'
283     container:
284       image: ttl.sh/osm-krm-functions:24h
285       # imagePullPolicy: Always
286       # securityContext:
287       #   runAsUser: 10000
288       #   runAsGroup: 10000
289       #   fsGroup: 10000
290       volumeMounts:
291       - name: fleet-repo-volume
292         mountPath: '{{inputs.parameters.fleet_mount_path}}'
293       - name: sw-catalogs-repo-volume
294         mountPath: '{{inputs.parameters.sw_catalogs_mount_path}}'
295       command: ["/app/scripts/entrypoint.sh"]
296       args:
297       - create_cluster_aks
298       - "{{inputs.parameters.cluster_name}}"
299       - "{{inputs.parameters.vm_size}}"
300       - "{{inputs.parameters.node_count}}"
301       - "{{inputs.parameters.cluster_location}}"
302       - "{{inputs.parameters.rg_name}}"
303       - "{{inputs.parameters.k8s_version}}"
304       - "{{inputs.parameters.providerconfig_name}}"
305       - "{{inputs.parameters.cluster_kustomization_name}}"
306       - "{{inputs.parameters.target_folder}}"
307       - "{{inputs.parameters.manifest_filename}}"
308       - "{{inputs.parameters.templates}}"
309       - "{{inputs.parameters.template_manifest_filename}}"
310
311
312   # Bootstrap remote cluster running in **ANY cloud**
313   - name: bootstrap-remote-cluster
314     inputs:
315       parameters:
316       # Volumes with cloned repos
317       - name: fleet_volume_name
318       - name: fleet_mount_path
319         value: "/fleet"
320       - name: sw_catalogs_volume_name
321       - name: sw_catalogs_mount_path
322         value: "/sw-catalogs"
323
324       # Specific parameters
325       - name: cluster_name
326       - name: cluster_kustomization_name
327       - name: public_key_mgmt
328       - name: public_key_new_cluster
329       - name: secret_name_private_age_key_for_new_cluster
330       - name: key_name_in_secret
331         value: "agekey"
332       - name: fleet_repo_url
333       - name: sw_catalogs_repo_url
334
335       # Other parameters - Recommended to keep defaults
336       - name: mgmt_project_name
337         value: "osm_admin"
338       - name: imported_cluster
339         value: "false"
340       - name: fleet_repo_dir
341         value: "/fleet/fleet-osm/"
342       - name: sw_catalogs_repo_dir
343         value: "/sw-catalogs/sw-catalogs-osm/"
344
345       # Debug/dry run?
346       - name: debug
347         value: "false"
348
349     container:
350       image: ttl.sh/osm-krm-functions:24h
351       # imagePullPolicy: Always
352       env:
353       - name: PRIVATE_KEY_NEW_CLUSTER
354         valueFrom:
355           secretKeyRef:
356             name: "{{inputs.parameters.secret_name_private_age_key_for_new_cluster}}"
357             key: "{{inputs.parameters.key_name_in_secret}}"
358       - name: DEBUG
359         value: "{{inputs.parameters.debug}}"
360       command: ["/app/scripts/entrypoint.sh"]
361       args:
362       - create_bootstrap_for_remote_cluster
363       - "{{inputs.parameters.cluster_name}}"
364       - "{{inputs.parameters.cluster_kustomization_name}}"
365       - "{{inputs.parameters.fleet_repo_dir}}"
366       - "{{inputs.parameters.sw_catalogs_repo_dir}}"
367       - "{{inputs.parameters.fleet_repo_url}}"
368       - "{{inputs.parameters.sw_catalogs_repo_url}}"
369       - "{{inputs.parameters.mgmt_project_name}}"
370       - "{{inputs.parameters.public_key_mgmt}}"
371       - "{{inputs.parameters.public_key_new_cluster}}"
372       - ''
373       - "{{inputs.parameters.imported_cluster}}"
374       volumeMounts:
375       - name: fleet-repo-volume
376         mountPath: '{{inputs.parameters.fleet_mount_path}}'
377       - name: sw-catalogs-repo-volume
378         mountPath: '{{inputs.parameters.sw_catalogs_mount_path}}'
379     volumes:
380       - name: fleet-repo-volume
381         persistentVolumeClaim:
382           claimName: '{{inputs.parameters.fleet_volume_name}}'
383       - name: sw-catalogs-repo-volume
384         persistentVolumeClaim:
385           claimName: '{{inputs.parameters.sw_catalogs_volume_name}}'
386     securityContext:
387       runAsUser: 10000
388     #   runAsGroup: 10000
389     #   fsGroup: 10000
390
391
392   # Disconnect Flux in remote cluster running in **ANY cloud**
393   - name: disconnect-flux-remote-cluster
394     inputs:
395       parameters:
396       # Volumes with cloned repos
397       - name: fleet_volume_name
398       - name: fleet_mount_path
399         value: "/fleet"
400
401       # Specific parameters
402       - name: cluster_kustomization_name
403       - name: mgmt_project_name
404         value: "osm_admin"
405
406       # Other parameters - Recommended to keep defaults
407       - name: fleet_repo_dir
408         value: "/fleet/fleet-osm/"
409
410       # Debug/dry run?
411       - name: debug
412         value: "false"
413
414     container:
415       image: ttl.sh/osm-krm-functions:24h
416       # imagePullPolicy: Always
417       env:
418       - name: DEBUG
419         value: "{{inputs.parameters.debug}}"
420       command: ["/app/scripts/entrypoint.sh"]
421       args:
422       - disconnect_flux_remote_cluster
423       - "{{inputs.parameters.cluster_kustomization_name}}"
424       - "{{inputs.parameters.fleet_repo_dir}}"
425       - "{{inputs.parameters.mgmt_project_name}}"
426       volumeMounts:
427       - name: fleet-repo-volume
428         mountPath: '{{inputs.parameters.fleet_mount_path}}'
429     volumes:
430       - name: fleet-repo-volume
431         persistentVolumeClaim:
432           claimName: '{{inputs.parameters.fleet_volume_name}}'
433     securityContext:
434       runAsUser: 10000
435     #   runAsGroup: 10000
436     #   fsGroup: 10000
437
438
439   # Delete cluster from **ANY** cloud
440   - name: delete-cluster
441     inputs:
442       parameters:
443       # Volumes with cloned repos
444       - name: fleet_volume_name
445       - name: fleet_mount_path
446         value: "/fleet"
447
448       # Specific parameters
449       - name: cluster_kustomization_name
450       - name: project_name
451         value: "osm_admin"
452
453       # Other parameters - Recommended to keep defaults
454       - name: fleet_repo_dir
455         value: "/fleet/fleet-osm/"
456       - name: mgmt_resources_dir
457         value: "{{inputs.parameters.fleet_repo_dir}}/{{inputs.parameters.project_name}}/managed-resources/_management"
458
459     container:
460       image: ttl.sh/osm-krm-functions:24h
461       # imagePullPolicy: Always
462       command: ["/app/scripts/entrypoint.sh"]
463       args:
464       - delete_remote_cluster
465       - "{{inputs.parameters.cluster_kustomization_name}}"
466       - "{{inputs.parameters.project_name}}"
467       - "{{inputs.parameters.fleet_repo_dir}}"
468       - "{{inputs.parameters.mgmt_resources_dir}}"
469
470       volumeMounts:
471       - name: fleet-repo-volume
472         mountPath: '{{inputs.parameters.fleet_mount_path}}'
473     volumes:
474       - name: fleet-repo-volume
475         persistentVolumeClaim:
476           claimName: '{{inputs.parameters.fleet_volume_name}}'
477     securityContext:
478       runAsUser: 10000
479     #   runAsGroup: 10000
480     #   fsGroup: 10000