Mar*_*rco 5 yaml docker kubernetes azure-devops
我正在尝试使用默认的 Azure DevOps 模板将图像推送到 AKS:
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
- upload: manifests
artifact: manifests
Run Code Online (Sandbox Code Playgroud)
这会导致以下错误:
##[error]Path does not exist: /home/vsts/work/1/s/manifests
Run Code Online (Sandbox Code Playgroud)
我尝试过使用默认的发布任务
- task: PublishPipelineArtifact@1
inputs:
artifactName: 'manifests'
path: 'manifests'
Run Code Online (Sandbox Code Playgroud)
但这并没有改变任何事情。有人可以解释一下,这里发生了什么以及为什么 Msft 的默认模板不起作用?
好吧 - 在这个阶段我必须管理,我对构建管道中的工件有一个彻底的误解。
(upload已弃用) 和publish任务是发布管道工件任务的简写(https://learn.microsoft.com/en-us/azure/devops/pipelines/artifacts/pipeline-artifacts?view=azure-devops&tabs=yaml)
其次,publish关键字后面的路径是将要发布的相对文件夹。如果您使用 Azure DevOps 中的 Kubernetes 服务模板,它将manifest在存储库的根目录中创建一个文件夹,并在其中预填充部署和服务 yml 文件。
我不希望它们在那里(并且一定是潜意识地删除了该文件夹),所以我移动了它们并修改了路径:
- publish: $(System.DefaultWorkingDirectory)/Code/Database/Docker
artifact: sql-drop
Run Code Online (Sandbox Code Playgroud)
(Docker 文件夹是我保存 Dockerfiles、docker-compose、overrides 以及所有其他用于启动容器的爵士乐的地方)
现在,在我的部署任务中,我需要注意,我不能使用存储库中的文字路径。我需要先下载工件,然后使用工件的名称 - “sql-drop”作为文件夹名称:
steps:
#current means the current pipline. shorthand sytnax
- download: current
# name from the aritfact specifed above
artifact: sql-drop
- task: KubernetesManifest@0
displayName: Create imagePullSecret
inputs:
action: createSecret
secretName: $(imagePullSecret)
dockerRegistryEndpoint: $(dockerRegistryServiceConnection)
- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
inputs:
action: deploy
# Use sql-drop as folder name and specify manifests
manifests: |
$(Pipeline.Workspace)/sql-drop/his-sql.dev.deployment.yml
$(Pipeline.Workspace)/sql-drop/his-sql.dev.service.yml
imagePullSecrets: |
$(imagePullSecret)
containers: |
$(containerRegistry)/$(imageRepository):$(tag)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7799 次 |
| 最近记录: |