当前位置: 首页 > 知识库问答 >
问题:

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

宇文德明
2023-03-14

kubectl任务无法将清单文件部署到AKS中。管道失败,出现以下错误

##[error]找不到与/home/vsts/work/1/s/清单匹配的配置文件。

pipeline在运行两个阶段(如构建和部署)时都工作得很好,因为在构建阶段之后,它将为该清单文件创建工件,并在部署阶段下载并部署到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'

共有2个答案

淳于博
2023-03-14
- 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作为下载工件的路径

能修谨
2023-03-14

根据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)'
 类似资料:
  • 我有一个文件,我需要部署到现有的应用服务(已经包含一个应用程序,以前通过另一个管道部署)。 我想避免使用FTP任务。 有没有办法通过DevOps管道将单个文件部署到应用程序服务中的特定文件夹?

  • 我试图通过jenkins管道将azure web应用程序部署到azure form git 代码如下所示 这怎么可能?有什么方法可以将git repo url作为参数提供给azure插件吗? 谢了!

  • 一种部署工具,用于将本地“构建框”中的EAR和WAR文件部署到任何托管服务器(即测试或暂存服务器)。 目前。sh脚本在每台服务器上运行以进行部署。 环境:Linux,JavaEE应用(确切地说是ATG框架),使用的Jboss服务器。 部署工具要求: 1) 软件必须是开源的。 2)只需要一个部署工具;没有构建工具和延续集成工具,就像Jenkin或Hudson应用程序一样。 3) 该软件必须是一个轻量

  • 我们已经建立了管道脚本,工作得很好。最近,我们决定使用bitbucket管道自动部署到elastic beanstalk,并遵循使用命令进行部署的教程。显然,此命令在管道上失败。配置文件似乎是合法的,因为它在本地运行。它还可以在管道文件中指定的同一图像的容器中运行,也可以从本地使用docker exec在同一图像的容器中运行命令。下面是管道文件和我们使用命令得到的错误。我显然漏掉了什么。如有任何帮

  • 一旦所说的图像在相应的注册表中被更新,那么让我的亚马逊ECS任务更新其Docker图像的正确方法是什么?

  • 我正在尝试使用Azure DevOps发布管道将java应用程序部署到tomcat服务器。我在tomcat服务器选项卡中填写了war文件路径、服务器URL信息、用户名和密码,如下所示: 但部署失败,我得到以下错误: 我使用的路径或任何其他信息是否错误?谁能帮我一下吗,谢谢。

  • 我尝试用gitlab ci构建并推送我的react build文件夹。yml构建和测试通过,但部署失败,出现以下错误:如果我在语言环境文件中使用相同的脚本,它就会工作! 这是我的all yml文件:

  • 我试图在Azure运营模式发布管道上创建Click一旦部署我创建签名,清单,应用程序,部署文件与证书但是我如何创建exe和安装文件(通过Azure运营模式发布管道)