0
votes

I have an azure pipeline that I am using to generate and push helm charts in. Within this pipeline I have a deployment stage that uses the HelmDeploy0 task. This task requires a kubernetesServiceEndpoint. Consequentially, I have also opted to use Pipeline environments and have configured my dev Kubernetes cluster as my Dev Environment for use in the pipeline. I am unsure ohow this task is going to use this environment as I have to assume that Azure DevOps, upon using the environment, must be authenticating with the cluster, thus, the helm chart should simply install. Unfortunately the HelmDeploy0 task requires this serviceendpoint key. Any insight would be appreciated. Below is a snippet of the pipeline stage.

- stage: Dev
  displayName: Deploy to Dev
  dependsOn: Build
  condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
  jobs: 
  - deployment:
    
    displayName: Deploy $(projName)
    environment: 'Dev'
    strategy:
      runOnce:
        preDeploy:
          steps:
            - task: HelmInstaller@1
              inputs:
                helmVersionToInstall: latest
        deploy:
          steps:
            - task: HelmDeploy@0
              displayName: Install Helm Chart
              inputs: 
                command: install
                chartName: $(REGISTRY_NAME)/helm/$(projName)
                arguments: --version $(tag)
                releaseName: $(projName)

NOTE: Yes I know variables cannot be used as the display name, it's there to protect any IP right now.

1
Hi Did you get a chance to check out below answer. How did it go?Levi Lu-MSFT
Your suggestion worked out. I was even able to build a deployment template to pass this info. Thanks so much! I have marked your answer below.Derek Williams

1 Answers

1
votes

You probably need to explicitly specify your Kubernetes cluster resource name in the Environment section. See below:

- deployment: 
  environment:               
    name: Dev   # name of the environment to run this job on.
    resourceName: cluster-resource-name # name of the resource in the environment to record the deployments against
    resourceType: Kubernetes
  strategy:
    ...

You can also try using the shorten syntax: environment: environmentName.resourceName. If the shorten syntax failed to find the resource, you need to use above syntax to provide the resourceType. See document here.

The steps of the deployment job automatically inherit the service connection details from resource targeted by the deployment job.

You can scope the target of deployment to a particular resource within the environment. This allows you to record deployment history on a specific resource within the environment. The steps of the deployment job automatically inherit the service connection details from resource targeted by the deployment job.

Check here for information.