通过集群 v1beta1 API,您可以基于默认的 ClusterClass 定义置备集群。
ClusterClass API v1beta1
Kubernetes 集群 API 是一套用于提供 Kubernetes 集群的声明式置备、升级和操作的工具。ClusterClass 是集群 API 的升级版,可用于定义管理集群集生命周期的模板。主管 上的 TKG 2 通过 v1beta1 API 支持 ClusterClass。
主管 上的 TKG 2 附带一个名为 tanzukubernetescluster
的默认 ClusterClass 定义。tanzukubernetescluster
ClusterClass 为通过 v1beta API 在 主管 上创建 TKG 2 集群提供了一个模板。tanzukubernetescluster
ClusterClass 在所有用户命名空间中均可用。要基于此 ClusterClass 创建集群,请在集群规范中引用它。有关指导,请参阅 v1beta 示例。
默认的 ClusterClass tanzukubernetescluster
tanzukubernetescluster
ClusterClass 不可改变。此处,它仅作为参考提供。
apiVersion: cluster.x-k8s.io/v1beta1 kind: ClusterClass metadata: name: tanzukubernetescluster annotations: run.tanzu.vmware.com/resolve-tkr: "" spec: controlPlane: metadata: annotations: run.tanzu.vmware.com/resolve-os-image: os-name=photon ref: apiVersion: controlplane.cluster.x-k8s.io/v1beta1 kind: KubeadmControlPlaneTemplate name: "tkc-control-plane" machineInfrastructure: ref: kind: VSphereMachineTemplate apiVersion: vmware.infrastructure.cluster.x-k8s.io/v1beta1 name: "tkc-control-plane" machineHealthCheck: maxUnhealthy: 100% nodeStartupTimeout: 2h0m0s unhealthyConditions: - status: Unknown timeout: 5m0s type: Ready - status: "False" timeout: 12m0s type: Ready infrastructure: ref: apiVersion: vmware.infrastructure.cluster.x-k8s.io/v1beta1 kind: VSphereClusterTemplate name: "tkc-infrastructure" workers: machineDeployments: - class: node-pool template: metadata: annotations: run.tanzu.vmware.com/resolve-os-image: os-name=photon bootstrap: ref: kind: KubeadmConfigTemplate apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 name: "tkc-md" infrastructure: ref: kind: VSphereMachineTemplate apiVersion: vmware.infrastructure.cluster.x-k8s.io/v1beta1 name: "tkc-md" machineHealthCheck: maxUnhealthy: 100% nodeStartupTimeout: 2h0m0s unhealthyConditions: - status: Unknown timeout: 5m0s type: Ready - status: "False" timeout: 12m0s type: Ready variables: - name: TKR_DATA required: false schema: openAPIV3Schema: type: object additionalProperties: type: object properties: kubernetesSpec: type: object properties: version: type: string imageRepository: type: string etcd: type: object properties: imageTag: type: string coredns: type: object properties: imageTag: type: string osImageRef: type: object properties: name: type: string labels: type: object additionalProperties: type: string - name: vmClass required: true schema: openAPIV3Schema: type: string - name: storageClass required: true schema: openAPIV3Schema: type: string - name: storageClasses required: false schema: openAPIV3Schema: type: array items: type: string - name: defaultStorageClass required: false schema: openAPIV3Schema: type: string - name: extensionCert required: false schema: openAPIV3Schema: type: object properties: contentSecret: type: object properties: name: type: string key: type: string - name: clusterEncryptionConfigYaml required: false schema: openAPIV3Schema: type: string - name: defaultRegistrySecret required: false schema: openAPIV3Schema: type: object properties: namespace: type: string name: type: string data: type: string - name: ntp required: false schema: openAPIV3Schema: type: string - name: user required: false schema: openAPIV3Schema: type: object properties: passwordSecret: type: object properties: name: type: string key: type: string sshAuthorizedKey: type: string - name: nodePoolTaints required: false schema: openAPIV3Schema: type: array items: type: object properties: key: type: string value: type: string effect: type: string timeAdded: type: integer - name: nodePoolLabels required: false schema: openAPIV3Schema: type: array items: type: object properties: key: type: string value: type: string - name: proxy required: false schema: openAPIV3Schema: type: object properties: httpProxy: type: string httpsProxy: type: string noProxy: type: array items: type: string - name: trust required: false schema: openAPIV3Schema: type: object properties: additionalTrustedCAs: type: array items: type: object properties: name: type: string - name: controlPlaneVolumes required: false schema: openAPIV3Schema: type: array items: type: object properties: storageClass: type: string mountPath: type: string name: type: string capacity: type: object properties: storage: type: string - name: nodePoolVolumes required: false schema: openAPIV3Schema: type: array items: type: object properties: storageClass: type: string mountPath: type: string name: type: string capacity: type: object properties: storage: type: string
用于自定义集群的 ClusterClass 变量
您可以使用变量基于 tanzukubernetescluster
ClusterClass 自定义一个集群。变量使用名称-值对进行定义。语法必须符合 openAPIV3Schema 的要求。
- 虚拟机类
- 存储类
- 代理
- TLS 证书
- SSH 密钥
以下部分列出了默认 tanzukubernetescluster
ClusterClass 可用的所有变量。
clusterEncryptionConfigYaml
使用 clusterEncryptionConfigYaml
变量配置集群加密。
- clusterEncryptionConfigYaml
- 一个字符串,表示提供加密配置详细信息的 YAML 文件。
controlPlaneVolumes
controlPlaneVolumes
变量为控制平面节点配置持久卷。
- controlPlaneVolumes
-
一个可选对象数组,其中每个对象都包括
name
、storageClass
和mountPath
(均为字符串),以及一个可选的capacity
对象,其中包含storage
字符串。... variables: #controlPlaneVolumes is an optional set of PVCs to create and #attach to each node; use for high-churn components like etcd - name: controlPlaneVolumes value: | #name of the PVC to be used as the suffix (node.name) - name: etcd #mountPath is the directory where the volume device is mounted #takes the form /dir/path mountPath: /var/lib/etcd #storageClass is the storage class to use for the PVC storageClass: tkg2-storage-profile #capacity is the PVC storage capacity capacity: #storage sets the capacity for the disk volume #if not specified defaults to storageClass capacity storage: 4Gi
defaultRegistrySecret
使用 defaultRegistrySecret
变量为集群配置默认的容器注册表。
- defaultRegistrySecret
- 一个对象,此对象包含默认容器注册表的公钥、证书名称和命名空间。
defaultStorageClass
使用 defaultStorageClass
变量为集群配置默认存储类。
- defaultStorageClass
-
一个字符串,此字符串用于标识要用作默认存储类的存储类,通常,Helm 图表和 Tanzu 软件包等应用程序需要它。
... variables: - name: defaultStorageClass value: tkg2-storage-profile
extensionCert
使用 extensionCert
变量配置 TLS 证书。
- extensionCert
-
一个对象,此对象包含具有
name
和key
字符串的contentSecret
对象。contentSecret
引用为 TLS 证书创建的 Kubernetes 密钥对象。... variables: #extensionCert specifies the cert and key for Extensions Controller #self-signed issuer and certificates must be created in advance - name: extensionCert value: contentSecret: #name specifies the name of secret name: string #key specifies the content of tls\.crt in the secret's data map key: string
nodePoolLabels
使用 nodePoolLabels
变量为工作节点配置标签。
- nodePoolLabels
- 一个或多个对象组成的数组,其中每个对象都包含一个键/值(均为字符串)对。
nodePoolTaints
使用 nodePoolTaints
变量将污点应用于工作节点。
- nodePoolTaints
- 一个对象数组,其中每个对象都包含一个适用于工作节点的 污点。
nodePoolVolumes
使用 nodePoolVolumes
变量为集群节点指定持久卷。
- nodePoolVolumes
-
一个可选对象数组,其中每个对象都包括
name
、storageClass
和mountPath
(均为字符串),以及一个可选的capacity
对象,其中包含storage
字符串。... variables: #nodePoolVolumes is an optional set of PVCs to create and #attach to each node; use for high-churn components like containerd - name: nodePoolVolumes value: | #name of the PVC to be used as the suffix (node.name) - name: etcd #mountPath is the directory where the volume device is mounted #takes the form /dir/path mountPath: /var/lib/containerd #storageClass is the storage class to use for the PVC storageClass: tkg2-storage-profile #capacity is the PVC storage capacity capacity: #storage sets the capacity for the disk volume #if not specified defaults to storageClass capacity storage: 4Gi
ntp
使用 ntp
变量为集群配置 NTP 服务器。
- ntp
- 一个字符串,表示 NTP 服务器的 FQDN 或 IP 地址。
代理
使用 proxy
变量为集群配置代理服务器。
- 代理
- 一个对象,其参数可引用出站集群连接的代理服务器。
storageClass
使用 storageClass
变量为集群配置存储类。
- storageClass
-
一个字符串,此字符串是已分配给置备了 TKG 集群的
vSphere 命名空间 的 vSphere 存储配置文件的名称。
... variables: - name: storageClass value: tkg2-storage-profile
storageClasses
使用 storageClasses
变量为集群配置存储类阵列。
- storageClasses
-
一个或多个字符串组成的数组,每个字符串都是已分配给置备了 TKG 集群的
vSphere 命名空间 的 vSphere 存储配置文件的名称。
... variables: - name: storageClasses value: [tkg2-storage-profile, tkg2-storage-profile-latebinding]
TKR_DATA
使用 TKR_DATA
变量指定 TKR 信息。
- TKR_DATA
- 用于指定 TKR 版本和其他详细信息的对象。
trust
使用 trust
变量为集群指定一个或多个受信任的 CA 证书。
- trust
- 一个对象,用于向集群添加 TLS 证书(其他 CA 证书或终端证书)。
user
使用 user
变量指定集群用户凭据。
- user
- 一个对象,此对象包含具有名称和密钥字符串以及 sshAuthorizedKey 字符串的 passwordSecret 对象。您可以使用此变量将用户的 SSH 密钥添加到集群节点中以进行远程 SSH 访问。
vmClass
使用 vmClass
变量为集群节点配置虚拟机类。
- vmClass
- 一个必需字符串,此字符串将映射到与置备了 TKG 集群的 vSphere 命名空间 绑定的虚拟机类的名称。