gkectl
工具有两个用于排查集群问题的命令:gkectl diagnose cluster
和 gkectl diagnose snapshot
。这两个命令适用于管理员集群和用户集群。 本文档介绍了如何使用 gkectl diagnose
命令诊断集群中的问题。
如需详细了解如何使用 gkectl diagnose snapshot
命令创建快照以帮助 Cloud Customer Care 诊断问题,请参阅创建快照以诊断集群。
gkectl diagnose cluster
此命令会对集群执行健康检查并报告错误。该命令会对以下组件运行健康检查:
- vCenter
- 凭据
- DRS
- 反亲和性群组
- 网络
- 版本
- 数据中心
- Datastore
- ResourcePool
- 文件夹
- 网络
- 负载均衡器(F5、Seesaw 或手动)
- 用户集群和节点池
- 集群对象
- 用户集群的 Konnectivity 服务器就绪性
- 机器对象和相应的集群节点
kube-system
和gke-system
命名空间中的 Pod- 控制平面
- 集群中的 vSphere 永久卷
- 用户和管理员集群的 vCPU(虚拟 CPU)和内存争用信号
- 用户和管理员集群 ESXi 预配置主机 CPU 使用率和内存用量警报。
- 时段 (TOD)
- 启用了 Dataplane V2 的集群的节点网络政策
- Dataplane V2 节点代理的整体健康状况
诊断管理员集群
如需诊断管理员集群,请指定管理员集群的路径:
gkectl diagnose cluster --kubeconfig=ADMIN_CLUSTER_KUBECONFIG
将 ADMIN_CLUSTER_KUBECONFIG
替换为管理员集群 kubeconfig 文件的路径。
gkectl diagnose cluster
命令会返回以下示例输出:
Preparing for the diagnose tool...
Diagnosing the cluster......DONE
- Validation Category: Admin Cluster Connectivity
Checking VMs TOD (availability)...SUCCESS
Checking Konnectivity Server (readiness)...SUCCESS
- Validation Category: Admin Cluster F5 BIG-IP
Checking f5 (credentials, partition)...SUCCESS
- Validation Category: Admin Cluster VCenter
Checking Credentials...SUCCESS
Checking DRS enabled...SUCCESS
Checking Hosts for AntiAffinityGroups...SUCCESS
Checking Version...SUCCESS
Checking Datacenter...SUCCESS
Checking Datastore...SUCCESS
Checking Resource pool...SUCCESS
Checking Folder...SUCCESS
Checking Network...SUCCESS
- Validation Category: Admin Cluster
Checking cluster object...SUCCESS
Checking machine deployment...SUCCESS
Checking machineset...SUCCESS
Checking machine objects...SUCCESS
Checking kube-system pods...SUCCESS
Checking anthos-identity-service pods...SUCCESS
Checking storage...SUCCESS
Checking resource...SUCCESS
Checking virtual machine resource contention...SUCCESS
Checking host resource contention...SUCCESS
All validation results were SUCCESS.
Cluster is healthy!
如果目标集群中的虚拟 IP 地址 (VIP) 出现问题,请使用 --config
标志提供管理员集群配置文件,以提供更多调试信息。
gkectl diagnose cluster --kubeconfig ADMIN_CLUSTER_KUBECONFIG --config CLUSTER_CONFIG
将 CLUSTER_CONFIG
替换为管理员集群或用户集群配置文件的路径。
以下示例输出显示 gkectl diagnose cluster
命令现在可以正确连接到集群并检查问题:
Failed to access the api server via LB VIP "...": ...
Try to use the admin master IP instead of problematic VIP...
Reading config with version "[CONFIG_VERSION]"
Finding the admin master VM...
Fetching the VMs in the resource pool "[RESOURCE_POOL_NAME]"...
Found the "[ADMIN_MASTER_VM_NAME]" is the admin master VM.
Diagnosing admin|user cluster "[TARGET_CLUSTER_NAME]"...
...
诊断用户集群
如需诊断用户集群,您必须指定用户集群名称。如果您需要获取用户集群的名称,请运行以下命令:
kubectl get cluster --kubeconfig=USER_CLUSTER_KUBECONFIG
将 USER_CLUSTER_KUBECONFIG
替换为用户集群 kubeconfig 文件的路径。
指定用户集群的名称以及配置文件,如下所示:
gkectl diagnose cluster --kubeconfig=ADMIN_CLUSTER_KUBECONFIG \ --cluster-name=USER_CLUSTER_NAME
将 USER_CLUSTER_NAME
替换为用户集群的名称。
gkectl diagnose cluster
命令会返回以下示例输出:
Preparing for the diagnose tool...
Diagnosing the cluster......DONE
Diagnose result is saved successfully in <DIAGNOSE_REPORT_JSON_FILE>
- Validation Category: User Cluster Connectivity
Checking Node Network Policy...SUCCESS
Checking VMs TOD (availability)...SUCCESS
Checking Dataplane-V2...Success
- Validation Category: User Cluster F5 BIG-IP
Checking f5 (credentials, partition)...SUCCESS
- Validation Category: User Cluster VCenter
Checking Credentials...SUCCESS
Checking DRS enabled...SUCCESS
Checking Hosts for AntiAffinityGroups...SUCCESS
Checking VSphere CSI Driver...SUCCESS
Checking Version...SUCCESS
Checking Datacenter...SUCCESS
Checking Datastore...SUCCESS
Checking Resource pool...SUCCESS
Checking Folder...SUCCESS
Checking Network...SUCCESS
- Validation Category: User Cluster
Checking user cluster and node pools...SUCCESS
Checking cluster object...SUCCESS
Checking machine deployment...SUCCESS
Checking machineset...SUCCESS
Checking machine objects...SUCCESS
Checking control plane pods...SUCCESS
Checking kube-system pods...SUCCESS
Checking gke-system pods...SUCCESS
Checking gke-connect pods...SUCCESS
Checeking anthos-identity-service pods...SUCCESS
Checking storage...SUCCESS
Checking resource...SUCCESS
Checking virtual machine resource contention...SUCCESS
Checking host resource contention...SUCCESS
All validation results were SUCCESS.
Cluster is healthy!
诊断虚拟机状态
如果虚拟机创建出现问题,请运行 gkectl diagnose cluster
以获取虚拟机状态的诊断信息。
输出类似于以下内容:
- Validation Category: Cluster Healthiness
Checking cluster object...SUCCESS
Checking machine deployment...SUCCESS
Checking machineset...SUCCESS
Checking machine objects...SUCCESS
Checking machine VMs...FAILURE
Reason: 1 machine VMs error(s).
Unhealthy Resources:
Machine [NODE_NAME]: The VM's UUID "420fbe5c-4c8b-705a-8a05-ec636406f60" does not match the machine object's providerID "420fbe5c-4c8b-705a-8a05-ec636406f60e".
Debug Information:
null
...
Exit with error:
Cluster is unhealthy!
Run gkectl diagnose cluster automatically in gkectl diagnose snapshot
Public page https://cloud.google.com/anthos/clusters/docs/on-prem/latest/diagnose#overview_diagnose_snapshot
问题排查
下表列出了运行 gkectl diagnose cluster
命令时可能出现的问题及其解决方法:
问题 | 可能的原因 | 解决方法 |
---|---|---|
管理员集群或用户集群无法连接到 Kubernetes API 服务器。 | 检查虚拟机运行状况 OOB(开箱)内存延迟图表,理想情况下内存延迟时间应接近零。内存争用也会增加 CPU 争用,CPU 就绪情况图表可能会出现峰值,因为会执行交换。 | 增大物理内存。如需了解其他选项,请参阅 VMware 问题排查建议。 |
创建 Nodepool 时超时。 | VMDK 的读/写延迟时间较长。检查虚拟机运行状况 OOB 以了解是否存在虚拟磁盘读写延迟。根据 VMware 报道,总延迟时间超过 20 毫秒表示存在问题。 | 请参阅磁盘性能问题的 VMware 解决方案。 |
BundleUnexpectedDiff
个错误
由 Google Distributed Cloud 软件包管理的 Kubernetes Cluster API 资源可能会被意外修改,这可能会导致系统组件故障或集群升级或更新失败。
在 Google Distributed Cloud 1.13 及更高版本中,onprem-user-cluster-controller
会定期检查对象的状态,并通过日志和事件报告与预期状态的任何意外差异。这些对象包括用户集群控制平面和插件(例如 Service 和 DaemonSet)。
以下示例输出显示了意外的差异事件:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning BundleUnexpectedDiff 13m onpremusercluster/ci-bundle-diff Detected unexpected difference of user control plane objects: [ConfigMap/istio], please check onprem-user-cluster-controller logs for more details.
以下示例输出显示了 onprem-user-cluster-controller
生成的日志:
2022-08-06T02:54:42.701352295Z W0806 02:54:42.701252 1 update.go:206] Detected unexpected difference of user addon object(ConfigMap/istio), Diff: map[string]string{
2022-08-06T02:54:42.701376406Z - "mesh": (
2022-08-06T02:54:42.701381190Z - """
2022-08-06T02:54:42.701385438Z - defaultConfig:
2022-08-06T02:54:42.701389350Z - discoveryAddress: istiod.gke-system.svc:15012
...
2022-08-06T02:54:42.701449954Z - """
2022-08-06T02:54:42.701453099Z - ),
2022-08-06T02:54:42.701456286Z - "meshNetworks": "networks: {}",
2022-08-06T02:54:42.701459304Z + "test-key": "test-data",
2022-08-06T02:54:42.701462434Z }
事件和日志不会阻止集群操作。如果对象与其预期状态存在意外差异,则该对象将在下一次集群升级中被覆盖。