排查 Azure Kubernetes Fleet Manager 中的 ClusterResourcePlacement API 问题

使用 Azure Kubernetes Fleet Manager 时,此故障排除指南可帮助你解决 ClusterResourcePlacement API 对象相关问题。 排查集线器群集上的这些错误需要掌握以下对象:

  • ClusterResourceSnapshot
  • ClusterSchedulingPolicySnapshot
  • ClusterResourceBinding
  • Work

有关每个对象的更多详细信息,请参阅 KubeFleet API 参考

ClusterResourcePlacement 部署的完整进度

了解自定义资源的进度和状态 ClusterResourcePlacement 对于诊断和识别故障至关重要。 可以使用以下命令查看自定义资源的状态 ClusterResourcePlacement

kubectl describe clusterresourceplacement <name>

有关详细信息,请参阅 使用 ClusterResourcePlacement API 将资源传播到成员群集

完整进度 ClusterResourcePlacement 如下:

  1. ClusterResourcePlacementScheduled:指示资源已计划放置。

    如果为 false,请参阅 如何排除 ClusterResourcePlacementScheduled 条件状态为 false 时的故障

  2. ClusterResourcePlacementRolloutStarted:指示推出过程已开始。

    如果为 false,请参阅如何排查 ClusterResourcePlacementRolloutStarted 条件状态为 false 的问题

  3. ClusterResourcePlacementOverridden:表示资源已被覆盖。

    如果为假,请参阅 当 ClusterResourcePlacementOverridden 条件状态为假时如何进行故障排除

  4. ClusterResourcePlacementWorkSynchronized:指示工作对象已同步。

    如果为 false,请参阅 如何排查 ClusterResourcePlacementWorkSynchronized 条件状态为 false 时的问题

  5. ClusterResourcePlacementApplied:表示资源已被应用。

    如果为 false,请参阅 集群资源放置已应用条件状态为 false 时如何进行故障排除

  6. ClusterResourcePlacementAvailable:指示资源可用。

    如果为 false,请参阅 集群资源放置可用条件状态为 false 时的故障排除方法

常见问题

如果某些群集未按预期选择,我该如何进行调试?

检查ClusterSchedulingPolicySnapshot的状态,以确定选择了哪些群集及其选择原因。

如何调试以解决所选群集没有预期的资源,或者 ClusterResourcePlacement 没有应用最新更改的问题?

  1. 检查ClusterResourcePlacement状态下的ClusterResourcePlacementRolloutStarted条件是否设定为truefalse
  2. 检查条件是否 ClusterResourcePlacementApplied 设置为 未知false 还是 true
  3. 在特定群集的placementStatuses状态中检查ClusterResourcePlacement部分。 本 FailedPlacements 部分应提供任何资源应用程序故障的原因。

如何查找并确认用于 ClusterResourcePlacement 部署的最新 ClusterSchedulingPolicySnapshot?

若要查找 API 部署的最新ClusterSchedulingPolicySnapshotClusterResourcePlacement版本,请运行以下命令:

kubectl get clusterschedulingpolicysnapshot -l kubernetes-fleet.io/is-latest-snapshot=true,kubernetes-fleet.io/parent-CRP={CRPName}

注释

在此命令中,将 {CRPName} 替换为您的 ClusterResourcePlacement 名称。

然后,将 ClusterSchedulingPolicySnapshot 策略与 ClusterResourcePlacement 策略进行比较,以确保它们匹配,从“ClusterResourcePlacement”规范中排除字段 numberOfClusters

如果放置类型为 PickN,请检查策略中 ClusterResourcePlacement 请求的群集数是否与标签的值 number-of-clusters 匹配。

如何查找最新的 ClusterResourceBinding 资源?

以下命令列出与ClusterResourcePlacement关联的所有ClusterResourceBindings实例:

Kubectl get clusterresourcebinding -l kubernetes-fleet.io/parent-CRP={CRPName}

注释

在此命令中,将 {CRPName} 替换为您的 ClusterResourcePlacement 名称。

示例

  1. 运行以下命令以查看部署的状态 ClusterResourcePlacement 。 在本例中,名称 ClusterResourcePlacementtest-crp.

    kubectl describe clusterresourceplacement test-crp
    
  2. 下面是一个示例输出。 在placementStatuses部分的test-crp状态中,请注意,它已将资源分配到两个成员群集,因此有两个ClusterResourceBindings实例:

    status:
      conditions:
      - lastTransitionTime: "2023-11-23T00:49:29Z"
        ...
      placementStatuses:
      - clusterName: kind-cluster-1
        conditions:
          ...
          type: ResourceApplied
      - clusterName: kind-cluster-2
        conditions:
          ...
          reason: ApplySucceeded
          status: "True"
          type: ResourceApplied
    
  3. 若要获取 ClusterResourceBindings 该值,请运行以下命令:

    kubectl get clusterresourcebinding -l kubernetes-fleet.io/parent-CRP=test-crp 
    
    NAME                               WORKCREATED   RESOURCESAPPLIED   AGE
    test-crp-kind-cluster-1-be990c3e   True          True               33s
    test-crp-kind-cluster-2-ec4d953c   True          True               33s
    

    输出列出了所有与 test-crp 关联的 ClusterResourceBindings 实例。 资源 ClusterResourceBinding 名称使用以下格式:

    {CRPName}-{clusterName}-{suffix}

如何查找最新的 ClusterResourceSnapshot 资源?

若要查找最新的 ClusterResourceSnapshot 资源,请运行以下命令:

kubectl get clusterresourcesnapshot -l kubernetes-fleet.io/is-latest-snapshot=true,kubernetes-fleet.io/parent-CRP={CRPName}

注释

在此命令中,将 {CRPName} 替换为你的名称 ClusterResourcePlacement

如何查找与 ClusterResourcePlacement 关联的正确工作资源?

若要查找正确的工作资源,请执行以下步骤:

  1. 标识成员群集命名空间和 ClusterResourcePlacement 名称。 命名空间的格式为 fleet-member-{clusterName}.

  2. 若要获取工作资源,请运行以下命令:

    kubectl get work -n fleet-member-{clusterName} -l kubernetes-fleet.io/parent-CRP={CRPName}
    

    注释

    在此命令中,将 {clusterName}{CRPName} 替换为你在第一步中标识的名称。

联系我们以获得帮助

如果您有任何疑问或需要帮助,可以创建支持请求,或咨询Azure社区支持。 您还可以向Azure反馈社区提交产品反馈。