sigs.k8s.io/cluster-api-provider-azure@v1.17.0/docs/book/src/topics/clusterclass.md (about)

     1  # ClusterClass
     2  
     3  - **Feature status:** Experimental
     4  - **Feature gate:** `ClusterTopology=true`
     5  
     6  [ClusterClass](https://cluster-api.sigs.k8s.io/tasks/experimental-features/cluster-class/index.html) is a collection of templates that define a topology (control plane and machine deployments) to be used to continuously reconcile one or more Clusters. It is built on top of the existing Cluster API resources and provides a set of tools and operations to streamline cluster lifecycle management while maintaining the same underlying API.
     7  
     8  CAPZ currently supports ClusterClass for both managed (AKS) and self-managed clusters. CAPZ implements this with four custom resources:
     9  1. AzureClusterTemplate
    10  2. AzureManagedClusterTemplate
    11  3. AzureManagedControlPlaneTemplate
    12  4. AzureManagedMachinePoolTemplate
    13  
    14  Each resource is a template for the corresponding CAPZ resource. For example, the AzureClusterTemplate is a template for the CAPZ AzureCluster resource. The template contains a set of parameters that are able to be shared across multiple clusters.
    15  
    16  ## Deploying a Self-Managed Cluster with ClusterClass
    17  
    18  Users must first create a ClusterClass resource to deploy a self-managed cluster with ClusterClass. The ClusterClass resource defines the cluster topology, including the control plane and machine deployment templates. The ClusterClass resource also defines the parameters that can be used to customize the cluster topology. 
    19  
    20  Please refer to the Cluster API book for more information on how to write a ClusterClass topology: https://cluster-api.sigs.k8s.io/tasks/experimental-features/cluster-class/write-clusterclass.html
    21  
    22  For a self-managed cluster, the AzureClusterTemplate defines the Azure infrastructure for the cluster. The following example shows a basic AzureClusterTemplate resource:
    23  
    24  ```yaml
    25  apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    26  kind: AzureClusterTemplate
    27  metadata:
    28    name: capz-clusterclass-cluster
    29    namespace: default
    30  spec:
    31    template:
    32      spec:
    33        location: westus2
    34        networkSpec:
    35          subnets:
    36          - name: control-plane-subnet
    37            role: control-plane
    38          - name: node-subnet
    39            natGateway:
    40              name: node-natgateway
    41            role: node
    42        subscriptionID: 00000000-0000-0000-0000-000000000000
    43  ```
    44  
    45  ## Deploying a Managed Cluster (AKS) with ClusterClass
    46  
    47  **Feature gate:** `MachinePool=true`
    48  
    49  Deploying an AKS cluster with ClusterClass is similar to deploying a self-managed cluster. However, both an AzureManagedClusterTemplate and AzureManagedControlPlaneTemplate must be used instead of the AzureClusterTemplate. Due to the nature of managed Kubernetes and the control plane implementation, the infrastructure provider (and therefore the AzureManagedClusterTemplate) for AKS cluster is basically a no-op. The AzureManagedControlPlaneTemplate is used to define the AKS cluster configuration, such as the Kubernetes version and the number of nodes. Finally, the AzureManagedMachinePoolTemplate defines the worker nodes (agentpools) for the AKS cluster.
    50  
    51  <aside class="note warning">
    52  
    53  <h1> Warning </h1>
    54  
    55  The field `virtualNetwork.Name` should not be set in the AzureManagedControlPlaneTemplate. Setting this field will result in an error with conflicting vnet names when creating multiple clusters with one template. To prevent a breaking API change, this field is not removed from the API, but it should not be used.
    56  
    57  </aside>
    58  
    59  The following example shows a basic AzureManagedClusterTemplate, AzureManagedControlPlaneTemplate, and AzureManagedMachinePoolTemplate resource:
    60  
    61  ```yaml
    62  apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    63  kind: AzureManagedClusterTemplate
    64  metadata:
    65    name: capz-clusterclass-cluster
    66  ---
    67  apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    68  kind: AzureManagedControlPlaneTemplate
    69  metadata:
    70    name: capz-clusterclass-control-plane
    71  spec:
    72    location: westus2
    73    subscriptionID: 00000000-0000-0000-0000-000000000000
    74    version: 1.25.2
    75  ---
    76  apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    77  kind: AzureManagedMachinePoolTemplate
    78  metadata:
    79    name: capz-clusterclass-pool0
    80    namespace: default
    81  spec:
    82    template:
    83      spec:
    84        mode: System
    85        name: pool0
    86        sku: Standard_D2s_v3
    87  ```