helmfile调试

说明

我们在调试helmfile编排的chart时,对于helm chart正常的情况下,我们编排的helmfile渲染模版的值出了问题,可能会存在以下的报错:

helmfile template 
ERROR:
  exit status 1

EXIT STATUS
  1

STDERR:
  Error: failed to parse /tmp/values761990442: error converting YAML to JSON: yaml: line 50: did not find expected key

这种情况下,我们可以指定以下的参数,来进行查看生成的临时文件的value值模版:

helmfile template --skip-cleanup
# 这样我们就可以查看生成的临时文件的值来进行调试
cat /tmp/values761990442

此外还存在一种情况,我们可能因为helmfile部署传入的变量值的格式导致的异常报错,例如:

helmfile -e dev -l app=test diff
Templating release=test, chart=test-repo/test
in ./helmfile.yaml: command "/usr/local/bin/helm" exited with non-zero status:

PATH:
  /usr/local/bin/helm

ARGS:
  0: helm (4 bytes)
  1: template (8 bytes)
  2: test-max (18 bytes)
  3: test-repo/test-max (41 bytes)
  4: --version (9 bytes)
  5: -v2.4.0-st+041e3a87 (24 bytes)
  6: --namespace (11 bytes)
  7: test (26 bytes)
  8: --values (8 bytes)
  9: /tmp/helmfile2916714270/stesttsts-6cd688596 (86 bytes)
  10: --set (5 bytes)
  11: image.repository=registry.xxxx.com/test/test/testfe (83 bytes)
  12: --set (5 bytes)
  13: image.tag=v2.4.0-test-041e3a87 (33 bytes)

ERROR:
  exit status 1

EXIT STATUS
  1

这种情况下,我们可以加debug参数来查看具体详情,可以看出是传入的参数异常:

helmfile -e dev -l app=test diff --args "--debug"
COMBINED OUTPUT:
  Executing helm version
  Executing helm get manifest test --namespace test
  Executing helm template test test-repo/test --version -v2.3.1-test+f86f99e7 --namespace
 test --set image.repository=registry.xxx.com/test/test-fe --set image.
tag=v2.3.1-test-f86f99e7 --values /tmp/helmfile3502519488/test-values-747cff949b --valida
te --is-upgrade
  Error: Failed to render chart: exit status 1: install.go:172: [debug] Original chart version: "-v2.3.1-test+f86f99e7"
  Error: chart "test matching -v2.3.1-test+f86f99e7 not found in test-repo index. (try 'helm repo upda
te'): improper constraint: -v2.3.1-test+f86f99e7
  helm.go:94: [debug] improper constraint: -v2.3.1-test+f86f99e7
  chart "test" matching -v2.3.1-test+f86f99e7 not found in testrepo index. (try 'helm repo update')
  helm.sh/helm/v3/pkg/downloader.(*ChartDownloader).ResolveChartVersion
      /home/circleci/helm.sh/helm/pkg/downloader/chart_downloader.go:234
  helm.sh/helm/v3/pkg/downloader.(*ChartDownloader).DownloadTo
      /home/circleci/helm.sh/helm/pkg/downloader/chart_downloader.go:87
  helm.sh/helm/v3/pkg/action.(*ChartPathOptions).LocateChart
      /home/circleci/helm.sh/helm/pkg/action/install.go:669
  main.runInstall
      /home/circleci/helm.sh/helm/cmd/helm/install.go:184
  main.newTemplateCmd.func2
      /home/circleci/helm.sh/helm/cmd/helm/template.go:70
  github.com/spf13/cobra.(*Command).execute
      /go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:842
  github.com/spf13/cobra.(*Command).ExecuteC
      /go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950
  github.com/spf13/cobra.(*Command).Execute
      /go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
  main.main
      /home/circleci/helm.sh/helm/cmd/helm/helm.go:93
  runtime.main
      /usr/local/go/src/runtime/proc.go:203
  runtime.goexit
      /usr/local/go/src/runtime/asm_amd64.s:1373
  Error: plugin "diff" exited with error
  helm.go:94: [debug] plugin "diff" exited with error
 
Fail to run the plugin because of error(Process exited with an error: 1)
posted @ 2022-08-05 17:33  yuhaohao  阅读(577)  评论(0编辑  收藏  举报