Nandakumar Raghu
05/09/2023, 2:33 PMerror converting YAML to JSON: yaml: line 32: mapping values are not allowed in this context
dynamic "set" {
for_each = module.labels.tags
content {
name = "commonLabels.${set.key}"
value = set.value
}
}
Posted in #ask-the-communitySamhita Alla
Nandakumar Raghu
05/10/2023, 7:11 AMSamhita Alla
Nandakumar Raghu
05/10/2023, 3:40 PMcommonLabels:
team: ${team}
project: ${project}
And then in my helm_release, I use the templatefile function to pass in the variables -
values = [templatefile("values.yaml", {
team = var.team,
project = var.project,
})]
I get this error on apply -
│ Error: YAML parse error on flyte-binary/templates/deployment.yaml: error converting YAML to JSON: yaml: line 38: mapping values are not allowed in this context
│
│ with helm_release.flyte-backend,
│ on <http://flyte-backend-k8s.tf|flyte-backend-k8s.tf> line 1, in resource "helm_release" "flyte-backend":
│ 1: resource "helm_release" "flyte-backend" {
How do I debug this issue? All I can find online is that this is due to a yaml formatting / indentation issue, however I have checked my values.yaml file with multiple yaml checkers / validators and all say it is valid.David Espejo (he/him)
05/10/2023, 8:03 PMtags
variable?
2. How would you use the output of your code (commonLabels.team = team1
,etc) to change the actual values.yaml content?
Sorry if I'm asking dumb questions, just trying to get more info. This is not really the domain of Flyte itself, but we want to help as much as possibleNandakumar Raghu
05/10/2023, 8:39 PM{
'team' = 'my_team',
'Project' = 'my_project'
}
But, ideally we want to use a custom values.yaml to override the default values.yaml so you can disregard the question regarding assigning the tags variable.
2. We will not use the commonLabels.team. This is a label that will be applied to all kubernetes resources that are created by this helm chart (flyte-binary). Basically we want to apply labels to the resources our team creates on kubernetes for auditing and metering purposes.
commonLabels is here in flyte-binary's values.yaml here and we will just override this empty value as shown in my latest example.
Our custom values.yaml is well formatted and validated, so that is not a problem.
Let me know if you need more information.Samhita Alla
Nandakumar Raghu
05/11/2023, 7:06 AMSamhita Alla
Nandakumar Raghu
05/11/2023, 7:29 AMconfiguration:
database:
username: '${db_username}'
password: '${db_password}'
host: '${db_host}'
dbname: '${db_name}'
In the terraform helm_resource, I set the values like this -
values = [templatefile("values.yaml", {
db_username = var.db_username,
db_host = var.db_host,
})]
jeev
Nandakumar Raghu
05/11/2023, 8:00 AMjeev
Nandakumar Raghu
05/11/2023, 8:01 AMjeev
Nandakumar Raghu
05/12/2023, 8:26 AM38m Normal PolicyApplied clusterpolicy/require-labels Deployment mlops-platform-infrastructure-flyte-namespace/flyte-backend-flyte-binary: pass
56m Normal PolicyApplied clusterpolicy/require-labels Pod mlops-platform-infrastructure-flyte-namespace/flyte-backend-flyte-binary-647f4d875c-fhdd7: pass
38m Normal PolicyApplied clusterpolicy/require-labels Pod mlops-platform-infrastructure-flyte-namespace/flyte-backend-flyte-binary-647f4d875c-zpvnq: pass
30m Normal PolicyApplied clusterpolicy/require-labels Pod mlops-platform-infrastructure-flyte-namespace/flyte-backend-flyte-binary-647f4d875c-s7728: pass
And for some they are not -
10m Warning PolicyViolation clusterpolicy/require-labels Pod flyte/flyte-flyte-binary-6bfd5b44c-x6bpn: [environment-label] fail (blocked)
10m Warning PolicyViolation clusterpolicy/require-labels Pod flyte/flyte-flyte-binary-6bfd5b44c-x6bpn: [ba-label] fail (blocked)
jeev
Nandakumar Raghu
05/13/2023, 7:01 PM