71dc58b97ce7b9fa794edbc34476cd8fdfe85326
[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: ksu-management-wft
22   namespace: osm-workflows
23 spec:
24   templates:
25
26 # Create a KSU based on an OKA Package which includes a `HelmRelease`
27   - name: create-ksu-oka-hr
28     inputs:
29       parameters:
30       # References to required external resources
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       # Specific parameters - Base KSU generation from template
38       - name: templates_path
39       ## Should substitute environment variables in the template?
40       - name: substitute_environment
41         value: "false"
42       ## Filter for substitution of environment variables
43       - name: substitution_filter
44         value: ""
45       ## Custom environment variables (formatted as .env), to be used for template parametrization
46       - name: custom_env_vars
47         value: ""
48       ## Root folder of the cloned SW Catalogs repo - Do not touch
49       - name: cloned_sw_catalogs_folder_name
50         value: "sw-catalogs-osm"
51       # Specific parameters - Patch HelmRelease in KSU with inline values
52       - name: kustomization_name
53       - name: helmrelease_name
54       - name: inline_values
55         value: ""
56       # Specific parameters - Secret generation
57       - name: is_preexisting_secret
58         value: "false"
59       - name: target_ns
60       - name: age_public_key
61       - name: values_secret_name
62       - name: reference_secret_for_values
63       - name: reference_key_for_values
64       - name: secret_key
65         value: "values.yaml"
66       # Specific parameters - Configmap generation
67       - name: is_preexisting_cm
68         value: "false"
69       - name: values_cm_name
70       - name: cm_key
71         value: "values.yaml"
72       - name: cm_values
73         value: ""
74       # Specific parameters - KSU rendering
75       - name: ksu_name
76       - name: profile_name
77       - name: profile_type
78       - name: project_name
79         value: "osm_admin"
80       - name: sync
81         value: "true"
82       ## Root folder of the cloned Fleet repo - Do not touch
83       - name: cloned_fleet_folder_name
84         value: "fleet-osm"
85       # Debug?
86       - name: debug
87         value: "false"
88     container:
89       image: ttl.sh/osm-krm-functions:24h
90       # imagePullPolicy: Always
91       env:
92       - name: SECRET_VALUES
93         valueFrom:
94           secretKeyRef:
95             name: "{{inputs.parameters.reference_secret_for_values}}"
96             key: "{{inputs.parameters.reference_key_for_values}}"
97             optional: true
98           default: ""
99       - name: DEBUG
100         value: "{{inputs.parameters.debug}}"
101       command: ["/app/scripts/entrypoint.sh"]
102       args:
103         - create_hr_ksu_into_profile
104         - "{{inputs.parameters.sw_catalogs_mount_path}}/{{inputs.parameters.cloned_sw_catalogs_folder_name}}/{{inputs.parameters.templates_path}}"
105         - "{{inputs.parameters.substitute_environment}}"
106         - "{{inputs.parameters.substitution_filter}}"
107         - "{{inputs.parameters.custom_env_vars}}"
108         - "{{inputs.parameters.kustomization_name}}"
109         - "{{inputs.parameters.helmrelease_name}}"
110         - "{{inputs.parameters.inline_values}}"
111         - "{{inputs.parameters.is_preexisting_secret}}"
112         - "{{inputs.parameters.target_ns}}"
113         - "{{inputs.parameters.values_secret_name}}"
114         - "{{inputs.parameters.secret_key}}"
115         - "{{inputs.parameters.age_public_key}}"
116         - ''
117         - "{{inputs.parameters.is_preexisting_cm}}"
118         - "{{inputs.parameters.values_cm_name}}"
119         - "{{inputs.parameters.cm_key}}"
120         - "{{inputs.parameters.cm_values}}"
121         - "{{inputs.parameters.ksu_name}}"
122         - "{{inputs.parameters.profile_name}}"
123         - "{{inputs.parameters.profile_type}}"
124         - "{{inputs.parameters.project_name}}"
125         - "{{inputs.parameters.fleet_mount_path}}/{{inputs.parameters.cloned_fleet_folder_name}}"
126         - "{{inputs.parameters.sync}}"
127       volumeMounts:
128       - name: fleet-volume
129         mountPath: '{{inputs.parameters.fleet_mount_path}}'
130       - name: sw-catalogs-repo-volume
131         mountPath: '{{inputs.parameters.sw_catalogs_mount_path}}'
132     volumes:
133       - name: fleet-volume
134         persistentVolumeClaim:
135           claimName: '{{inputs.parameters.fleet_volume_name}}'
136       - name: sw-catalogs-repo-volume
137         persistentVolumeClaim:
138           claimName: '{{inputs.parameters.sw_catalogs_volume_name}}'
139     securityContext:
140       fsGroup: 10000
141     #   runAsUser: 10000
142     #   runAsGroup: 10000
143
144
145 # Update a KSU based on an OKA Package which includes a `HelmRelease`
146   - name: update-ksu-oka-hr
147     inputs:
148       parameters:
149       # References to required external resources
150       - name: fleet_volume_name
151       - name: fleet_mount_path
152         value: "/fleet"
153       - name: sw_catalogs_volume_name
154       - name: sw_catalogs_mount_path
155         value: "/sw-catalogs"
156       # Specific parameters - Base KSU generation from template
157       - name: templates_path
158       ## Should substitute environment variables in the template?
159       - name: substitute_environment
160         value: "false"
161       ## Filter for substitution of environment variables
162       - name: substitution_filter
163         value: ""
164       ## Custom environment variables (formatted as .env), to be used for template parametrization
165       - name: custom_env_vars
166         value: ""
167       ## Root folder of the cloned SW Catalogs repo - Do not touch
168       - name: cloned_sw_catalogs_folder_name
169         value: "sw-catalogs-osm"
170       # Specific parameters - Patch HelmRelease in KSU with inline values
171       - name: kustomization_name
172       - name: helmrelease_name
173       - name: inline_values
174         value: ""
175       # Specific parameters - Secret generation
176       - name: is_preexisting_secret
177         value: "false"
178       - name: target_ns
179       - name: age_public_key
180       - name: values_secret_name
181       - name: reference_secret_for_values
182       - name: reference_key_for_values
183       - name: secret_key
184         value: "values.yaml"
185       # Specific parameters - Configmap generation
186       - name: is_preexisting_cm
187         value: "false"
188       - name: values_cm_name
189       - name: cm_key
190         value: "values.yaml"
191       - name: cm_values
192         value: ""
193       # Specific parameters - KSU rendering
194       - name: ksu_name
195       - name: profile_name
196       - name: profile_type
197       - name: project_name
198         value: "osm_admin"
199       ## Root folder of the cloned Fleet repo - Do not touch
200       - name: cloned_fleet_folder_name
201         value: "fleet-osm"
202       # Debug?
203       - name: debug
204         value: "false"
205     container:
206       image: ttl.sh/osm-krm-functions:24h
207       # imagePullPolicy: Always
208       env:
209       - name: SECRET_VALUES
210         valueFrom:
211           secretKeyRef:
212             name: "{{inputs.parameters.reference_secret_for_values}}"
213             key: "{{inputs.parameters.reference_key_for_values}}"
214             optional: true
215           default: ""
216       - name: DEBUG
217         value: "{{inputs.parameters.debug}}"
218       command: ["/app/scripts/entrypoint.sh"]
219       args:
220         - update_hr_ksu_into_profile
221         - "{{inputs.parameters.sw_catalogs_mount_path}}/{{inputs.parameters.cloned_sw_catalogs_folder_name}}/{{inputs.parameters.templates_path}}"
222         - "{{inputs.parameters.substitute_environment}}"
223         - "{{inputs.parameters.substitution_filter}}"
224         - "{{inputs.parameters.custom_env_vars}}"
225         - "{{inputs.parameters.kustomization_name}}"
226         - "{{inputs.parameters.helmrelease_name}}"
227         - "{{inputs.parameters.inline_values}}"
228         - "{{inputs.parameters.is_preexisting_secret}}"
229         - "{{inputs.parameters.target_ns}}"
230         - "{{inputs.parameters.values_secret_name}}"
231         - "{{inputs.parameters.secret_key}}"
232         - "{{inputs.parameters.age_public_key}}"
233         - ''
234         - "{{inputs.parameters.is_preexisting_cm}}"
235         - "{{inputs.parameters.values_cm_name}}"
236         - "{{inputs.parameters.cm_key}}"
237         - "{{inputs.parameters.cm_values}}"
238         - "{{inputs.parameters.ksu_name}}"
239         - "{{inputs.parameters.profile_name}}"
240         - "{{inputs.parameters.profile_type}}"
241         - "{{inputs.parameters.project_name}}"
242         - "{{inputs.parameters.fleet_mount_path}}/{{inputs.parameters.cloned_fleet_folder_name}}"
243       volumeMounts:
244       - name: fleet-volume
245         mountPath: '{{inputs.parameters.fleet_mount_path}}'
246       - name: sw-catalogs-repo-volume
247         mountPath: '{{inputs.parameters.sw_catalogs_mount_path}}'
248     volumes:
249       - name: fleet-volume
250         persistentVolumeClaim:
251           claimName: '{{inputs.parameters.fleet_volume_name}}'
252       - name: sw-catalogs-repo-volume
253         persistentVolumeClaim:
254           claimName: '{{inputs.parameters.sw_catalogs_volume_name}}'
255     securityContext:
256       fsGroup: 10000
257     #   runAsUser: 10000
258     #   runAsGroup: 10000
259
260
261 # Create a "generated" KSU from `HelmRelease` and Source Repo definitions
262   - name: create-ksu-generated-hr
263     inputs:
264       parameters:
265       # References to required external resources
266       - name: fleet_volume_name
267       - name: fleet_mount_path
268         value: "/fleet"
269       # HelmRelease generation
270       - name: helmrelease_name
271       - name: chart_name
272       - name: chart_version
273       - name: target_ns
274       - name: create_ns
275       # Repo source generation
276       - name: is_preexisting_repo
277         value: "false"
278       - name: helmrepo_name
279       - name: helmrepo_url
280       - name: helmrepo_ns
281         valueFrom:
282           expression: "{{input.parameters.target_ns}}"
283       - name: helmrepo_secret_ref
284       # HelmRelease inline values (if any)
285       - name: inline_values
286         value: ""
287       # Secret reference and generation (if required)
288       - name: is_preexisting_secret
289         value: "false"
290       - name: values_secret_name
291       - name: secret_key
292         value: "values.yaml"
293       - name: age_public_key
294       ## Secret values will be obtained from the
295       ## secret named after the input parameter `reference_secret_for_values`,
296       ## and from the key named after the input parameter `reference_key_for_values`
297       - name: reference_secret_for_values
298       - name: reference_key_for_values
299       # ConfigMap reference and generation (if required)
300       - name: is_preexisting_cm
301         value: "false"
302       - name: values_cm_name
303       - name: cm_key
304         value: "values.yaml"
305       - name: cm_values
306         value: ""
307       # KSU rendering
308       - name: ksu_name
309       - name: profile_name
310       - name: profile_type
311       - name: project_name
312         value: "osm_admin"
313       # By default, it will not syncronize, so that we can easily accumulate more than
314       # one Helm chart into the same KSU if desired
315       - name: sync
316         value: "false"
317       ## Root folder of the cloned Fleet repo - Do not touch
318       ### `FLEET_REPO_DIR` is the result of:
319       ### "{{inputs.parameters.fleet_mount_path}}/{{inputs.parameters.cloned_fleet_folder_name}}"
320       - name: cloned_fleet_folder_name
321         value: "fleet-osm"
322       # Debug?
323       - name: debug
324         value: "false"
325
326     container:
327       image: ttl.sh/osm-krm-functions:24h
328       # imagePullPolicy: Always
329       env:
330       - name: SECRET_VALUES
331         valueFrom:
332           secretKeyRef:
333             name: "{{inputs.parameters.reference_secret_for_values}}"
334             key: "{{inputs.parameters.reference_key_for_values}}"
335             optional: true
336           default: ""
337       - name: DEBUG
338         value: "{{inputs.parameters.debug}}"
339       command: ["/app/scripts/entrypoint.sh"]
340       args:
341       - create_generated_ksu_from_helm_into_profile
342       - "{{inputs.parameters.helmrelease_name}}"
343       - "{{inputs.parameters.chart_name}}"
344       - "{{inputs.parameters.chart_version}}"
345       - "{{inputs.parameters.target_ns}}"
346       - "{{inputs.parameters.create_ns}}"
347       - "{{inputs.parameters.is_preexisting_repo}}"
348       - "{{inputs.parameters.helmrepo_name}}"
349       - "{{inputs.parameters.helmrepo_url}}"
350       - "{{inputs.parameters.helmrepo_ns}}"
351       - "{{inputs.parameters.helmrepo_secret_ref}}"
352       - "{{inputs.parameters.inline_values}}"
353       - "{{inputs.parameters.is_preexisting_secret}}"
354       - "{{inputs.parameters.values_secret_name}}"
355       - "{{inputs.parameters.secret_key}}"
356       - "{{inputs.parameters.age_public_key}}"
357       - ''
358       - "{{inputs.parameters.is_preexisting_cm}}"
359       - "{{inputs.parameters.values_cm_name}}"
360       - "{{inputs.parameters.cm_key}}"
361       - "{{inputs.parameters.cm_values}}"
362       - "{{inputs.parameters.ksu_name}}"
363       - "{{inputs.parameters.profile_name}}"
364       - "{{inputs.parameters.profile_type}}"
365       - "{{inputs.parameters.project_name}}"
366       - "{{inputs.parameters.fleet_mount_path}}/{{inputs.parameters.cloned_fleet_folder_name}}"
367       - "{{inputs.parameters.sync}}"
368       volumeMounts:
369       - name: fleet-volume
370         mountPath: '{{inputs.parameters.fleet_mount_path}}'
371     volumes:
372       - name: fleet-volume
373         persistentVolumeClaim:
374           claimName: '{{inputs.parameters.fleet_volume_name}}'
375     securityContext:
376       fsGroup: 10000
377     #   runAsUser: 10000
378     #   runAsGroup: 10000
379
380
381 # Update a "generated" KSU from `HelmRelease` and Source Repo definitions
382   - name: update-ksu-generated-hr
383     inputs:
384       parameters:
385       # References to required external resources
386       - name: fleet_volume_name
387       - name: fleet_mount_path
388         value: "/fleet"
389       # HelmRelease generation
390       - name: helmrelease_name
391       - name: chart_name
392       - name: chart_version
393       - name: target_ns
394       - name: create_ns
395       # Repo source generation
396       - name: is_preexisting_repo
397         value: "false"
398       - name: helmrepo_name
399       - name: helmrepo_url
400       - name: helmrepo_ns
401         valueFrom:
402           expression: "{{input.parameters.target_ns}}"
403       - name: helmrepo_secret_ref
404       # HelmRelease inline values (if any)
405       - name: inline_values
406         value: ""
407       # Secret reference and generation (if required)
408       - name: is_preexisting_secret
409         value: "false"
410       - name: values_secret_name
411       - name: secret_key
412         value: "values.yaml"
413       - name: age_public_key
414       ## Secret values will be obtained from the
415       ## secret named after the input parameter `reference_secret_for_values`,
416       ## and from the key named after the input parameter `reference_key_for_values`
417       - name: reference_secret_for_values
418       - name: reference_key_for_values
419       # ConfigMap reference and generation (if required)
420       - name: is_preexisting_cm
421         value: "false"
422       - name: values_cm_name
423       - name: cm_key
424         value: "values.yaml"
425       - name: cm_values
426         value: ""
427       # KSU rendering
428       - name: ksu_name
429       - name: profile_name
430       - name: profile_type
431       - name: project_name
432         value: "osm_admin"
433       ## Root folder of the cloned Fleet repo - Do not touch
434       ### `FLEET_REPO_DIR` is the result of:
435       ### "{{inputs.parameters.fleet_mount_path}}/{{inputs.parameters.cloned_fleet_folder_name}}"
436       - name: cloned_fleet_folder_name
437         value: "fleet-osm"
438       # Debug?
439       - name: debug
440         value: "false"
441
442     container:
443       image: ttl.sh/osm-krm-functions:24h
444       # imagePullPolicy: Always
445       env:
446       - name: SECRET_VALUES
447         valueFrom:
448           secretKeyRef:
449             name: "{{inputs.parameters.reference_secret_for_values}}"
450             key: "{{inputs.parameters.reference_key_for_values}}"
451             optional: true
452           default: ""
453       - name: DEBUG
454         value: "{{inputs.parameters.debug}}"
455       command: ["/app/scripts/entrypoint.sh"]
456       args:
457       - update_generated_ksu_from_helm_into_profile
458       - "{{inputs.parameters.helmrelease_name}}"
459       - "{{inputs.parameters.chart_name}}"
460       - "{{inputs.parameters.chart_version}}"
461       - "{{inputs.parameters.target_ns}}"
462       - "{{inputs.parameters.create_ns}}"
463       - "{{inputs.parameters.is_preexisting_repo}}"
464       - "{{inputs.parameters.helmrepo_name}}"
465       - "{{inputs.parameters.helmrepo_url}}"
466       - "{{inputs.parameters.helmrepo_ns}}"
467       - "{{inputs.parameters.helmrepo_secret_ref}}"
468       - "{{inputs.parameters.inline_values}}"
469       - "{{inputs.parameters.is_preexisting_secret}}"
470       - "{{inputs.parameters.values_secret_name}}"
471       - "{{inputs.parameters.secret_key}}"
472       - "{{inputs.parameters.age_public_key}}"
473       - ''
474       - "{{inputs.parameters.is_preexisting_cm}}"
475       - "{{inputs.parameters.values_cm_name}}"
476       - "{{inputs.parameters.cm_key}}"
477       - "{{inputs.parameters.cm_values}}"
478       - "{{inputs.parameters.ksu_name}}"
479       - "{{inputs.parameters.profile_name}}"
480       - "{{inputs.parameters.profile_type}}"
481       - "{{inputs.parameters.project_name}}"
482       - "{{inputs.parameters.fleet_mount_path}}/{{inputs.parameters.cloned_fleet_folder_name}}"
483       volumeMounts:
484       - name: fleet-volume
485         mountPath: '{{inputs.parameters.fleet_mount_path}}'
486     volumes:
487       - name: fleet-volume
488         persistentVolumeClaim:
489           claimName: '{{inputs.parameters.fleet_volume_name}}'
490     securityContext:
491       fsGroup: 10000
492     #   runAsUser: 10000
493     #   runAsGroup: 10000
494
495
496 # Delete a KSU from a profile
497   - name: delete-ksu
498     inputs:
499       parameters:
500       # References to required external resources
501       - name: fleet_volume_name
502       - name: fleet_mount_path
503         value: "/fleet"
504       - name: sw_catalogs_volume_name
505       - name: sw_catalogs_mount_path
506         value: "/sw-catalogs"
507       # Specific parameters - KSU id
508       - name: ksu_name
509       - name: profile_name
510       - name: profile_type
511       - name: project_name
512         value: "osm_admin"
513       # Other parameters - Do not touch
514       - name: cloned_fleet_folder_name
515         value: "fleet-osm"
516       - name: cloned_sw_catalogs_folder_name
517         value: "sw-catalogs-osm"
518       # Debug?
519       - name: debug
520         value: "false"
521     container:
522       image: ttl.sh/osm-krm-functions:24h
523       # imagePullPolicy: Always
524       env:
525       - name: DEBUG
526         value: "{{inputs.parameters.debug}}"
527       command: ["/app/scripts/entrypoint.sh"]
528       args:
529         - delete_ksu_from_profile
530         - "{{inputs.parameters.ksu_name}}"
531         - "{{inputs.parameters.profile_name}}"
532         - "{{inputs.parameters.profile_type}}"
533         - "{{inputs.parameters.project_name}}"
534         - "{{inputs.parameters.fleet_mount_path}}/{{inputs.parameters.cloned_fleet_folder_name}}"
535       volumeMounts:
536       - name: fleet-volume
537         mountPath: '{{inputs.parameters.fleet_mount_path}}'
538       - name: sw-catalogs-repo-volume
539         mountPath: '{{inputs.parameters.sw_catalogs_mount_path}}'
540     volumes:
541       - name: fleet-volume
542         persistentVolumeClaim:
543           claimName: '{{inputs.parameters.fleet_volume_name}}'
544       - name: sw-catalogs-repo-volume
545         persistentVolumeClaim:
546           claimName: '{{inputs.parameters.sw_catalogs_volume_name}}'
547     securityContext:
548       fsGroup: 10000
549     #   runAsUser: 10000
550     #   runAsGroup: 10000
551
552
553 # Clone a KSU from a profile to another
554   - name: clone-ksu
555     inputs:
556       parameters:
557       # References to required external resources
558       - name: fleet_volume_name
559       - name: fleet_mount_path
560         value: "/fleet"
561       # Specific parameters - Source and destination KSU
562       ## Source KSU:
563       - name: source_ksu_name
564       - name: source_profile_name
565       - name: source_profile_type
566       - name: source_project_name
567         value: "osm_admin"
568       ## Destination KSU:
569       ## - If any of the destination parameters are not specified, it will assume
570       ##   they are the same as in source.
571       ## - It will reject if all are empty or equal to source, to avoid cloning a KSU over itself
572       - name: destination_ksu_name
573         value: ""
574       - name: destination_profile_name
575         value: ""
576       - name: destination_profile_type
577         value: ""
578       - name: destination_project_name
579         value: ""
580       # Other parameters - Do not touch
581       - name: cloned_fleet_folder_name
582         value: "fleet-osm"
583       # Debug?
584       - name: debug
585         value: "false"
586     container:
587       image: ttl.sh/osm-krm-functions:24h
588       # imagePullPolicy: Always
589       env:
590       - name: DEBUG
591         value: "{{inputs.parameters.debug}}"
592       command: ["/app/scripts/entrypoint.sh"]
593       args:
594       - clone_ksu
595       - "{{inputs.parameters.source_ksu_name}}"
596       - "{{inputs.parameters.source_profile_name}}"
597       - "{{inputs.parameters.source_profile_type}}"
598       - "{{inputs.parameters.source_project_name}}"
599       - "{{inputs.parameters.destination_ksu_name}}"
600       - "{{inputs.parameters.destination_profile_name}}"
601       - "{{inputs.parameters.destination_profile_type}}"
602       - "{{inputs.parameters.destination_project_name}}"
603       - "{{inputs.parameters.fleet_mount_path}}/{{inputs.parameters.cloned_fleet_folder_name}}"
604       volumeMounts:
605       - name: fleet-volume
606         mountPath: '{{inputs.parameters.fleet_mount_path}}'
607     volumes:
608       - name: fleet-volume
609         persistentVolumeClaim:
610           claimName: '{{inputs.parameters.fleet_volume_name}}'
611     securityContext:
612       fsGroup: 10000
613     #   runAsUser: 10000
614     #   runAsGroup: 10000
615
616
617   # Read template folder from OKA Package and convert to `ResourceList`
618   # It can work as KRM generator function, since it accepts an optional input `ResourceList`
619   - name: folder2list
620     inputs:
621       parameters:
622       # References to required external resources
623       - name: sw_catalogs_volume_name
624       - name: temp_volume_name
625       # Filename for input stream
626       - name: input_stream_file
627         value: "/dev/null"
628       # Specific parameters
629       ## Relative path from `sw_catalogs_mount_path`
630       - name: templates_path
631       ## Should substitute environment variables in the template?
632       - name: substitute_environment
633         value: "false"
634       ## Filter for substitution of environment variables
635       - name: substitution_filter
636         value: ""
637       ## Custom environment variables (formatted as .env), to be used for template parametrization
638       - name: custom_env_vars
639         value: ""
640         # value: |
641         #     KEY1=value1
642         #     KEY2=value2
643       # Debug mode?
644       - name: debug
645         value: "false"
646       # Other parameters - Do not touch
647       - name: sw_catalogs_mount_path
648         value: "/sw-catalogs"
649       - name: cloned_sw_catalogs_folder_name
650         value: "sw-catalogs-osm"
651       - name: rand_str
652         value: "{{=sprig.randAlphaNum(9)}}"
653     outputs:
654       parameters:
655         - name: output_file
656           value: "/results/resourcelist.{{inputs.parameters.rand_str}}.yaml"
657     container:
658       image: ttl.sh/osm-krm-functions:24h
659       # imagePullPolicy: Always
660       env:
661       - name: INFILE
662         value: "{{inputs.parameters.input_stream_file}}"
663       - name: OUTFILE
664         value: "/results/resourcelist.{{inputs.parameters.rand_str}}.yaml"
665       - name: CUSTOM_ENV
666         value: "{{inputs.parameters.custom_env_vars}}"
667       - name: DEBUG
668         value: "{{inputs.parameters.debug}}"
669       command: ["/app/scripts/entrypoint.sh"]
670       args:
671       - folder2list_generator
672       - "{{inputs.parameters.sw_catalogs_mount_path}}/{{inputs.parameters.cloned_sw_catalogs_folder_name}}/{{inputs.parameters.templates_path}}"
673       - "{{inputs.parameters.substitute_environment}}"
674       - "{{inputs.parameters.substitution_filter}}"
675       volumeMounts:
676       - name: temp-volume
677         mountPath: "/results"
678       - name: sw-catalogs-repo-volume
679         mountPath: '{{inputs.parameters.sw_catalogs_mount_path}}'
680     volumes:
681       - name: temp-volume
682         persistentVolumeClaim:
683           claimName: '{{inputs.parameters.temp_volume_name}}'
684       - name: sw-catalogs-repo-volume
685         persistentVolumeClaim:
686           claimName: '{{inputs.parameters.sw_catalogs_volume_name}}'
687     securityContext:
688       fsGroup: 10000
689     #   runAsUser: 10000
690     #   runAsGroup: 10000
691
692
693   # Transform `ResourceList`'s main Kustomization to patch `HelmRelease` to use
694   # inline values
695   - name: transform-ks-add-values-to-hr
696     inputs:
697       parameters:
698       # References to required external resources
699       - name: temp_volume_name
700       # Specific parameters - Generator
701       ## Filename for input stream
702       - name: input_stream_file
703       # Specific parameters
704       ## Patched objects
705       - name: kustomization_name
706       - name: helmrelease_name
707       ## Input values for the Helm Chart
708       - name: inline_values
709       # Debug mode?
710       - name: debug
711         value: "false"
712       # Other parameters - Do not touch
713       - name: rand_str
714         value: "{{=sprig.randAlphaNum(9)}}"
715     outputs:
716       parameters:
717         - name: output_file
718           value: "/results/resourcelist.{{inputs.parameters.rand_str}}.yaml"
719     container:
720       image: ttl.sh/osm-krm-functions:24h
721       # imagePullPolicy: Always
722       env:
723       - name: INFILE
724         value: "{{inputs.parameters.input_stream_file}}"
725       - name: OUTFILE
726         value: "/results/resourcelist.{{inputs.parameters.rand_str}}.yaml"
727       - name: DEBUG
728         value: "{{inputs.parameters.debug}}"
729       command: ["/app/scripts/entrypoint.sh"]
730       args:
731       - add_values_to_helmrelease_via_ks
732       - "{{inputs.parameters.kustomization_name}}"
733       - "{{inputs.parameters.helmrelease_name}}"
734       - "{{inputs.parameters.inline_values}}"
735       volumeMounts:
736       - name: temp-volume
737         mountPath: "/results"
738     volumes:
739     - name: temp-volume
740       persistentVolumeClaim:
741         claimName: '{{inputs.parameters.temp_volume_name}}'
742     securityContext:
743       fsGroup: 10000
744       # runAsUser: 10000
745       # runAsGroup: 10000
746
747
748   # Transform `ResourceList`'s main Kustomization to patch `HelmRelease` to use
749   # values from a Secret, a ConfigMap or both.
750   - name: transform-ks-add-referenced-values-to-hr
751     inputs:
752       parameters:
753       # References to required external resources
754       - name: temp_volume_name
755       # Specific parameters - Generator
756       ## Filename for input stream
757       - name: input_stream_file
758       # Specific parameters
759       - name: kustomization_name
760       - name: helmrelease_name
761       ## Source for values (Secret, ConfigMap or both)
762       - name: values_secret_name
763         value: ""
764       - name: values_cm_name
765         value: ""
766       # Debug mode?
767       - name: debug
768         value: "false"
769       # Other parameters - Do not touch
770       - name: rand_str
771         value: "{{=sprig.randAlphaNum(9)}}"
772     outputs:
773       parameters:
774         - name: output_file
775           value: "/results/resourcelist.{{inputs.parameters.rand_str}}.yaml"
776     container:
777       image: ttl.sh/osm-krm-functions:24h
778       # imagePullPolicy: Always
779       env:
780       - name: INFILE
781         value: "{{inputs.parameters.input_stream_file}}"
782       - name: OUTFILE
783         value: "/results/resourcelist.{{inputs.parameters.rand_str}}.yaml"
784       - name: DEBUG
785         value: "{{inputs.parameters.debug}}"
786       command: ["/app/scripts/entrypoint.sh"]
787       args:
788       - add_ref_values_to_hr_via_ks
789       - "{{inputs.parameters.kustomization_name}}"
790       - "{{inputs.parameters.helmrelease_name}}"
791       - "{{inputs.parameters.values_secret_name}}"
792       - "{{inputs.parameters.values_cm_name}}"
793       volumeMounts:
794       - name: temp-volume
795         mountPath: "/results"
796     volumes:
797     - name: temp-volume
798       persistentVolumeClaim:
799         claimName: '{{inputs.parameters.temp_volume_name}}'
800     securityContext:
801       fsGroup: 10000
802       # runAsUser: 10000
803       # runAsGroup: 10000
804
805
806   # KRM function to render a ResourceList with a KSU into a target profile
807   - name: render-ksu-into-profile
808     inputs:
809       parameters:
810       # References to required external resources
811       - name: fleet_volume_name
812       - name: temp_volume_name
813       # Filename for input stream
814       - name: input_stream_file
815       # Specific parameters
816       - name: ksu_name
817       - name: profile_name
818       - name: profile_type
819       - name: project_name
820         value: "osm_admin"
821       ## Whether the target KSU folder will be fully re-created on render
822       - name: sync
823         value: "false"
824       # Debug mode?
825       - name: debug
826         value: "false"
827       # Other parameters - Do not touch
828       - name: fleet_mount_path
829         value: "/fleet"
830       - name: fleet_repo_dir
831         value: "/fleet/fleet-osm/"
832       - name: rand_str
833         value: "{{=sprig.randAlphaNum(9)}}"
834     outputs:
835       parameters:
836         - name: output_file
837           value: "/results/resourcelist.{{inputs.parameters.rand_str}}.yaml"
838     container:
839       image: ttl.sh/osm-krm-functions:24h
840       # imagePullPolicy: Always
841       env:
842       - name: INFILE
843         value: "{{inputs.parameters.input_stream_file}}"
844       - name: OUTFILE
845         value: "/results/resourcelist.{{inputs.parameters.rand_str}}.yaml"
846       - name: DEBUG
847         value: "{{inputs.parameters.debug}}"
848       command: ["/app/scripts/entrypoint.sh"]
849       args:
850       - render_ksu_into_profile
851       - "{{inputs.parameters.ksu_name}}"
852       - "{{inputs.parameters.profile_name}}"
853       - "{{inputs.parameters.profile_type}}"
854       - "{{inputs.parameters.project_name}}"
855       - "{{inputs.parameters.fleet_repo_dir}}"
856       - "{{inputs.parameters.sync}}"
857       volumeMounts:
858       - name: temp-volume
859         mountPath: "/results"
860       - name: fleet-volume
861         mountPath: '{{inputs.parameters.fleet_mount_path}}'
862     volumes:
863       - name: temp-volume
864         persistentVolumeClaim:
865           claimName: '{{inputs.parameters.temp_volume_name}}'
866       - name: fleet-volume
867         persistentVolumeClaim:
868           claimName: '{{inputs.parameters.fleet_volume_name}}'
869     securityContext:
870       fsGroup: 10000
871     #   runAsUser: 10000
872     #   runAsGroup: 10000
873
874
875   # KRM generator to create Secrets suitable to pass values to `HelmReleases`
876   - name: generator-secret-hr-values
877     inputs:
878       parameters:
879       # References to required external resources
880       - name: temp_volume_name
881       # Specific parameters - Generator
882       ## Filename for input stream
883       - name: input_stream_file
884         value: "/dev/null"
885       ## Name of final manifest filename into generated `ResourceList` object
886       - name: final_manifest_filename
887       # Specific parameters - Secret
888       - name: age_public_key
889       - name: values_secret_name
890       - name: target_ns
891       - name: reference_secret_for_values
892       - name: reference_key_for_values
893       - name: secret_key
894         value: "values.yaml"
895       # Debug mode?
896       - name: debug
897         value: "false"
898     outputs:
899       parameters:
900         - name: output_file
901           valueFrom:
902             parameter: '{{steps.generate-resourcelist.outputs.parameters.output_file}}'
903     steps:
904     - - name: build-manifest
905         templateRef:
906           name: ksu-management-wft
907           template: manifest-secret-hr-values
908         arguments:
909           parameters:
910           # References to required external resources
911           - name: temp_volume_name
912             value: "{{inputs.parameters.temp_volume_name}}"
913           # Specific parameters
914           - name: age_public_key
915             value: "{{inputs.parameters.age_public_key}}"
916           - name: values_secret_name
917             value: "{{inputs.parameters.values_secret_name}}"
918           - name: target_ns
919             value: "{{inputs.parameters.target_ns}}"
920           - name: reference_secret_for_values
921             value: "{{inputs.parameters.reference_secret_for_values}}"
922           - name: reference_key_for_values
923             value: "{{inputs.parameters.reference_key_for_values}}"
924           - name: secret_key
925             value: "{{inputs.parameters.secret_key}}"
926           # Debug?
927           - name: debug
928             value: "{{inputs.parameters.debug}}"
929     - - name: generate-resourcelist
930         templateRef:
931           name: ksu-management-wft
932           template: make-generator
933         arguments:
934           parameters:
935           # References to required external resources
936           - name: temp_volume_name
937             value: "{{inputs.parameters.temp_volume_name}}"
938           # Filename for input stream
939           - name: input_stream_file
940             value: "{{inputs.parameters.input_stream_file}}"
941           # File with raw manifest
942           - name: input_manifest_file
943             value: '{{steps.build-manifest.outputs.parameters.output_file}}'
944           # Name of final manifest filename into generated `ResourceList` object
945           - name: final_manifest_filename
946             value: "{{inputs.parameters.final_manifest_filename}}"
947           # Debug?
948           - name: debug
949             value: "{{inputs.parameters.debug}}"
950
951
952   # KRM generator to create ConfigMaps suitable to pass values to `HelmReleases`
953   - name: generator-cm-hr-values
954     inputs:
955       parameters:
956       # References to required external resources
957       - name: temp_volume_name
958       # Specific parameters - Generator
959       ## Filename for input stream
960       - name: input_stream_file
961         value: "/dev/null"
962       ## Name of final manifest filename into generated `ResourceList` object
963       - name: final_manifest_filename
964       # Specific parameters - ConfigMap
965       - name: values_cm_name
966       - name: target_ns
967       - name: cm_key
968         value: "values.yaml"
969       - name: cm_values
970       # Debug mode?
971       - name: debug
972         value: "false"
973     outputs:
974       parameters:
975         - name: output_file
976           valueFrom:
977             parameter: '{{steps.generate-resourcelist.outputs.parameters.output_file}}'
978     steps:
979     - - name: build-manifest
980         templateRef:
981           name: ksu-management-wft
982           template: manifest-cm-hr-values
983         arguments:
984           parameters:
985           # References to required external resources
986           - name: temp_volume_name
987             value: "{{inputs.parameters.temp_volume_name}}"
988           # Specific parameters
989           - name: values_cm_name
990             value: "{{inputs.parameters.values_cm_name}}"
991           - name: target_ns
992             value: "{{inputs.parameters.target_ns}}"
993           - name: cm_key
994             value: "{{inputs.parameters.cm_key}}"
995           - name: cm_values
996             value: "{{inputs.parameters.cm_values}}"
997           # Debug?
998           - name: debug
999             value: "{{inputs.parameters.debug}}"
1000     - - name: generate-resourcelist
1001         templateRef:
1002           name: ksu-management-wft
1003           template: make-generator
1004         arguments:
1005           parameters:
1006           # References to required external resources
1007           - name: temp_volume_name
1008             value: "{{inputs.parameters.temp_volume_name}}"
1009           # Filename for input stream
1010           - name: input_stream_file
1011             value: "{{inputs.parameters.input_stream_file}}"
1012           # File with raw manifest
1013           - name: input_manifest_file
1014             value: '{{steps.build-manifest.outputs.parameters.output_file}}'
1015           # Name of final manifest filename into generated `ResourceList` object
1016           - name: final_manifest_filename
1017             value: "{{inputs.parameters.final_manifest_filename}}"
1018           # Debug?
1019           - name: debug
1020             value: "{{inputs.parameters.debug}}"
1021
1022
1023   # Converts a manifest to a KRM generator
1024   - name: make-generator
1025     inputs:
1026       parameters:
1027       # References to required external resources
1028       - name: temp_volume_name
1029       # Filename for input stream
1030       - name: input_stream_file
1031         value: "/dev/null"
1032       # File with raw manifest
1033       - name: input_manifest_file
1034       # Name of final manifest filename into generated `ResourceList` object
1035       - name: final_manifest_filename
1036       # Debug mode?
1037       - name: debug
1038         value: "false"
1039       # Other parameters - Do not touch
1040       - name: rand_str
1041         value: "{{=sprig.randAlphaNum(9)}}"
1042     outputs:
1043       parameters:
1044         - name: output_file
1045           value: "/results/resourcelist.{{inputs.parameters.rand_str}}.yaml"
1046     container:
1047       image: ttl.sh/osm-krm-functions:24h
1048       # imagePullPolicy: Always
1049       env:
1050       - name: INFILE
1051         value: "{{inputs.parameters.input_stream_file}}"
1052       - name: OUTFILE
1053         value: "/results/resourcelist.{{inputs.parameters.rand_str}}.yaml"
1054       - name: DEBUG
1055         value: "{{inputs.parameters.debug}}"
1056       command: ["/app/scripts/entrypoint.sh"]
1057       args:
1058       - make_generator
1059       - "{{inputs.parameters.final_manifest_filename}}"
1060       - cat
1061       - "{{inputs.parameters.input_manifest_file}}"
1062       volumeMounts:
1063       - name: temp-volume
1064         mountPath: "/results"
1065     volumes:
1066     - name: temp-volume
1067       persistentVolumeClaim:
1068         claimName: '{{inputs.parameters.temp_volume_name}}'
1069     securityContext:
1070       fsGroup: 10000
1071       # runAsUser: 10000
1072       # runAsGroup: 10000
1073
1074
1075   # Produces a secret manifest and encrypts it with SOPS
1076   - name: manifest-secret-hr-values
1077     inputs:
1078       parameters:
1079       # References to required external resources
1080       - name: temp_volume_name
1081       # Public age key to encrypt secret
1082       - name: age_public_key
1083       # Name of the secret to be created
1084       - name: values_secret_name
1085       # Namespace for the secret
1086       - name: target_ns
1087       # Input secret that contains the values to embed into the new secret
1088       - name: reference_secret_for_values
1089       - name: reference_key_for_values
1090         value: "values.yaml"
1091       # Key in the new secret where the values will be inserted
1092       - name: secret_key
1093         value: "values.yaml"
1094       # Debug mode?
1095       - name: debug
1096         value: "false"
1097       # Other parameters - Do not touch
1098       - name: rand_str
1099         value: "{{=sprig.randAlphaNum(9)}}"
1100     outputs:
1101       parameters:
1102         - name: output_file
1103           value: "/results/manifest.{{inputs.parameters.rand_str}}.yaml"
1104     container:
1105       image: ttl.sh/osm-krm-functions:24h
1106       # imagePullPolicy: Always
1107       env:
1108       - name: INSTREAM
1109         valueFrom:
1110           secretKeyRef:
1111             name: "{{inputs.parameters.reference_secret_for_values}}"
1112             key: "{{inputs.parameters.reference_key_for_values}}"
1113       - name: OUTFILE
1114         value: "/results/manifest.{{inputs.parameters.rand_str}}.yaml"
1115       - name: DEBUG
1116         value: "{{inputs.parameters.debug}}"
1117       command: ["/app/scripts/entrypoint.sh"]
1118       args:
1119         - kubectl_encrypt
1120         - "{{inputs.parameters.age_public_key}}"
1121         - create
1122         - secret
1123         - generic
1124         - "{{inputs.parameters.values_secret_name}}"
1125         - --namespace={{inputs.parameters.target_ns}}
1126         - --from-file={{inputs.parameters.secret_key}}=/dev/stdin
1127         - -o=yaml
1128         - --dry-run=client
1129       volumeMounts:
1130       - name: temp-volume
1131         mountPath: "/results"
1132     volumes:
1133     - name: temp-volume
1134       persistentVolumeClaim:
1135         claimName: '{{inputs.parameters.temp_volume_name}}'
1136     securityContext:
1137       fsGroup: 10000
1138     # runAsUser: 10000
1139     # runAsGroup: 10000
1140
1141
1142   # Produces a ConfigMap manifest
1143   - name: manifest-cm-hr-values
1144     inputs:
1145       parameters:
1146       # References to required external resources
1147       - name: temp_volume_name
1148       # Specific parameters
1149       - name: values_cm_name
1150       - name: target_ns
1151       - name: cm_key
1152         value: "values.yaml"
1153       - name: cm_values
1154       # Debug mode?
1155       - name: debug
1156         value: "false"
1157       # Other parameters - Do not touch
1158       - name: rand_str
1159         value: "{{=sprig.randAlphaNum(9)}}"
1160     outputs:
1161       parameters:
1162         - name: output_file
1163           value: "/results/manifest.{{inputs.parameters.rand_str}}.yaml"
1164     container:
1165       image: ttl.sh/osm-krm-functions:24h
1166       # imagePullPolicy: Always
1167       env:
1168       - name: INSTREAM
1169         value: "{{inputs.parameters.cm_values}}"
1170       - name: OUTFILE
1171         value: "/results/manifest.{{inputs.parameters.rand_str}}.yaml"
1172       - name: DEBUG
1173         value: "{{inputs.parameters.debug}}"
1174       command: ["/app/scripts/entrypoint.sh"]
1175       args:
1176         - kubectl
1177         - create
1178         - configmap
1179         - "{{inputs.parameters.values_cm_name}}"
1180         - --namespace={{inputs.parameters.target_ns}}
1181         - --from-file={{inputs.parameters.cm_key}}=/dev/stdin
1182         - -o=yaml
1183         - --dry-run=client
1184       volumeMounts:
1185       - name: temp-volume
1186         mountPath: "/results"
1187     volumes:
1188     - name: temp-volume
1189       persistentVolumeClaim:
1190         claimName: '{{inputs.parameters.temp_volume_name}}'
1191     securityContext:
1192       fsGroup: 10000
1193     # runAsUser: 10000
1194     # runAsGroup: 10000