【问题标题】:What is the pool during a deployment job in Azure DevOps?Azure DevOps 中的部署作业期间的池是什么?
【发布时间】:2020-12-10 16:49:38
【问题描述】:

我使用ubuntu-latest 作为构建 vmImage 来构建管道中的所有容器。现在我正在尝试将以前构建的容器部署到 AKS。

根据documentation,它应该是这样的:

- stage: Deploy
  displayName: Deploy stage
  dependsOn: Build
  jobs:
  - deployment: Deploy
    displayName: Deploy job
    pool:
      vmImage: $(vmImageName)

很遗憾,没有描述变量$(vmImageName) 指的是什么,并且无法再按照步骤进行操作,因为使用可视化界面使用的是 Helm,这会让我更加困惑。

我正在构建这样的容器:

- job: BuildSQL
  displayName: Build SQL Server Container image
  pool:
    vmImage: "ubuntu-latest"
  steps:
    - task: Docker@2
      displayName: Build an image
      inputs:
        command: buildAndPush
        dockerfile: "$(Build.SourcesDirectory)/Code/Database/Docker/Dockerfile"
        arguments: -o $(Build.ArtifactStagingDirectory)/xxx.sql.tar
        containerRegistry: $(dockerRegistryServiceConnection)
        repository: his.sql
        tags: |
          $(tag)
    #publish the results of the previous task as manifest to be picked up by the deployment job
    - task: PublishPipelineArtifact@1
      inputs:
        artifactName: 'his.sql.tar'
        path: $(Build.ArtifactStagingDirectory)

在下一个阶段,如果想拿起工件然后部署它:

 - stage: DeploySQL
    displayName: 'Deploy SQL Container to AKS'
    dependsOn: BuildSQL
    jobs:
    - deployment: Deploy
      displayName: Deploy job
      pool:
        vmImage: "ubuntu-latest"
      environment: 'sql-test.default'
      strategy:
        runOnce:
          deploy:
            steps:
            - task: DownloadPipelineArtifact@2
              inputs:
                artifactName: 'manifests'
                downloadPath: '$(Build.ArtifactStagingDirectory)/xxx.sql.tar'

然后部署作业失败并显示以下错误消息:

##[error]Pipeline does not have permissions to use the referenced pool(s) . For authorization details, refer to https://aka.ms/yamlauthz.

我在这里不知所措,不知道池实际指的是什么以及在那里输入什么。如何将此推送到我在 Azure 中预配的 AKS 群集?

【问题讨论】:

    标签: azure-devops azure-aks


    【解决方案1】:

    问题实际上可能是您在此处引用的 vmImage: "ubuntu-latest",请尝试将其更改为 vmImage: 'ubuntu-latest'

    在将池作为变量传递时,您应该记住:

    仅使用全局级别的变量来定义池名称。不支持阶段/作业级别的变量来定义池名称。

    但是,如果我的第一个建议没有帮助,请查看this article

    因为您可能需要默认池的权限

    【讨论】:

      【解决方案2】:

      我认为这可能会有所帮助。如果您对ubuntu-latest 没有强烈的偏好,那么根本不要指定vmImage!微软将提供一个没有要求的私有池。

      https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=example%2Cparameter-schema#pool

      如果您有具体要求,可以将demands: 行添加到您的“池”部分。

      https://docs.microsoft.com/en-us/azure/devops/pipelines/process/demands?view=azure-devops&tabs=yaml

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-06-06
        • 1970-01-01
        • 2020-07-27
        • 2021-05-13
        • 2021-07-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多