本页面概述了 GKE On-Prem 中使用的 Kubernetes Cluster API 资源。
概览
GKE On-Prem 支持以下 Cluster API 资源:
- Cluster
- Machine
- MachineDeployment
- MachineSet
- MachineClasses
GKE On-Prem 会在安装过程中自动在集群中生成这些资源;一般而言,您无需直接与其互动。此外,GKE On-Prem 文档会引用这些资源来说明高可用性等概念。
您可以查看集群中的可用 Cluster API CustomResourceDefinition (CRD):
kubectl get crds | grep "cluster.k8s.io" clusters.cluster.k8s.io machineclasses.cluster.k8s.io machinedeployments.cluster.k8s.io machines.cluster.k8s.io machinesets.cluster.k8s.io
下面几个部分讨论了目前与了解 GKE On-Prem 相关的 Cluster API 资源。
Cluster
Cluster 资源表示在主机上运行的 Kubernetes 实例。所有 GKE On-Prem 集群都有一个描述集群的 Cluster 资源。
如需查看集群中的 Cluster 资源,请运行以下命令,其中 [KUBECONFIG] 是集群的 kubeconfig 文件的路径:
kubectl get clusters --kubeconfig [KUBECONFIG]
下面是您可能会在 GKE On-Prem 用户集群中看到的 Cluster 资源示例:
apiVersion: cluster.k8s.io/v1alpha1 kind: Cluster metadata: annotations: addons.gke.io/loadbalancerip: "" bundle.gke.io/target-version: bundle.gke.io/version: onprem.gke.io/provider: vsphere creationTimestamp: finalizers: - cluster.cluster.k8s.io generation: name: example-user-cluster namespace: default resourceVersion: "" selfLink: /apis/cluster.k8s.io/v1alpha1/namespaces/default/clusters/example-user-cluster uid: spec: clusterNetwork: pods: cidrBlocks: - serviceDomain: cluster.local services: cidrBlocks: - providerSpec: value: apiVersion: vsphereproviderconfig.k8s.io/v1alpha1 controlPlaneReplicas: controlPlaneVersion: kind: VsphereClusterProviderConfig loadBalancerIP: loadBalancerNodePort: metadata: creationTimestamp: networkSpec: dns: ntp: "" reservedAddresses: oidcSpec: sniCert: vsphereDatacenter: vsphereDefaultDatastore: vsphereNetwork: vsphereResourcePool: status: apiEndpoints: - host: port:
机器
在 GKE On-Prem 中,Machine 资源是位于 vSphere 中的单个虚拟机 (VM) 的声明性规范。每个 Machine 资源都有一个对应的 Node 资源,Node 资源由 GKE On-Prem 根据 Machine 的规范创建。这些资源引用同一个物理对象,即位于 vSphere 环境中的虚拟机。
如需查看集群中的 Machine 资源,请运行以下命令,其中 [KUBECONFIG] 是集群的 kubeconfig 文件的路径:
kubectl get machines --kubeconfig [KUBECONFIG]
下面是您可能会在 GKE On-Prem 集群中看到的 Machine 资源示例:
apiVersion: cluster.k8s.io/v1alpha1 kind: Machine metadata: annotations: control-plane-version: "" kubelet-version: onprem.gke.io/provider: vsphere vm-ip-address: vsphere-machine-state: vsphere-machine-uuid: creationTimestamp: finalizers: - machine.cluster.k8s.io generateName: example-cluster-node generation: labels: kubernetes.googleapis.com/cluster-name: example-cluster-node kubernetes.googleapis.com/cluster-namespace: machine-template-hash: "" set: node name: example-cluster-node namespace: default ownerReferences: - apiVersion: cluster.k8s.io/v1alpha1 blockOwnerDeletion: controller: kind: MachineSet name: example-cluster-node uid: resourceVersion: "" selfLink: /apis/cluster.k8s.io/v1alpha1/namespaces/default/machines/example-cluster-node uid: spec: metadata: creationTimestamp: providerSpec: value: apiVersion: vsphereproviderconfig.k8s.io/v1alpha1 kind: VsphereMachineProviderConfig machineVariables: datacenter: datastore: disk_label: disk_size: "" memory: "" network: num_cpus: "" resource_pool: vm_template: metadata: creationTimestamp: networkSpec: address: dns: ntp: "" useIPAM: vsphereMachine: versions: kubelet: status: lastUpdated: nodeRef: kind: Node name: uid:
MachineDeployment
一个 MachineDeployment 管理一组 Machine:它指定 Machine 在其中运行的 GKE On-Prem 集群、声明 Machine 的 vSphere 配置以及发布配置更改。您可以将 MachineDeployment 和 Machine 视为 Deployment 和 pod。
如需查看集群中的 MachineDeployment 资源,请运行以下命令,其中 [KUBECONFIG] 是集群的 kubeconfig 文件的路径:
kubectl get machinedeployments --kubeconfig [KUBECONFIG]
下面是您可能会在 GKE On-Prem 集群中看到的 MachineDeployment 资源示例:
apiVersion: cluster.k8s.io/v1alpha1 kind: MachineDeployment metadata: annotations: machinedeployment.clusters.k8s.io/revision: "1" onprem.gke.io/provider: vsphere creationTimestamp: generation: 2 labels: kubernetes.googleapis.com/cluster-name: example-cluster kubernetes.googleapis.com/cluster-namespace: set: node name: example-cluster namespace: default resourceVersion: "" selfLink: /apis/cluster.k8s.io/v1alpha1/namespaces/default/machinedeployments/example-cluster uid: spec: minReadySeconds: 0 progressDeadlineSeconds: replicas: revisionHistoryLimit: selector: matchLabels: kubernetes.googleapis.com/cluster-name: example-cluster kubernetes.googleapis.com/cluster-namespace: default set: node strategy: rollingUpdate: maxSurge: maxUnavailable: type: RollingUpdate template: metadata: annotations: onprem.gke.io/provider: vsphere creationTimestamp: null labels: kubernetes.googleapis.com/cluster-name: example-cluster kubernetes.googleapis.com/cluster-namespace: set: node spec: metadata: creationTimestamp: providerSpec: value: apiVersion: vsphereproviderconfig.k8s.io/v1alpha1 kind: VsphereMachineProviderConfig machineVariables: datacenter: datastore: disk_label: disk_size: "" memory: "" network: num_cpus: "" resource_pool: example-cluster vm_template: metadata: creationTimestamp: networkSpec: address: dns: ntp: "" useIPAM: vsphereMachine: versions: kubelet: status: availableReplicas: observedGeneration: readyReplicas: replicas: updatedReplicas: