Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Helm chart errors like "error converting YAML to JSON: yaml: mapping values are not allowed in this context"?

I'm using Helm 3 and microk8s. When I try a dry run:

microk8s.helm install <...> --dry-run --debug

I see errors like

Error: YAML parse error on ./templates/deployment.yaml: error converting YAML to JSON: yaml: mapping values are not allowed in this context
helm.go:76: [debug] error converting YAML to JSON: yaml: mapping values are not allowed in this context
YAML parse error on ./templates/deployment.yaml
helm.sh/helm/v3/pkg/releaseutil.(*manifestFile).sort
    /home/circleci/helm.sh/helm/pkg/releaseutil/manifest_sorter.go:129
helm.sh/helm/v3/pkg/releaseutil.SortManifests
    /home/circleci/helm.sh/helm/pkg/releaseutil/manifest_sorter.go:98
helm.sh/helm/v3/pkg/action.(*Configuration).renderResources
    /home/circleci/helm.sh/helm/pkg/action/install.go:455
helm.sh/helm/v3/pkg/action.(*Install).Run
    /home/circleci/helm.sh/helm/pkg/action/install.go:214
main.runInstall
...

I found several questions with a similar error, but the answer is usually just asking for read a chart code. I have a large chart and need to debug this error on my own. And guessing which line it complains about doesn't seem meaningful.

Is there a way to know what exactly is wrong in the config?

like image 375
Yann Avatar asked Jan 02 '20 13:01

Yann


People also ask

How do I override values YAML in Helm?

You can use a --set flag in your Helm commands to override the value of a setting in the YAML file. Specify the name of the setting and its new value after the --set flag in the Helm command. The --set flag in the above command overrides the value for the <service>. deployment.

How do you verify a Helm chart?

After the Helm chart installation is complete, you can verify the installation. Note: Add --cleanup to the command to delete the testing pods after the command is run. You can also check the deployed Kubernetes resources by running one of the following commands: oc get all -n {namespace}


1 Answers

Try: helm template ... --debug > foo.yaml

This'll output the rendered chart to foo.yaml (and the helm error stacktrace to stderr). Then find the template filename in question from the helm error and look through the rendered chart for a line like # Source: the-template-name.yaml. YAML to JSON conversion is done separately for each YAML object, so you may have multiple instances of the same # Source: the-template-name.yaml.

Look n lines below each # Source: ... comment for an error, where n is the line number of the error reported by Helm render.

like image 105
Eric Schoen Avatar answered Oct 05 '22 09:10

Eric Schoen