AGIC 问题没有对基础设施进行任何更改

问题描述 投票:0回答:1

我将 AGIC 作为我的 AKS 的入口,没有任何更改。看到以下错误:

E0109 08:27:56.481514 1 Reflector.go:138] pkg/mod/k8s.io/[电子邮件受保护]/tools/cache/reflector.go:167:无法观看*v1beta1.AzureApplicationGatewayRewrite:无法列出*v1beta1.AzureApplicationGatewayRewrite:azureapplicationgatewayrewrites.appgw.ingress.azure.io 被禁止:用户“system:serviceaccount:kube-system:ingress-appgw-sa”无法在 API 组“appgw.ingress.azure.io”中列出资源“azureapplicationgatewayrewrites” “在集群范围内:Azure 对此用户没有意见。

E0109 09:38:27.684411 1 Reflector.go:138] pkg/mod/k8s.io/[电子邮件受保护]/tools/cache/reflector.go:167:无法观看*v1beta1.AzureApplicationGatewayRewrite:无法列出*v1beta1.AzureApplicationGatewayRewrite:服务器找不到请求的资源(获取azureapplicationgatewayrewrites.appgw.ingress.azure.io)

删除了 POD 并重新创建,但仍然看到相同的错误

azure kubernetes-ingress azure-aks azure-application-gateway
1个回答
0
投票

您看到的错误表明 Azure 应用程序网关入口控制器 (AGIC) 使用的服务帐户

ingress-appgw-sa
没有必要的权限来列出 AKS 群集中的
AzureApplicationGatewayRewrite
资源。要解决此问题,您需要确保为
ingress-appgw-sa
服务帐户设置正确的 RBAC(基于角色的访问控制)权限。 首先验证您的服务帐户 kubectl 获取服务帐户 ingress-appgw-sa -n kube-system enter image description here

列出

kube-system
命名空间中的所有角色和角色绑定:

kubectl get roles,rolebindings -n kube-system

enter image description here

如果您没有看到 AGIC 的任何现有角色或角色绑定,则需要创建它们。

下面是为具有现有应用程序网关的 AKS 群集启用应用程序网关入口控制器加载项的示例。 如果您已有 AKS 群集,请跳过它。如果不创建如下所示的集群-

az aks create -n <ClusterName> -g <ResourceGroup> --network-plugin azure --enable-managed-identity --generate-ssh-keys

部署新的应用程序网关,使用您选择的名称更改 myResourceGroup 、 myPublicIp、myVnet、mySubnet、myApplicationGateway 的名称

 az network public-ip create -n myPublicIp -g myResourceGroup --allocation-method Static --sku Standard

enter image description here

az network vnet create -n myVnet -g myResourceGroup --address-prefix 10.0.0.0/16 --subnet-name mySubnet --subnet-prefix 10.0.0.0/24 

enter image description here

az network application-gateway create -n myApplicationGateway -g myResourceGroup --sku Standard_v2 --public-ip-address myPublicIp --vnet-name myVnet --subnet mySubnet --priority 100
 

enter image description here

现在在 AKS 集群中启用 AGIC 插件

appgwId=$(az network application-gateway show -n myApplicationGateway -g myResourceGroup -o tsv --query "id") 
az aks enable-addons -n myCluster -g myResourceGroup -a ingress-appgw --appgw-id $appgwId

enter image description here

如果你想使用 Azure 门户启用 AGIC 附加组件,请转到 (https://aka.ms/azure/portal/aks/agic) 并导航到你的 AKS 群集。从那里,转到 AKS 群集下的“网络”选项卡。您将看到应用程序网关入口控制器部分,其中包含使用 Azure 门户启用/禁用入口控制器加载项的选项。 enter image description here

由于我已将 AKS 集群部署在其自己的虚拟网络中,并将应用程序网关部署在另一个虚拟网络中,因此我必须将两个虚拟网络对等互连,以便流量从应用程序网关流向集群中的 Pod .

nodeResourceGroup=$(az aks show -n myCluster -g myResourceGroup -o tsv --query "nodeResourceGroup")
aksVnetName=$(az network vnet list -g $nodeResourceGroup -o tsv --query "[0].name")

aksVnetId=$(az network vnet show -n $aksVnetName -g $nodeResourceGroup -o tsv --query "id")
az network vnet peering create -n AppGWtoAKSVnetPeering -g myResourceGroup --vnet-name myVnet --remote-vnet $aksVnetId --allow-vnet-access

appGWVnetId=$(az network vnet show -n myVnet -g myResourceGroup -o tsv --query "id")
az network vnet peering create -n AKStoAppGWVnetPeering -g $nodeResourceGroup --vnet-name $aksVnetName --remote-vnet $appGWVnetId --allow-vnet-access

enter image description here

完成。现在将示例应用程序部署到 AKS 集群,该应用程序将使用 Ingress 的 AGIC 加载项并将应用程序网关连接到 AKS 集群。

kubectl apply -f https://raw.githubusercontent.com/Azure/application-gateway-kubernetes-ingress/master/docs/examples/aspnetapp.yaml

kubectl get ingress

enter image description here enter image description here

参考文档: AKS 上的 AGIC AGIC 的常见问题和故障排除

© www.soinside.com 2019 - 2024. All rights reserved.