1
votes

We are using helm charts templates for deployment to kube and Azure devops for CI/CD.in my values.yaml data in below section will change as per environment and saved as config map in pod. My question is how can I update it during deployment in azure pipeline. We are using Helm upgrade task OR any other way to handle it better.

environment:
    enabled: true
    env:
      enabled: false
    internalConfigMap:
      enabled: true
      **data:
        AZ_DIRECTORY: xxx
        MODEL_ID_SVM: xxx
        MODEL_ID_MULTI: xxx
        MODEL_THRESHOLD_SVM: 'xx'
        SINGLE_ACC_ENDPT: 'xx'
        MODEL_WT_SVM: 'xx'**

here is deployment task:(ignore indentation)

task: HelmDeploy@0
     displayName: Helm upgrade
                inputs:
                  command: upgrade
                  chartType: Name
                  chartName: chart/$(chartname)
                  releaseName: $(chartname)-${{ parameters.CI_ENVIRONMENT_SLUG }}
                  namespace: $(NAMESPACE)
                  connectionType: Azure Resource Manager
                  #azureSubscriptionEndpoint: ${{ variables.AZ_SUBSCRIPTION }}
                  #azureResourceGroup: $(AKS_RESOURCE_GROUP)
                # kubernetesCluster: $(K8S_CLUSTER)
                  install: true
                  waitForExecution: true
                  useClusterAdmin: true
                  overrideValues: |
                    template.image.tag=$(imagetag)
1

1 Answers

1
votes

Option 1: One value file per environment

If you have one values.yaml per environment (environment1-values.yaml, environment2-values.yaml etc) you can refer to different files for each stage in your pipeline.

The Helm Upgrade command accepts the parameter valueFile which you can use to point to the correct values.yaml for the environment you are deploying to

(Optional) Specify values in a YAML file or a URL. For example, specifying myvalues.yaml will result in helm install --values=myvals.yaml

Option 2: Override values on deployment

The Helm Upgrade command accepts the parameter overrideValues by which you can pass values directly to helm:

(Optional) Set values on the command line. You can specify multiple values by separating values with commas. For example, key1=val1,key2=val2. You can also specify multiple values by delimiting them with newline as so: key1=val1 key2=val2 Please note that if you have a value which itself contains newlines, use the valueFile option, else the task will treat the newline as a delimiter. The task will construct the helm command by using these set values. For example, helm install --set key1=val1 ./redis

In your case this would mean

   overrideValues: template.image.tag=$(imagetag),environment.internalConfigMap.data.AZ_DIRECTORY=xxx,environment.internalConfigMap.data.MODEL_ID_SVM=xxx