请参阅此示例,置备具有默认设置的 v1beta1 集群。
v1beta1 示例:默认集群
以下示例 YAML 使用 v1beta1 API 基于默认 ClusterClass 创建默认集群。
此示例表示使用 v1beta1 API 创建集群所需的最低配置。此示例针对每个字段添加了注释说明。有关详细信息,请参阅源代码。
请注意有关此示例的以下事项:
- 与 v1alpha3 API 不同,v1beta1 API 要求指定
clusterNetwork
。集群类型没有默认的网络设置。 - 默认 ClusterClass 为
tanzukubernetescluster
,详情请参见:集群 v1beta1 API。 - 可以使用
variables
自定义集群,每个变量都是一个名称-值对。必须至少将虚拟机类和存储类指定为变量,如此示例中所示。 - 尽管在技术上是可选操作,但该示例还包含一个
defaultStorageClass
变量,因为许多工作负载(包括 Tanzu 软件包和 Helm 图表)都要求使用默认存储类置备集群。
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.26.13---vmware.1-fips.1-tkg.3 #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