AKS kubectl任务的Azure DevOps管道未能部署明显的AKS

发布于 2025-01-29 21:18:12 字数 2137 浏览 3 评论 0原文

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

## [错误]找到配置文件匹配/home/vsts/work/work/s/清单。

管道 因为在构建阶段之后,它将为该清单文件创建工件,并且它将在部署阶段下载并部署到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'

kubectl task failing to deploying manifest files into AKS. pipeline failing with below error

##[error]No configuration file matching /home/vsts/work/1/s/manifests was found.

pipeline is working fine with run both stages (Like Build and Deploy) because after build stage it will create the artifacts for that manifest files and it will download in deploy stage and deploy in to AKS..

I have issue occur if I select stages to run only for deploy stage it will fail with above error msg..

Pipeline

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

疯到世界奔溃 2025-02-05 21:18:12

根据Kasun评论,我添加了-neckeckout: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)'

As per Kasun comment I added -checkout: self and $(Build.SourcesDirectory) in pipeline it's works..

Pipeline


- 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)'
森末i 2025-02-05 21:18:12
- 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吗?更改位置工件被下载并添加构建。SourcesDirectory作为下载工件的途径

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

Can you check with the above pipeline yaml. Change the location artifact is downloaded and added the Build.SourcesDirectory as the path to download the artifacts

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文