本文提供有关 Azure Kubernetes Fleet Manager 基于 DNS 的负载均衡的故障排除信息。 Fleet Manager DNS 负载均衡使用 Azure 流量管理器来平衡来自多个 Azure Kubernetes 服务(AKS)成员群集的公共终结点之间的流量。
使用 Fleet Manager 中心群集进行故障排除
用户应该拥有访问 Azure 订阅和资源组的权限,这些资源是用于创建 Azure 流量管理器配置文件的。
安装或升级到 Azure CLI 版本 2.72.0 或更高版本。
确保已安装 Kubernetes kubectl 命令行工具。 可以通过运行 az aks install-cli 命令来安装 kubectl。
使用
az extension add
命令安装fleet Azure CLI 扩展。 请确保已安装的版本至少为 1.5.2。az extension add --name fleet
访问 Fleet Manager 中心群集 Kubernetes API。 有关详细信息,请参阅 访问 Fleet Manager 中心群集 API。
方案 1:无法创建 TrafficManagerProfile 或流量管理器
本节提供有关 TrafficManagerProfile
Kubernetes 对象及其关联的 Azure 流量管理器资源未创建的场景的常见原因和解决方案。
若要确定适当的解决方法,请使用显示的命令检查 Fleet Manager 中心群集上对象的状态 TrafficManagerProfile
。
kubectl get trafficmanagerprofile -n <namespace> <profile-name> -o yaml
错误 1:客户端没有执行作的授权
如果满足以下条件之一,可能会出现此问题:
- 清单中指定了不存在的
TrafficManagerProfile
Azure 资源组。 - 资源组与 Fleet Manager 资源不在同一 Azure 订阅中。
- Fleet Manager 中心群集标识无权在指定的资源组中创建和管理 Azure 流量管理器配置文件。
可以检查 TrafficManagerProfile
错误状态以了解详细信息。 以下关于状态TrafficManagerProfile
的示例显示权限不足。
status:
conditions:
- lastTransitionTime: "2025-04-29T02:57:33Z"
message: |
Invalid profile: GET https://management.azure.com/subscriptions/xxx/resourceGroups/your-fleet-atm-rg/providers/Microsoft.Network/trafficmanagerprofiles/fleet-yyyy
--------------------------------------------------------------------------------
RESPONSE 403: 403 Forbidden
ERROR CODE: AuthorizationFailed
--------------------------------------------------------------------------------
{
"error": {
"code": "AuthorizationFailed",
"message": "The client 'xxx' with object id 'xxx' does not have authorization to perform action
'Microsoft.Network/trafficmanagerprofiles/read' over scope
'/subscriptions/xxx/resourceGroups/your-fleet-atm-rg/providers/Microsoft.Network/trafficmanagerprofiles/fleet-yyyy' or the
scope is invalid. If access was recently granted, please refresh your credentials."
}
}
--------------------------------------------------------------------------------
observedGeneration: 1
reason: Invalid
status: "False"
type: Programmed
解决方案
若要解决此问题,请执行以下步骤:
- 确保 Azure 资源组存在,并且其 Azure 订阅值与 Fleet Manager 具有的值相同。
- 验证 Fleet Manager 中心群集标识是否被授予
Traffic Manager Contributor
角色,该角色的范围限定为资源组。 有关详细信息,请参阅 “配置机群管理器”权限。
错误 2:域名不可用
如果生成的 DNS 前缀已被另一个 Azure 流量管理器配置文件使用,则可能会出现此问题。 DNS 前缀由命名空间和 metadata.name
清单中的 TrafficManagerProfile
字段组成。 例如,如果命名空间为 team-a
和 metadata.name
is webapp
,则 DNS 前缀为 team-a-webapp
。
以下状态示例 TrafficManagerProfile
显示域名不可用:
status:
conditions:
- lastTransitionTime: "2025-04-29T06:39:10Z"
message: Domain name is not available. Please choose a different profile name or namespace
observedGeneration: 2
reason: DNSNameNotAvailable
status: "False"
type: Programmed
解决方案
若要解决此问题,请使用 nslookup
或类似的工具来确定完整 DNS 名称(例如) team-a-webapp.trafficmanager.net
是否已退出。 如果名称不可用,请考虑以下替代解决方案之一:
- 将
metadata.name
清单中的TrafficManagerProfile
字段更改为唯一名称。 - 对
TrafficManagerProfile
清单使用不同的命名空间。 此选择会影响TrafficManagerBackend
和ServiceExport
对象。 这些对象必须位于同一命名空间中。
错误 3:达到 Azure 流量管理器订阅限制
如果单个 Azure 订阅中存在 200 多个流量管理器配置文件或终结点,则可能会出现此问题。
以下状态示例 TrafficManagerProfile
显示已达到 Azure 流量管理器配置文件限制:
status:
conditions:
- lastTransitionTime: "2025-04-29T06:39:10Z"
message: Azure Traffic Manager profile limits reached.
observedGeneration: 2
reason: Invalid
status: "False"
type: Programmed
解决方案
请考虑删除未使用的配置文件或请求增加限制。 有关详细信息,请参阅 Azure 流量管理器限制。
错误 4:Azure 流量管理器返回错误
如果 Azure 流量管理器服务在创建配置文件时返回错误,则可能会出现此问题。
以下状态示例 TrafficManagerProfile
显示此错误:
status:
conditions:
- lastTransitionTime: "2025-04-29T06:39:10Z"
message: Azure Traffic Manager error message is displayed here.
observedGeneration: 2
reason: Invalid
status: "False"
type: Programmed
解决方案
如果错误仍然存在,请检查 Azure 流量管理器服务运行状况。
方案 2:无法创建 TrafficManagerBackend
本部分为无法创建 TrafficManagerBackend
Kubernetes 对象的情形提供常见原因和建议的解决方案。
若要确定适当的解决方法,请使用显示的命令检查 Fleet Manager 中心群集上对象的状态 TrafficManagerBackend
。
kubectl get trafficmanagerbackend -n <namespace> <backend-name> -o yaml
错误 1:找不到 TrafficManagerProfile 或 TrafficManagerProfile 无效
如果满足以下条件之一,可能会出现此问题:
-
TrafficManagerBackend
是在与TrafficManagerProfile
不同的命名空间中创建的。 - 该
TrafficManagerProfile
对象存在,但找不到关联的 Azure 流量管理器资源。
以下是显示错误的TrafficManagerBackend
状态示例。
status:
conditions:
- lastTransitionTime: "2025-04-29T06:43:57Z"
message: TrafficManagerProfile "nginx-nginx-profile" is not found
observedGeneration: 1
reason: Invalid
status: "False"
type: Accepted
缺少 Azure 流量管理器资源。
status:
conditions:
- lastTransitionTime: "2025-04-29T07:00:04Z"
message: 'Invalid trafficManagerProfile "nginx-nginx-profile": Domain name is not available.
Please choose a different profile name or namespace'
observedGeneration: 1
reason: Invalid
status: "False"
type: Accepted
解决方案
若要解决此问题,请执行以下步骤:
- 请确保在与
TrafficManagerProfile
相同的命名空间中创建TrafficManagerBackend
。 - 确保
Programmed
的TrafficManagerProfile
条件是Accepted
。 如果不是,请检查个人资料定义的有效性,然后重新提交。 - 确保 Azure 流量管理器资源存在。 若要重新创建资源,请从 Fleet Manager 中心群集中删除
TrafficManagerProfile
该资源。 然后重新应用它。
错误 2:Service 或 ServiceExport 无效
如果满足以下条件之一,可能会出现此问题:
-
Service
是在与TrafficManagerBackend
对象不同的命名空间中创建的。 - 存在
Service
,但ServiceExport
对象未在与TrafficManagerBackend
.. 相同的命名空间中创建。 -
Service
未被定义为LoadBalancer
类型。 -
Service
不会通过 Azure 公共 IP 地址公开,也不会分配 DNS 名称。
以下关于状态TrafficManagerBackend
的示例显示了错误:
status:
conditions:
- lastTransitionTime: "2025-04-29T07:50:49Z"
message: ServiceImport "invalid-service" is not found
observedGeneration: 1
reason: Invalid
status: "False"
type: Accepted
未将 Service
定义为 LoadBalancer
类型。
status:
conditions:
- lastTransitionTime: "2025-04-29T07:56:05Z"
message: '1 service(s) exported from clusters cannot be exposed as the Azure
Traffic Manager, for example, service exported from aks-member-5 is invalid:
unsupported service type "ClusterIP"'
observedGeneration: 1
reason: Invalid
status: "False"
type: Accepted
解决方案
若要解决此问题,请执行以下步骤:
- 通过创建
ServiceExport
,确保至少一个成员群集导出到TrafficManagerBackend
对象的Service
命名空间中。 - 确保导出
Service
的是负载均衡器类型,并通过 Azure 公共 IP 地址公开。 此地址必须具有一个已分配的 DNS 名称,以用于流量管理器配置文件中。
错误 3:找不到 Azure 流量管理器配置文件
如果满足以下条件之一,可能会出现此问题:
- 该
TrafficManagerProfile
对象存在,但找不到关联的 Azure 流量管理器资源。 - Fleet Manager 中心群集标识无权在指定的资源组中创建和管理 Azure 流量管理器配置文件或终结点。
以下是TrafficManagerBackend
状态的示例,显示错误:
status:
conditions:
- lastTransitionTime: "2025-05-08T09:38:36Z"
message: Azure Traffic Manager profile "fleet-6dd24764-0e46-4b52-b9c6-cc2a3f2535f9" under "your-fleet-atm-rg" is not found
observedGeneration: 2
reason: Invalid
status: "False"
type: Accepted
解决方案
若要解决此问题,请执行以下步骤:
- 确保 Azure 流量管理器资源存在。 若要重新创建资源,请从 Fleet Manager 中心群集中删除
TrafficManagerProfile
配置文件,然后重新应用该配置文件。 - 验证已向 Fleet Manager 枢纽集群标识授予
Traffic Manager Contributor
限定到资源组范围的角色。 有关详细信息,请参阅 “配置机群管理器”权限。
错误 4:已达到 Azure 流量管理器配置文件限制
如果在单个 Azure 订阅中创建 200 多个 Azure 流量管理器终结点,则可能会出现此问题。
TrafficManagerBackend
状态的以下示例显示错误:
status:
conditions:
- lastTransitionTime: "2025-04-29T06:39:10Z"
message: Azure Traffic Manager profile limits reached.
observedGeneration: 2
reason: Invalid
status: "False"
type: Programmed
解决方案
请考虑删除未使用的终结点。 有关详细信息,请参阅 Azure 流量管理器限制。
使用 Azure Log Analytics 进行故障排除
除了查询 Fleet Manager 中心群集之外,还可以使用 Azure Log Analytics 进行故障排除。
TrafficManagerProfile
通过使用trafficmanagerprofile/controller.go
筛选fleet-hub-net-controller-manager
类别中的条目。
AzureDiagnostics
| where Category == "fleet-hub-net-controller-manager"
| project TimeGenerated, ResourceId, log_s
| where ResourceId == "/subscriptions/xxx/resourceGroups/your-fleet-rg/providers/Microsoft.ContainerService/fleets/your-fleet"
| where log_s contains "trafficmanagerprofile/controller.go"
| limit 1000
流量管理后台
使用trafficmanagerbackend/controller.go
筛选fleet-hub-net-controller-manager
类别中的条目。
AzureDiagnostics
| where Category == "fleet-hub-net-controller-manager"
| project TimeGenerated, ResourceId, log_s
| where ResourceId == "/subscriptions/xxx/resourceGroups/your-fleet-rg/providers/Microsoft.ContainerService/fleets/your-fleet"
| where log_s contains "trafficmanagerbackend/controller.go"
| limit 1000
第三方联系人免责声明
为了帮助您获取有关此主题的更多信息,Microsoft 提供了第三方的联系信息。 该联系信息可能会在不通知的情况下更改。 微软不保证第三方联系信息的准确性。