Describe the bug
When a new aks cluster and appgw have been deployed and agic add-on has been enabled, it is not working as expected. I have created a couple of clusters (all in westeurope region) by following the article https://docs.microsoft.com/en-us/azure/application-gateway/tutorial-ingress-controller-add-on-existing, but I got this error in the logs (ingress controller pods').
E0909 21:30:44.450072 1 client.go:170] Code="ErrorApplicationGatewayForbidden" Message="Unexpected status code '403' while performing a GET on Application Gateway. You can use 'az role assignment create --role Reader --scope /subscriptions/e5c8b5e5-9c21-4fc3-81bc-4159bc41cd9b/resourceGroups/rg1-ozozturk --assignee c4a8000d-ffbd-4d68-b0d5-f2f448e65bc5; az role assignment create --role Contributor --scope /subscriptions/xxxxxxxxxxxx/resourceGroups/rg1-ozozturk/providers/Microsoft.Network/applicationGateways/appgw1-ozozturk --assignee xxxxxxxxxxxx' to assign permissions. AGIC Identity needs atleast has 'Contributor' access to Application Gateway 'appgw1-ozozturk' and 'Reader' access to Application Gateway's Resource Group 'rg1-ozozturk'." InnerError="network.ApplicationGatewaysClient#Get: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: Service returned an error. Status=403 Code="AuthorizationFailed" Message="The client 'xxxxxxxxxxxx' with object id 'xxxxxxxxxxxx' does not have authorization to perform action 'Microsoft.Network/applicationGateways/read' over scope '/subscriptions/xxxxxxxxxxxx/resourceGroups/rg1-ozozturk/providers/Microsoft.Network/applicationGateways/appgw1-ozozturk' or the scope is invalid. If access was recently granted, please refresh your credentials.""
I0909 21:30:44.450091 1 retry.go:33] Retrying in 10s
Btw, If I follow what log says and assign 'Contributor' access to Application Gateway and 'Reader' access to Application Gateway's Resource Group for the managed identity, it works.
To Reproduce
kubectl get ingress
NAME HOSTS ADDRESS PORTS AGE
aspnetapp * 80 5s
Ingress Controller details
kubectl describe pod <ingress controller> . The helm list. Name: ingress-appgw-deployment-7d57c6dcd5-jv8mk
Namespace: kube-system
Priority: 0
Node: aks-nodepool1-62859232-vmss000001/10.240.0.35
Start Time: Wed, 09 Sep 2020 23:19:57 +0200
Labels: app=ingress-appgw
kubernetes.azure.com/managedby=aks
pod-template-hash=7d57c6dcd5
Annotations: checksum/config: 9cdc8550b8f315e4f99b0da58b9fd961977977f20253fcb0091dbb7c352f634d
kubernetes.azure.com/metrics-scrape: true
prometheus.io/path: /metrics
prometheus.io/port: 8123
prometheus.io/scrape: true
resource-id:
/subscriptions/e5c8b5e5-9c21-4fc3-81bc-4159bc41cd9b/resourceGroups/rg1-ozozturk/providers/Microsoft.ContainerService/managedClusters/aks1-...
Status: Running
IP: 10.240.0.43
IPs:
IP: 10.240.0.43
Controlled By: ReplicaSet/ingress-appgw-deployment-7d57c6dcd5
Containers:
ingress-appgw-container:
Container ID: docker://45824fb72a5112f9f917edf9c1572aeba6170c8064517393ab5f2d4872d745c1
Image: mcr.microsoft.com/azure-application-gateway/kubernetes-ingress:1.2.0-rc3
Image ID: docker-pullable://mcr.microsoft.com/azure-application-gateway/kubernetes-ingress@sha256:9331411a7f29cfd49b6d93e045ea6dea44cab07a2b4ce7d6a6448b3eb23d5200
Port: <none>
Host Port: <none>
State: Running
Started: Wed, 09 Sep 2020 23:20:09 +0200
Ready: True
Restart Count: 0
Limits:
cpu: 700m
memory: 100Mi
Requests:
cpu: 100m
memory: 20Mi
Liveness: http-get http://:8123/health/alive delay=15s timeout=1s period=20s #success=1 #failure=3
Readiness: http-get http://:8123/health/ready delay=5s timeout=1s period=10s #success=1 #failure=3
Environment Variables from:
ingress-appgw-cm ConfigMap Optional: false
Environment:
AZURE_CLOUD_PROVIDER_LOCATION: /etc/kubernetes/azure.json
AGIC_POD_NAME: ingress-appgw-deployment-7d57c6dcd5-jv8mk (v1:metadata.name)
AGIC_POD_NAMESPACE: kube-system (v1:metadata.namespace)
KUBERNETES_PORT_443_TCP_ADDR: aks1-ozozt-rg1-ozozturk-e5c8b5-aa3d2728.hcp.westeurope.azmk8s.io
KUBERNETES_PORT: tcp://aks1-ozozt-rg1-ozozturk-e5c8b5-aa3d2728.hcp.westeurope.azmk8s.io:443
KUBERNETES_PORT_443_TCP: tcp://aks1-ozozt-rg1-ozozturk-e5c8b5-aa3d2728.hcp.westeurope.azmk8s.io:443
KUBERNETES_SERVICE_HOST: aks1-ozozt-rg1-ozozturk-e5c8b5-aa3d2728.hcp.westeurope.azmk8s.io
Mounts:
/etc/kubernetes/azure.json from cloud-provider-config (ro)
/var/run/secrets/kubernetes.io/serviceaccount from ingress-appgw-sa-token-lgxfw (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
cloud-provider-config:
Type: HostPath (bare host directory volume)
Path: /etc/kubernetes/azure.json
HostPathType: File
ingress-appgw-sa-token-lgxfw:
Type: Secret (a volume populated by a Secret)
SecretName: ingress-appgw-sa-token-lgxfw
Optional: false
QoS Class: Burstable
Node-Selectors: beta.kubernetes.io/os=linux
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 24m default-scheduler Successfully assigned kube-system/ingress-appgw-deployment-7d57c6dcd5-jv8mk to aks-nodepool1-62859232-vmss000001
Normal Pulling 24m kubelet, aks-nodepool1-62859232-vmss000001 Pulling image "mcr.microsoft.com/azure-application-gateway/kubernetes-ingress:1.2.0-rc3"
Normal Pulled 24m kubelet, aks-nodepool1-62859232-vmss000001 Successfully pulled image "mcr.microsoft.com/azure-application-gateway/kubernetes-ingress:1.2.0-rc3"
Normal Created 24m kubelet, aks-nodepool1-62859232-vmss000001 Created container ingress-appgw-container
Normal Started 24m kubelet, aks-nodepool1-62859232-vmss000001 Started container ingress-appgw-container
Output of `kubectl logs
E0909 21:30:44.450072 1 client.go:170] Code="ErrorApplicationGatewayForbidden" Message="Unexpected status code '403' while performing a GET on Application Gateway. You can use 'az role assignment create --role Reader --scope /subscriptions/e5c8b5e5-9c21-4fc3-81bc-4159bc41cd9b/resourceGroups/rg1-ozozturk --assignee c4a8000d-ffbd-4d68-b0d5-f2f448e65bc5; az role assignment create --role Contributor --scope /subscriptions/xxxxxxxxxxxx/resourceGroups/rg1-ozozturk/providers/Microsoft.Network/applicationGateways/appgw1-ozozturk --assignee xxxxxxxxxxxx' to assign permissions. AGIC Identity needs atleast has 'Contributor' access to Application Gateway 'appgw1-ozozturk' and 'Reader' access to Application Gateway's Resource Group 'rg1-ozozturk'." InnerError="network.ApplicationGatewaysClient#Get: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: Service returned an error. Status=403 Code="AuthorizationFailed" Message="The client 'xxxxxxxxxxxx' with object id 'xxxxxxxxxxxx' does not have authorization to perform action 'Microsoft.Network/applicationGateways/read' over scope '/subscriptions/xxxxxxxxxxxx/resourceGroups/rg1-ozozturk/providers/Microsoft.Network/applicationGateways/appgw1-ozozturk' or the scope is invalid. If access was recently granted, please refresh your credentials.""
I0909 21:30:44.450091 1 retry.go:33] Retrying in 10s
Any Azure support tickets associated with this issue.
If you let az aks create the app gw it will work as it then gets deployed to the node resource group where aks has a service principal on the RG. If the GW is in another RG you will need to manually add the SP of AKS to the RG so it can manage the GW.
Also you can not set a custom name for the node RG using az aks create as this will also break the integration.
Hope this gets sorted also.
@ozgurozturknet @mortenlerudjordet thanks for reporting. We will investigate this shortly.
Just a note, AGIC addon is in public preview.
I have encountered the same problem while testing this addon. Looking forward to the fix.
Hi @akshaysngupta any update on this issue?
Any updates on this issue?
would like to know if there is a fix for this as well
Poke
Most helpful comment
@ozgurozturknet @mortenlerudjordet thanks for reporting. We will investigate this shortly.
Just a note, AGIC addon is in public preview.