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

问题描述

我有一个 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定位到应用网关的后端池。您可以选择目标类型 IP address or FQDN。你的应用网关必须与你的 AKS 位于同一个 VNet。

enter image description here

有关详细信息,如果您有兴趣在 Azure Kubernetes 服务中创建应用程序网关入口控制器,可以create them with terraformtroubleshoot 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 一起使用,这不是一个好习惯。