711cf4d662b25478fd06bd4c0a09868888bca0d3
[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-aks-cluster-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 - AKS cluster
39     - name: cluster_name
40     - name: vm_size
41     - name: node_count
42     - name: cluster_location
43     - name: rg_name
44     - name: k8s_version
45     - name: providerconfig_name
46     - name: cluster_kustomization_name
47
48     # Debugging
49     - name: dry_run
50       value: false
51
52
53   # # Cleanup policy
54   # ttlStrategy:
55   #   secondsAfterCompletion: 100 # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
56   #   secondsAfterSuccess: 50     # Time to live after workflow is successful
57   #   secondsAfterFailure: 50     # Time to live after workflow fails
58
59   entrypoint: update-aks-cluster
60
61   templates:
62
63   # Main template
64   - name: update-aks-cluster
65     inputs:
66       parameters:
67       # Git repos
68       - name: git_fleet_url
69       - name: fleet_destination_folder
70       - name: git_fleet_cred_secret
71       - name: git_sw_catalogs_url
72       - name: sw_catalogs_destination_folder
73       - name: git_sw_catalogs_cred_secret
74
75       # Specific parameters - AKS cluster
76       - name: cluster_name
77       - name: vm_size
78       - name: node_count
79       - name: cluster_location
80       - name: rg_name
81       - name: k8s_version
82       - name: providerconfig_name
83       - name: cluster_kustomization_name
84
85       # Debugging
86       - name: dry_run
87     steps:
88
89     # ------ Preparations for transaction
90     - - name: generate-fleet-volume-repo
91         templateRef:
92           name: k8s-resources-wft
93           template: generate-volume
94         arguments:
95           parameters:
96             - name: pvc-size
97               value: '100Mi'
98       - name: generate-sw-catalogs-volume-repo
99         templateRef:
100           name: k8s-resources-wft
101           template: generate-volume
102         arguments:
103           parameters:
104             - name: pvc-size
105               value: '100Mi'
106     - - name: clone-fleet
107         templateRef:
108           name: git-wft
109           template: git-clone
110         arguments:
111           parameters:
112           - name: mount_path
113             value: "/fleet"
114           - name: repo_url
115             value: "{{inputs.parameters.git_fleet_url}}"
116           - name: destination_folder
117             value: "{{inputs.parameters.fleet_destination_folder}}"
118           - name: git_cred_secret
119             value: "{{inputs.parameters.git_fleet_cred_secret}}"
120           - name: git_volume_name
121             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
122       - name: clone-sw-catalogs
123         templateRef:
124           name: git-wft
125           template: git-clone
126         arguments:
127           parameters:
128           - name: mount_path
129             value: "/sw-catalogs"
130           - name: repo_url
131             value: "{{inputs.parameters.git_sw_catalogs_url}}"
132           - name: destination_folder
133             value: "{{inputs.parameters.sw_catalogs_destination_folder}}"
134           - name: git_cred_secret
135             value: "{{inputs.parameters.git_sw_catalogs_cred_secret}}"
136           - name: git_volume_name
137             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
138     # ------ end of preparations for transaction
139
140     # ------ Transformations
141     # Update cluster definition
142     - - name: update-cluster-aks
143         templateRef:
144           name: cluster-management-wft
145           template: create-cluster-aks
146         arguments:
147           parameters:
148           # Volumes with cloned repos
149           - name: fleet_volume_name
150             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
151           - name: fleet_mount_path
152             value: "/fleet"
153           - name: sw_catalogs_volume_name
154             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
155           - name: sw_catalogs_mount_path
156             value: "/sw-catalogs"
157           # Specific parameters
158           - name: cluster_name
159             value: "{{inputs.parameters.cluster_name}}"
160           - name: vm_size
161             value: "{{inputs.parameters.vm_size}}"
162           - name: node_count
163             value: "{{inputs.parameters.node_count}}"
164           - name: cluster_location
165             value: "{{inputs.parameters.cluster_location}}"
166           - name: rg_name
167             value: "{{inputs.parameters.rg_name}}"
168           - name: k8s_version
169             value: "{{inputs.parameters.k8s_version}}"
170           - name: providerconfig_name
171             value: "{{inputs.parameters.providerconfig_name}}"
172           - name: cluster_kustomization_name
173             value: "{{inputs.parameters.cluster_kustomization_name}}"
174     # ------ end of transformations
175
176     # ------ Commit transaction
177     - - name: push-to-fleet
178         templateRef:
179           name: git-wft
180           template: git-commit-merge-push
181         arguments:
182           parameters:
183           - name: mount_path
184             value: "/fleet"
185           - name: repo_folder
186             value: "{{inputs.parameters.fleet_destination_folder}}"
187           - name: git_cred_secret
188             value: "{{inputs.parameters.git_fleet_cred_secret}}"
189           - name: git_volume_name
190             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
191           - name: commit_message
192             value: "Update AKS cluster {{inputs.parameters.cluster_kustomization_name}}"
193           - name: main_branch
194             value: main
195           - name: contrib_branch
196             value: osm_contrib
197           - name: dry_run
198             value: "{{inputs.parameters.dry_run}}"
199 # ------ end of commit transaction