I have defined variables like below in variables/vars-global.yaml
file in a project called TEST
This CLUSTER_NAME
value I'm able to read it under azure-pipelines.yml
file, using the below way:
However, the same variable I'm trying to use it under another directory and file, but it doesn't work, this file is part of Datadog helm chart
I tried different ways to resolve the CLUSTER_NAME' variable value in
applications\datadog\dev-gke-cluster` but those are not working, some of those are:
vars-global.yaml
in values.yaml
file to use it as a template in values.yaml
common.yaml
in applications\datadog
where used the file as a template and imported this common.yaml
in values.yaml
${{ variables.vmImage }}
values.yaml
but none worked.My intention is when I deploy this project using the AzureDevOps pipeline, I should get a resolved value of $(CLUSTER_NAME)
so that I can use this file as an input to Datadog helm chart in ADO Pipeline.
Curretly I'm getting clusterName: $(CLUSTER_NAME)
as it is and hence the deployment of helm chart fails for datadog. with below error:
ERROR:
Error: INSTALLATION FAILED: failed to parse ./applications/datadog/dev-gke-cluster/values.yaml: error converting YAML to JSON: yaml: invalid map key: map[interface {}]interface {}{"template \"variables.CLUSTER_NAME\" .":interface {}(nil)}
Error: INSTALLATION FAILED: execution error at (datadog/templates/daemonset.yaml:118:12): Your `clusterName` isn’t valid. It must be dot-separated tokens where a token start with a lowercase letter followed by lowercase letters, numbers, or hyphens, can only end with a with [a-z0-9] and has to be below 80 chars.
Please note: I have removed redundant information from my files that I took as a screenshot, considering data and code privacy.
How can we pass multiple values of tags section:
Passing single value this way:
$(CLUSTER_NAME)
is the macro syntax to reference an Azure pipelines variable, but it has no meaning in Helm charts.
To override values in a Helm chart, use either the --values
flag and pass in a file or use the --set
or --set-string
(to force string values) when using helm install or helm upgrade commands.
Considering the following values.yaml
file:
datadog:
clusterName: ""
tags:
application_name: ""
customer_name: ""
In a pipeline you can do something like:
variables:
- template: /variables/vars-global.yaml
steps:
# other steps here
- script: >-
helm upgrade ...
--set-string datadog.clusterName=$(CLUSTER_NAME)
--set-string tags.application_name=$(APP_NAME)
--set-string tags.customer_name=$(CUSTOMER_NAME)
--install
displayName: Helm upgrade
Considering the following values.yaml
file:
datadog:
clusterName: ""
tags:
- foo
- bar
In a pipeline you can do something like:
variables:
- template: /variables/vars-global.yaml
steps:
# other steps here
- script: >-
helm upgrade ...
--set-string datadog.clusterName=$(CLUSTER_NAME)
--set-string tags[0]="application_name=$(APP_NAME)"
--set-string tags[1]="customer_name=$(CUSTOMER_NAME)"
--install
displayName: Helm upgrade