我想使用 AKS 和 ArgoCD 的用户分配或托管身份来创建应用程序。
我在 ACR 上为 AKS 身份分配了 AcrPull,然后尝试使用以下命令创建 ArgoCD 存储库
argocd repo add myACR.azurecr.io --type helm --name helm --enable-oci
helm
是我的存储库的根目录。它工作正常,我可以在 ArgoCD UI 的连接状态中看到绿色的“成功”勾号。
但是当我尝试为其中一张实际图像创建应用程序时,它失败了
helm pull oci://myACR.azurecr.io/helm/mychart --version 0.0.1 --destination /tmp/helm706383544
failed exit status 1: Error: failed to authorize: failed to fetch anonymous token: unexpected status: 401 Unauthorized
(顺便说一句,如果我启用管理员用户并使用 --username XXX --password XXX
选项创建 argocd 存储库,一切都会按预期工作)
我错过了什么?有可能实现这一目标吗?或者我是否需要在 ACR 上启用管理员用户(或使用 token ?)
最佳答案
当您说 AKS 身份并指用户管理身份时,那么在这种情况下是错误的。
要访问 ACR,您需要将 AKS 的 kubelet 身份分配为 AcrPull
角色 kubelet负责拉取镜像:
export KUBE_ID=$(az aks show -g <resource group> -n <aks cluster name> --query identityProfile.kubeletidentity.objectId -o tsv)
export ACR_ID=$(az acr show -g <resource group> -n <acr name> --query id -o tsv)
az role assignment create --assignee $KUBE_ID --role "AcrPull" --scope $ACR_ID
但这只是 Kubernetes 拉取镜像的部分。我不认为 ArgoCD 开箱即用地利用 Azure Identites 连接到您的存储库。
因此,也许您需要指定用户名和密码,以便 ArgoCD 可以连接到 helm 存储库:
argocd repo add myACR.azurecr.io --type helm --name helm --enable-oci --username <username> --password <password>
关于azure - 如何在 ArgoCD 中使用 AKS 托管身份连接到 ACR?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74928026/