使用 Helm 3 将 Azure DevOps Pipeline 部署到 Kubernetes:没有此类文件或目录

Fra*_*llo 1 azure-devops azure-pipelines kubernetes-helm

我有一个 Asp.net Core 项目,我正在尝试使用 Helm 3 创建用于 Kubernetes 部署的 Azure DevOps Pipeline。

该项目的结构是:

服务器图表服务器 Chart.yaml 控制器等。

当前的构建管道会构建 docker 映像,并将其上传到 Azure 容器注册表。

错误发生在 HelmDeploy 任务 'package' => ChartPath:

在此输入图像描述

这是部署的管道阶段:

  - stage: 'Deploy'
  displayName: 'Deploy the container'
  dependsOn: Build
  jobs:
  - deployment: Deploy
    displayName: Deploy
    pool:
      vmImage: 'ubuntu-latest'
    environment: 'staging'
    strategy:    
      runOnce:
        deploy:
          steps:        
          - task: HelmInstaller@0
            inputs:
              helmVersion: 'latest'
              installKubectl: true
          
          - task: HelmDeploy@0
            inputs:
              command: 'package'
              chartPath: Server/charts/server

          - task: HelmDeploy@0
            inputs:
              connectionType: 'Kubernetes Service Connection'
              kubernetesServiceConnection: 'Staging-592588480'
              namespace: 'staging'
              command: 'upgrade'
              chartType: 'FilePath'
              chartPath: $(Build.ArtifactStagingDirectory)/server
Run Code Online (Sandbox Code Playgroud)

我尝试了很多组合但没有成功:

chartPath: $(Build.Repository.LocalPath)/Server/charts/server
chartPath: $(Build.SourcesDirectory)/Server/charts/server
chartPath: **/Server/charts/server
chartPath: Server/charts/server/
Run Code Online (Sandbox Code Playgroud)

根据文档,azure pipelines 上的 Helm 3 不需要“init”命令,“upgrade”命令将安装图表(如果图表不存在)。

Krz*_*tof 6

默认情况下,部署作业不会下载源代码,因此如果您在源代码中保留图表,请在部署作业开始时添加结帐步骤:

- checkout: self
Run Code Online (Sandbox Code Playgroud)