-
Notifications
You must be signed in to change notification settings - Fork 308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't deploy an application from ACR #76
Comments
Any ideas? |
We may have a regression in the built-in ACR integration. When you created the service principal (SPN) for the cluster create what scopes did you use, or did you use the SPN created by As a workaround, you should be able to provide an |
I witnessed this last week. I resolved the issue by manually added the SPN to IAM as a contributor for the ACR resource. The SPN was created using |
@RohanNagar as your container registry is private and the kubelet is failing to pull the image, most probably your Service Principal does not have access to the ACR. Overall, that authentication can be done by either Service Principal Context - the one generated/provided at cluster creation - or by providing a docker secret that contains username/password. To do the latter, you need to create a secret in your cluster and reference it on your yaml file. Here's a walkthrough. |
@RohanNagar just re-tested the ACR integration with AKS, and everything is working as expected. If you are not explicitly providing a username/password, check that the service principal used by your AKS cluster has sufficient scope to ACR:
|
@marrobi do you happen to remember what the scope of your cluster SPN was before and after adding access to ACR? |
@slack Thank you for the help. It looks like the service principal used doesn't have sufficient scope:
But I'm actually a bit confused, because when I look at the portal, I see in the IAM for the cluster and the ACR, there is a "App Service or Function App" reader that is the same for both: cln77ea1ddf-8850-415e-9446-57a960b79a3f Do you know where that is coming from, and why the UUID is different from the one displayed on the command line? |
@RohanNagar ah, I didn't realize that I now realizee that our previous instructions for ACS and AKS walked folks through subscription-scoped SPN which let the Kubernetes ACR integration work magically. My test cluster was sub-scoped as well. doh! Add a
|
@slack Looks to have solved my problem, the pod is able to pull the image and serve the front end now. Thanks for all your help! |
@slack Not 100% sure. As I say was created automatically. I believe it had scope to the agent pool RG, but not the primary AKS resource RG, as thats where ACR was also deployed. But don't hold me to that! I actually saw two different people with the exact same issue that day - we were running a hack. |
@slack Hey all, this thread helped me out a ton - thanks! We ran into the same issue with the cluster SPN not having contributor access to the ACR resource. Also, the workaround suggested on this thread and in the Kubernetes docs using suggesting to use the secret and |
Unfortunately non of the ideas in this thread worked for me.
So the solution I ended up with is this
apiVersion: v1
kind: Secret
metadata:
name: acr-auth
data:
.dockerconfigjson: <base64-string>
type: kubernetes.io/dockerconfigjson
Why the original kubernetes secret did not work is just a mystery to me... |
@tolu Thanks you saved my day ! Had to do the same thing :
I added before trying this the Service Principal of my k8s cluster as Reader and Contributor of the ACR, so I don't know if it is required or not. |
@mleneveut were you deploying to a custom namespace or the default? I am deploying to a custom name space and have configured the Azure Container Registry to write the secret to the container but it appears to be writing it to the default namespace and not the custom namespace specified? @slack any ideas here? |
@benbuckland I was deploying to default namespace. |
@benbuckland I'm also using custom namespaces. From: https://kubernetes.io/docs/concepts/configuration/secret/
So make sure your Like so: |
Hey @tolu, i was trying to use the 'Deploy to Kubernetes' task in VSTS and expecting the task to create the ACR secret. The VSTS guys have come back and confirmed the fault I was seeing here microsoft/azure-pipelines-tasks#6695 Thanks again. |
@slack can you provide a bit more information how to solve this issue properly when using SP and following the best practices to have So my AKS is in resource group The Service Principal had initially only I added I added Owner role (which is pretty ugly) If I query for the role assignments using |
@slack quick update. Seems like k8s caches the service principal for a couple of minutes. After a couple of minutes I was able to pull the image from ACR. But it still feels a bit wrong to assign Owner role to the Service Principal |
I cannot get it working too. Neither with |
@slack @RohanNagar slack's solution worked for me too. Thank you both for sharing.. I figured I need not to modify the secrets in the pod yml file even. So everything stays the same - and the client service principal gets the new assignments; although... I've noticed that if you create a ACK resource group - the resource group that actually contains the running nodes is separated (I think to simplify the view for the Azure console end-user?...), and the default contributor role, although correctly assigned to the principal id, is scoped to the same resource group... SO... your ACR must be located within the same resource group as the one your nodes are scoped with. (Perhaps as an action item this should be a ticket to document a note on the guide lines/azure docs?...) Took me a good 3 late nights to understand what's going on... hope this saves someone else's time. |
@philippneugebauer I had the same issues. Using the alternate 'Image Pull Secret' methodology described here let me get rolling: |
To people who face issue when aks unable to pull image from acs, so make sure to check acr first, see if you get successful pull or not Create asp.net core, docker it with LINUX as target host |
@andrew-vandenbrink Does this include using aci-connectors? I thought that with aci-connectors, you can run either Linux and Windows containers. |
@ohdihe Before aks, there is container service Then there is aks, |
@andrew-vandenbrink. I was able to run Windows container on AKS using aci-connectors today. Aci-connectors acts like a virtual node in the AKS cluster. Also, I created a kubectl secret to grant AKS cluster permission to my private ACR in other to pull the windows image and run it. |
@ohdihe yes, what you described also in the faq... |
@slacks workaround worked for me... |
im stuck in a same issue i think The push refers to repository [docker.io/prova01/azure-vote-front] any ideas? |
@slack still this does not work for us. I mean the behaviour is inconsistent. It works sometimes and after few deployments it fails and if we start the deployment again. it works. No idea whats wrong here. The original SP is with Contributor role and the same SPN has the AcrPullRole. If I list the role assignment with |
I'm following this tutorial: https://docs.microsoft.com/en-in/azure/aks/tutorial-kubernetes-deploy-application
I can't seem to get azure-vote-front to deploy in AKS in part 4 of the tutorial. Both the ACR and the AKS are in the same resource group, but looking at the Kubernetes logs shows that there was an authentication failure, where it is failing to pull the image from ACR:
I tried deleting the cluster and deploying again after a day, same issue happened so it wasn't a one-off thing. I've been following the tutorial.
Does anyone have any ideas?
The text was updated successfully, but these errors were encountered: