Skip to content

Collection of cluster specs leveraging ClusterClass

This post documents cluster specs that can be used to create Tanzu Kubernetes Cluster leveraging ClusterClass. This collection is intended to document specs that can be referenced to test cluster creation. These have been validated against Supervisor clusters enabled on vSphere 8.

Common variables used across the specs

Few helpful commands to derive the values mentioned below

  • kubectl get tkr - To get Tanzu Kubernetes Release version
  • kubectl get vmclass - To get available VM class i.e virtualmachineclasses.vmoperator.vmware.com
  • kubectl get sc - To get available storage class

To kick off cluster creation using the specs below use kubectl apply -f <filename>.yaml.

export CLUSTER_NAME="ubuntu-cc"
export CLUSTER_NAMESPACE="oom-ns"
export SERVICE_CIDR='172.31.0.0/16'
export POD_CIDR='172.30.0.0/16'
export TKR_VERSION="v1.23.8+vmware.2-tkg.2-zshippable"
export STORAGE_CLASS="vwt-storage-policy"
export VM_CLASS="best-effort-small"
export CONTROLPLANE_REPLICAS=1
export WORKER_REPLICAS=2

Cluster with two ubuntu node pools

cat <<EOF > ubuntu-classy-cluster.yaml
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
  name: $CLUSTER_NAME
  namespace: $CLUSTER_NAMESPACE
spec:
  clusterNetwork:
    services:
      cidrBlocks: ["$SERVICE_CIDR"]
    pods:
      cidrBlocks: ["$POD_CIDR"]
    serviceDomain: "cluster.local"
  topology:
    class: tanzukubernetescluster
    version: $TKR_VERSION
    controlPlane:
      metadata:
        annotations:
          run.tanzu.vmware.com/resolve-os-image: os-name=ubuntu
      replicas: $CONTROLPLANE_REPLICAS
    workers:
      # node pools
      machineDeployments:
        - class: node-pool
          name: ub-node-pool-1
          replicas: $WORKER_REPLICAS
          metadata:
            annotations:
              run.tanzu.vmware.com/resolve-os-image: os-name=ubuntu
        - class: node-pool
          name: ub-node-pool-2
          replicas: $WORKER_REPLICAS
          metadata:
            annotations:
              run.tanzu.vmware.com/resolve-os-image: os-name=ubuntu
    variables:
      - name: vmClass
        value: $VM_CLASS
      # default storageclass for control plane and node pool
      - name: storageClass
        value: $STORAGE_CLASS
EOF

Cluster with two photon node pools

cat <<EOF > photon-classy-cluster.yaml
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
  name: $CLUSTER_NAME
  namespace: $CLUSTER_NAMESPACE
spec:
  clusterNetwork:
    services:
      cidrBlocks: ["$SERVICE_CIDR"]
    pods:
      cidrBlocks: ["$POD_CIDR"]
    serviceDomain: "cluster.local"
  topology:
    class: tanzukubernetescluster
    version: $TKR_VERSION
    controlPlane:
      metadata:
      replicas: $CONTROLPLANE_REPLICAS
    workers:
      machineDeployments:
        - class: node-pool
          name: ph-node-pool-1
          replicas: $WORKER_REPLICAS
        - class: node-pool
          name: ph-node-pool-2
          replicas: $WORKER_REPLICAS
    variables:
      - name: vmClass
        value: $VM_CLASS
      - name: storageClass
        value: $STORAGE_CLASS
EOF

Cluster with both ubuntu and photon node pools

  • Ubuntu as control plane OS
  • One Ubuntu node pool
  • One Photon node pool
cat <<EOF > mixed-classy-cluster.yaml
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
  name: $CLUSTER_NAME
  namespace: $CLUSTER_NAMESPACE
spec:
  clusterNetwork:
    services:
      cidrBlocks: ["$SERVICE_CIDR"]
    pods:
      cidrBlocks: ["$POD_CIDR"]
    serviceDomain: "cluster.local"
  topology:
    class: tanzukubernetescluster
    version: $TKR_VERSION
    controlPlane:
      metadata:
        annotations:
          run.tanzu.vmware.com/resolve-os-image: os-name=ubuntu
      replicas: $CONTROLPLANE_REPLICAS
    workers:
      # node pools
      machineDeployments:
        - class: node-pool
          name: ub-node-pool
          replicas: $WORKER_REPLICAS
          metadata:
            annotations:
              run.tanzu.vmware.com/resolve-os-image: os-name=ubuntu
        - class: node-pool
          name: ph-node-pool
          replicas: $WORKER_REPLICAS
    variables:
      - name: vmClass
        value: $VM_CLASS
      - name: storageClass
        value: $STORAGE_CLASS
EOF