Refer to this example to provision a v1beta1 Cluster with default settings.

v1beta1 Example: Default Cluster

The following example YAML uses the v1beta1 API to create a default Cluster based on the default ClusterClass.

This example represents the minimum configuration required to create a Cluster using the v1beta1 API. The example is annotated with descriptions of each field. For more information, refer to the source code.

Note the following about this example:
  • Unlike the v1alpha3 API, the v1beta1 API requires you to specify the clusterNetwork. There is no default network setting for the Cluster type.
  • The default ClusterClass is tanzukubernetescluster which is documented here: Cluster v1beta1 API.
  • You can customize the Cluster using variables, each of which is a name-value pair. At a minimum you must specify the VM and storage classes as variables, as shown in the example.
  • Although technically optional, the example also includes a defaultStorageClass variable because many workloads, including Tanzu Packages and Helm charts, require the cluster be provisioned with a default storage class.
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
#define the cluster
metadata:
  #user-defined name of the cluster; string
  name: cluster-default
  #kubernetes namespace for the cluster; string
  namespace: tkg-cluster-ns
#define the desired state of cluster
spec:
  #specify the cluster network; required, there is no default
  clusterNetwork:
    #network ranges from which service VIPs are allocated
    services:
      #ranges of network addresses; string array
      #CAUTION: must not overlap with Supervisor
      cidrBlocks: ["198.51.100.0/12"]
    #network ranges from which Pod networks are allocated
    pods:
      #ranges of network addresses; string array
      #CAUTION: must not overlap with Supervisor
      cidrBlocks: ["192.0.2.0/16"]
    #domain name for services; string
    serviceDomain: "cluster.local"
  #specify the topology for the cluster
  topology:
    #name of the ClusterClass object to derive the topology
    class: tanzukubernetescluster
    #kubernetes version of the cluster; format is TKR NAME
    version: v1.24.9---vmware.1-tkg.4
    #describe the cluster control plane
    controlPlane:
      #number of control plane nodes
      #integer value 1 or 3
      #NOTE: Production clusters require 3 control plane nodes
      replicas: 3
    #describe the cluster worker nodes
    workers:
      #specifies parameters for a set of worker nodes in the topology
      machineDeployments:
        #node pool class used to create the set of worker nodes
        - class: node-pool
          #user-defined name of the node pool; string
          name: node-pool-1
          #number of worker nodes in this pool; integer 0 or more
          replicas: 3
    #customize the cluster
    variables:
      #virtual machine class type and size for cluster nodes
      - name: vmClass
        value: guaranteed-medium
      #persistent storage class for cluster nodes
      - name: storageClass
        value: tkg-storage-policy
      # default storageclass for control plane and worker node pools
      - name: defaultStorageClass
        value: tkg-storage-policy