如何允许 Azure 中的 Kubernetes 集群通过 terraform 与 Azure 容器注册表通信?
我想从我的 Azure 容器注册表加载自定义图像。不幸的是,当 Kubernetes 应该从 ACR 下载图像时,我遇到了权限错误。
在我通过 az cli 将 acr 附加到 aks 后,一切正常:
az aks update -n myAKSCluster -g myResourceGroup --attach-acr <acrName>
这是我的地形配置;我已经剥离了一些其他的东西。它本身就起作用。
terraform {
backend "azurerm" {
resource_group_name = "tf-state"
storage_account_name = "devopstfstate"
container_name = "tfstatetest"
key = "prod.terraform.tfstatetest"
}
}
provider "azurerm" {
}
provider "azuread" {
}
provider "random" {
}
# define the password
resource "random_string" …Run Code Online (Sandbox Code Playgroud) 我有一个已推送到私有 Azure 容器注册表的本地 docker 映像。然后在 Azure Kubernetes 服务中,我有一个使用此映像的集群 - 来自 ACR。
现在我想更新图像(意识到我需要安装 zip 和解压缩)。我启动了一个本地容器,进行了更改,提交了它们并将新映像推送到了 ACR。不幸的是,这还不够。我的 pod 仍在使用之前版本的镜像,没有 zip。
更多细节和我尝试过的:
在掌舵图中,我使用了“最新”标签;
比较我本地“最新”图像的摘要 sha 和我在 ACR 中的图像 - 它们是相同的;
在本地启动“最新”容器 ( docker run -it --rm -p 8080:80 My-REPO.azurecr.io/MY-IMAGE:latest) - 它安装了 zip
删除了 kubernetes 中现有的 pod;新创建的仍然缺少 zip
删除发布并重新创建它 - 仍然没有。
我正在使用 ACR docker push MY-REPO.azurecr.io/MY-IMAGE:latest
所以我的问题是 - 我错过了什么?如何正确更新此设置?
我正在尝试构建一个 Docker 容器并将其推送到 Azure 容器注册表。为此,我创建了这个azure-pipeline.yml
# Docker
# Build and push an image to Azure Container Registry
# https://learn.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- main
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: '...'
imageRepository: 'mycontainer'
containerRegistry: 'azuk.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/dockerfile'
tag: '$(Build.BuildId)'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push …Run Code Online (Sandbox Code Playgroud)