gpt4 book ai didi

yaml - 如何调试 Helm 图表错误,如 "error converting YAML to JSON: yaml: mapping values are not allowed in this context"?

转载 作者:行者123 更新时间:2023-12-04 11:11:55 26 4
gpt4 key购买 nike

我正在使用 Helm 3 和 microk8s。当我尝试试运行时:

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

我看到类似的错误
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
...

我发现了几个有类似错误的问题,但答案通常只是要求读取图表代码。我有一个很大的图表,需要自己调试这个错误。猜测它提示哪一行似乎没有意义。

有没有办法知道配置中究竟有什么问题?

最佳答案

尝试:helm template ... --debug > foo.yaml这会将渲染的图表输出到 foo.yaml(并将 helm 错误堆栈跟踪输出到 stderr)。然后从 helm 错误中找到有问题的模板文件名,并在渲染的图表中查找类似 # Source: the-template-name.yaml 的行。 . YAML 到 JSON 的转换是针对每个 YAML 对象单独完成的,因此您可能有多个相同的实例 # Source: the-template-name.yaml .
查看每个下方的 n 行 # Source: ...对错误的注释,其中 n 是 Helm 渲染报告的错误的行号。

关于yaml - 如何调试 Helm 图表错误,如 "error converting YAML to JSON: yaml: mapping values are not allowed in this context"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59564379/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com