@@ -9,6 +9,7 @@ A managed Cluster can be used to:
9
9
* [ Add a MachineDeployment] ( #add-a-machinedeployment )
10
10
* [ Use variables in a Cluster] ( #use-variables )
11
11
* [ Rebase a Cluster to a different ClusterClass] ( #rebase-a-cluster )
12
+ * [ Upgrading Cluster API] ( #upgrading-cluster-api )
12
13
* [ Tips and tricks] ( #tips-and-tricks )
13
14
14
15
## Upgrade a Cluster
@@ -266,6 +267,104 @@ Please note that:
266
267
267
268
</aside >
268
269
270
+ # Upgrading Cluster API
271
+
272
+ There are some special considerations for ClusterClass regarding Cluster API upgrades when the upgrade includes a bump
273
+ of the apiVersion of infrastructure, bootstrap or control plane provider CRDs.
274
+
275
+ The recommended approach is to first upgrade Cluster API and then update the apiVersions in the ClusterClass references afterwards.
276
+ By following above steps, there won't be any disruptions of the reconciliation as the Cluster topology controller is able to reconcile the Cluster
277
+ even with the old apiVersions in the ClusterClass.
278
+
279
+ Note: The apiVersions in ClusterClass cannot be updated before Cluster API because the new apiVersions don't exist in
280
+ the management cluster before the Cluster API upgrade.
281
+
282
+ In general the Cluster topology controller always uses exactly the versions of the CRDs referenced in the ClusterClass.
283
+ This means in the following example the Cluster topology controller will always use ` v1beta1 ` when reconciling/applying
284
+ patches for the infrastructure ref, even if the ` DockerClusterTemplate ` already has a ` v1beta2 ` apiVersion.
285
+
286
+ ``` yaml
287
+ apiVersion : cluster.x-k8s.io/v1beta1
288
+ kind : ClusterClass
289
+ metadata :
290
+ name : quick-start
291
+ namespace : default
292
+ spec :
293
+ infrastructure :
294
+ ref :
295
+ apiVersion : infrastructure.cluster.x-k8s.io/v1beta1
296
+ kind : DockerClusterTemplate
297
+ ...
298
+ ```
299
+
300
+ <aside class =" note warning " >
301
+
302
+ <h1 >Bumping apiVersions in ClusterClass</h1 >
303
+
304
+ When upgrading the apiVersions in references in the ClusterClass the corresponding patches have to be changed accordingly.
305
+ This includes bumping the apiVersion in the patch selector and potentially updating the JSON patch to changes in the new
306
+ apiVersion of the referenced CRD. The following example shows how to upgrade the ClusterClass in this case.
307
+
308
+ ClusterClass with the old apiVersion:
309
+ ``` yaml
310
+ apiVersion : cluster.x-k8s.io/v1beta1
311
+ kind : ClusterClass
312
+ metadata :
313
+ name : quick-start
314
+ spec :
315
+ infrastructure :
316
+ ref :
317
+ apiVersion : infrastructure.cluster.x-k8s.io/v1beta1
318
+ kind : DockerClusterTemplate
319
+ ...
320
+ patches :
321
+ - name : lbImageRepository
322
+ definitions :
323
+ - selector :
324
+ apiVersion : infrastructure.cluster.x-k8s.io/v1beta1
325
+ kind : DockerClusterTemplate
326
+ matchResources :
327
+ infrastructureCluster : true
328
+ jsonPatches :
329
+ - op : add
330
+ path : " /spec/template/spec/loadBalancer/imageRepository"
331
+ valueFrom :
332
+ variable : lbImageRepository
333
+ ` ` `
334
+
335
+ ClusterClass with the new apiVersion:
336
+ ` ` ` yaml
337
+ apiVersion : cluster.x-k8s.io/v1beta1
338
+ kind : ClusterClass
339
+ metadata :
340
+ name : quick-start
341
+ spec :
342
+ infrastructure :
343
+ ref :
344
+ apiVersion : infrastructure.cluster.x-k8s.io/v1beta2 # apiVersion updated
345
+ kind : DockerClusterTemplate
346
+ ...
347
+ patches :
348
+ - name : lbImageRepository
349
+ definitions :
350
+ - selector :
351
+ apiVersion : infrastructure.cluster.x-k8s.io/v1beta2 # apiVersion updated
352
+ kind : DockerClusterTemplate
353
+ matchResources :
354
+ infrastructureCluster : true
355
+ jsonPatches :
356
+ - op : add
357
+ # Path has been updated, as in this example imageRepository has been renamed
358
+ # to imageRepo in v1beta2 of DockerClusterTemplate.
359
+ path : " /spec/template/spec/loadBalancer/imageRepo"
360
+ valueFrom :
361
+ variable : lbImageRepository
362
+ ` ` `
363
+
364
+ If external patches are used in the ClusterClass, it has to be ensured that all external patches support the new apiVersion
365
+ before bumping apiVersions.
366
+
367
+ </aside>
269
368
270
369
[Quick Start guide]: ../../../user/quick-start.md
271
370
[ClusterClass rebase]: ./change-clusterclass.md#rebase
0 commit comments