带有 AKS Kube-Proxy 的 Azure 应用程序网关

Azure application gateway with AKS Kube-Proxy

我有一个 AKS 集群和一些带有 Nodeport 的微服务。

User -> Application Gateway -> Backend Pool -> Nodeport of microservice -> service

但是,我想将应用程序网关与来自 AKS 节点池的虚拟机规模集一起使用。

当我在应用程序网关中添加 AKS 节点池的后端 (VMSS) 时

{
    "status": "Failed",
    "error": {
        "code": "LinkedAuthorizationFailed",
        "message": "The client has permission to perform action 'Microsoft.Compute/galleries/images/versions/read' on scope '/subscriptions/aa51d057-842e..../resourcegroups/MC_loadbalancer_aaa-aks-1_southeastasia/providers/Microsoft.Compute/virtualMachineScaleSets/aks-syspool-13675031-vmss', however the current tenant '1393b73d-faec-...' is not authorized to access linked subscription '911a5e88-712a-...'."
    }
}

但如果我创建手动 VMSS 并将其添加到应用程序网关,就没问题了。但是当我通过 AKS 集群添加 VMSS 节点池时,出现如上的错误。

这个错误很奇怪。好像我的租户 ID 没有订阅 911a5e88....

是否真的可以将应用程序网关作为后端池连接到 AKS 节点池?

我直接把节点池添加到后端池也遇到了这个问题。从Ingress controller creates backend pool based on pod IP not the service IP开始,貌似可以直接将节点IP定位到应用网关后台池。您可以 select 目标类型 IP address or FQDN。你的 App Gateway 必须与你的 AKS 位于同一个 VNet 中。

有关详细信息,如果您有兴趣在 Azure Kubernetes 服务中创建应用程序网关入口控制器,可以create them with terraform and troubleshoot common questions or issues with Ingress Controller

我的情况完全一样。

该修复的灵感来自于此:https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-upgrade-scale-set#update-the-load-balancer-for-your-scale-set 看来在 azure 中您也可以反过来将 VMSS 配置为 BackendPool,该选项似乎只能从 CLI 获得。

az vmss update --resource-group myResourceGroup --name myScaleSet --add virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].ipConfigurations[0].ApplicationGatewayBackendAddressPools '{"id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/backendAddressPools/{applicationGatewayBackendPoolName}"}'

我不知道为什么接受当前的回复,因为它只是提供了一种解决方法;您必须能够将 VMSS 添加到您的 AppGW 后端池。它要么是 Azure 中的错误,要么是最新升级的未记录案例。

切勿将 IP 或 FQDN 与 VMSS 一起使用,这不是好的做法。