Azure Devops kubectl 任务部署映像的状态为 ErrImagePull/ImagePullBackOff
Posted
技术标签:
【中文标题】Azure Devops kubectl 任务部署映像的状态为 ErrImagePull/ImagePullBackOff【英文标题】:Azure Devops kubectl task deployed image is with status ErrImagePull/ImagePullBackOff 【发布时间】:2020-10-07 00:15:15 【问题描述】:我使用 Azure Devops 创建了一个部署管道,通过它我正在构建一个映像并将其推送到 Azure 容器注册表。 在下一步中,我将从 ACR 部署到 AKS 集群,该集群是我使用以下命令创建并附加到 ACR 的: az aks create -n HealthCareAKSCluster -g AKSCICDRG --generate-ssh-keys --attach-acr HealthCareAKSCICDACR 以下是我的 yaml 代码:
# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- master
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: 'XXXXXXXXXX'
imageRepository: 'patientservice'
containerRegistry: 'healthcareakscicdacr.azurecr.io'
dockerfilePath: './PatientService/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 an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
- stage: Deploy
displayName: Deploy
jobs:
- job: Deploy
displayName: Deploy
pool:
vmImage: $(vmImageName)
steps:
- task: Kubernetes@1
displayName: Deploy an image to AKS
inputs:
connectionType: 'Azure Resource Manager'
azureSubscriptionEndpoint: 'XXXXXXX'
azureResourceGroup: 'AKSCICDRG'
kubernetesCluster: 'HealthCareAKSCluster'
command: 'apply'
arguments: '-f patientservice.yaml'
secretType: 'dockerRegistry'
containerRegistryType: 'Azure Container Registry'
图像已成功推送到 ACR,并且构建步骤运行良好。
即使部署步骤运行良好,但是当我在 AKS 集群中执行“kubectl get pods”时,我得到的 pod 状态为 ImagePullBackOff 或 ErrImagePull。 当我执行“kubectl describe pod”时,我收到以下消息:
无法提取图像“患者服务”:rpc 错误:代码 = 未知描述 = 来自守护进程的错误响应:对患者服务的拉取访问被拒绝,存储库不存在或可能需要“docker login”:拒绝: 请求的资源访问被拒绝
请帮助我如何部署正确的图像。
【问题讨论】:
请分享您的 patientservice.yaml 文件。 【参考方案1】:问题出在 patientservice.yaml 文件中。我忽略了它。以前图片只有服务的名称。我在 Patientservice.yaml 中的图片中添加了以下内容:
image: healthcareakscicdacr.azurecr.io/patientservice:latest
部署工作正常。
【讨论】:
感谢您在这里分享您的解决方案,请您接受您的解决方案作为答案吗?因此,对于遇到相同问题的其他成员轻松找到解决方案将很有帮助。祝你有美好的一天:)以上是关于Azure Devops kubectl 任务部署映像的状态为 ErrImagePull/ImagePullBackOff的主要内容,如果未能解决你的问题,请参考以下文章
isUpgrade 设置如何影响 Azure DevOps 中 Service Fabric 应用程序部署任务中的部署过程
YAML Azure Devops:步骤任务参考无效。任务名称不明确
用于 Linux 操作系统的 azure devops 发布管道中的自动化 SQL 部署任务
如何从 Azure DevOps DACPAC 部署中获取漂移报告?