請參閱此範例,佈建具有自訂設定的 v1beta1 叢集。

v1beta1 範例:以預設 ClusterClass 為基礎的自訂叢集

以下範例 YAML 示範了如何使用 v1beta1 API 透過變數佈建具有多個自訂設定的叢集。此範例根據 v1beta1 範例:預設叢集而建置。

此範例使用變數來控制頻繁變換的元件 (例如 containerd 和 kubelet) 的 worker 節點上的持續性磁碟區。此外, vmClass 變數會宣告兩次。在 workers.machineDeployments 中宣告的 vmClass 變數將覆寫全域宣告的 vmClass 變數,以便使用大型虛擬機器類別佈建 worker 節點。
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
  name: cluster-custom
  namespace: tkg-cluster-ns
spec:
  clusterNetwork:
    services:
      cidrBlocks: ["198.51.100.0/12"]
    pods:
      cidrBlocks: ["192.2.0.0/16"]
    serviceDomain: "cluster.local"
  topology:
    class: tanzukubernetescluster
    version: v1.25.7---vmware.3-fips.1-tkg.1
    controlPlane:
      replicas: 3
    workers:
      machineDeployments:
        - class: node-pool
          name: node-pool-1
          replicas: 3
          variables:
            overrides:
            - name: vmClass
              value: guaranteed-xlarge
    variables:
      - name: vmClass
        value: guaranteed-medium
      - name: storageClass
        value: tkg-storage-profile
      - name: defaultStorageClass
        value: tkg-storage-profile
      - name: nodePoolVolumes
        value:
          - name: containerd
            capacity:
              storage: 50Gi
            mountPath: /var/lib/containerd
            storageClass: tkg-storage-profile
          - name: kubelet
            capacity:
              storage: 50Gi
            mountPath: /var/lib/kubelet
            storageClass: tkg-storage-profile