请参阅此示例,置备具有自定义设置的 v1beta1 集群。

v1beta1 示例:自定义集群

以下示例 YAML 展示了如何使用 v1beta1 API 通过变量置备具有多个自定义设置的集群。此示例基于 v1beta1 示例:默认集群而构建。

该示例使用变量来控制频繁更改的组件(如 etcd、containerd 和 kubelet)的持久卷、控制平面和工作节点。此外,vmClass 变量声明两次。在 workers.machineDeployments 中声明的 vmClass 变量将覆盖全局声明的 vmClass 变量,以便为工作节点置备更大的虚拟机类。

apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
  name: cluster-custom
  namespace: tkg2-cluster-ns
spec:
  clusterNetwork:
    services:
      cidrBlocks: ["198.51.100.0/12"]
    pods:
      cidrBlocks: ["192.0.2.0/16"]
    serviceDomain: "cluster.local"
  topology:
    class: tanzukubernetescluster
    version: v1.23.8+vmware.1-tkg.2-zshippable
    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: tkg2-storage-profile
      - name: defaultStorageClass
        value: tkg2-storage-profile
      - name: controlPlaneVolumes
        value:
          - name: etcd
            capacity:
              storage: 4Gi
            mountPath: /var/lib/etcd
            storageClass: tkg2-storage-profile
      - name: nodePoolVolumes
        value:
          - name: containerd
            capacity:
              storage: 50Gi
            mountPath: /var/lib/containerd
            storageClass: tkg2-storage-profile
          - name: kubelet
            capacity:
              storage: 50Gi
            mountPath: /var/lib/kubelet
            storageClass: tkg2-storage-profile