gpt4 book ai didi

AKS Kubectl 任务的 Azure Devops 管道无法将 list 部署到 AKS

转载 作者:行者123 更新时间:2023-12-03 04:54:33 24 4
gpt4 key购买 nike

kubectl 任务无法将 list 文件部署到 AKS。管道失败并出现以下错误

##[错误]未找到与/home/vsts/work/1/s/manifests 匹配的配置文件。

管道在运行两个阶段(如构建和部署)时工作正常,因为在构建阶段之后,它将为该 list 文件创建工件,并将在部署阶段下载并部署到 AKS。

如果我选择仅在部署阶段运行的阶段,则会出现问题,它将失败并显示上述错误消息..

管道

- master

resources:
- repo: self

variables:
tag: '$(Build.BuildId)'
imagePullSecret: 'aks-acr-auth'

stages:
- stage: Build
displayName: Build image
jobs:
- job: Build
displayName: Build
pool:
vmImage: ubuntu-latest

steps:
- task: Docker@2
displayName: Build And Push Into ACR
inputs:
containerRegistry: 'AKS-ACR'
repository: 'apps/web'
command: 'buildAndPush'
Dockerfile: '$(Build.SourcesDirectory)/app/Dockerfile'
tags: |
$(tag)

- publish: manifests
artifact: manifests

- stage: 'Deployment'
displayName: 'Deploy To AKS'
jobs:
- deployment: Release
environment: 'DEV-AKS.default'
displayName: 'Release'
pool:
vmImage: ubuntu-latest
strategy:
runOnce:
deploy:
steps:

- task: KubernetesManifest@0
displayName: Create imagePullSecret
inputs:
action: 'createSecret'
kubernetesServiceConnection: 'DEV-AKS'
secretType: 'dockerRegistry'
secretName: '$(imagePullSecret)'
dockerRegistryEndpoint: 'AKS-ACR'

- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'manifests'
targetPath: '$(Pipeline.Workspace)'

- task: Kubernetes@1
displayName: Deploying Manifests into AKS
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceEndpoint: 'DEV-AKS'
namespace: 'default'
command: 'apply'
useConfigurationFile: true
configuration: 'manifests'
secretType: 'dockerRegistry'
containerRegistryType: 'Azure Container Registry'

最佳答案

根据 Kasun 评论,我在管道中添加了 -checkout: self 和 $(Build.SourcesDirectory) 它的作品..

管道


- master

resources:
- repo: self

variables:
imagePullSecret: 'acr-auth'

stages:

- stage: 'Deployment'
displayName: 'Deploy To AKS'
jobs:
- deployment: Release
environment: 'DEV-AKS.default'
displayName: 'Release'
pool:
vmImage: ubuntu-latest
strategy:
runOnce:
deploy:
steps:
- checkout: self

- task: KubernetesManifest@0
displayName: Create imagePullSecret
inputs:
action: 'createSecret'
kubernetesServiceConnection: 'DEV-AKS'
secretType: 'dockerRegistry'
secretName: '$(imagePullSecret)'
dockerRegistryEndpoint: 'AKS-ACR'

- script: dir $(Build.SourcesDirectory)/manifests
displayName: Cloning Manifest Files From Repo

- task: KubernetesManifest@0
displayName: Deploying Manifests InTo AKS
inputs:
action: 'deploy'
kubernetesServiceConnection: 'DEV-AKS'
namespace: 'default'
manifests: |
manifests/deployment.yml
manifests/service.yml
imagePullSecrets: '$(imagePullSecret)'

关于AKS Kubectl 任务的 Azure Devops 管道无法将 list 部署到 AKS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72283819/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com