首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Azure开发AKS Kubectl任务的管道未能将清单部署到AKS

Azure开发AKS Kubectl任务的管道未能将清单部署到AKS
EN

Stack Overflow用户
提问于 2022-05-18 05:51:59
回答 2查看 793关注 0票数 0

kubectl任务未能将清单文件部署到AKS。管道失败,以下错误

找到了##errorNo配置文件匹配/home/vst/work/1/s/清单。

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

如果只为部署阶段选择要运行的阶段,就会出现问题,如果出现上述错误,它将失败。

管道

代码语言:javascript
复制
- 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'
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-05-20 11:23:04

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

管道

代码语言:javascript
复制
- 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)'
票数 2
EN

Stack Overflow用户

发布于 2022-05-19 11:56:46

代码语言:javascript
复制
- master

resources:
- repo: self

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

- 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'

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

您能用上述管道检查一下yaml吗?更改位置工件下载并添加Build.SourcesDirectory作为下载工件的路径

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72283819

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档