helm-controller: Helm Chart installation failed due to post renderer yaml unmarshal error
Describe the bug
We were used to deploy the ErpNext Helm Chart using Flux.
Since the Flux upgrade to version 0.15.3 we are facing the following error message:
Helm install failed: error while running post render on files: map[string]interface {}(nil): yaml: unmarshal errors:
line 12: mapping key "app.kubernetes.io/name" already defined at line 8
PS: we are able to deploy the chart with a manual Helm install/upgrade command
Root cause
The helm chart is generating the follow yaml resource:
# Source: erpnext/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: test-erpnext-redis
labels:
helm.sh/chart: erpnext-3.2.8
app.kubernetes.io/name: erpnext
app.kubernetes.io/instance: test
app.kubernetes.io/version: "v13.5.1"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: erpnext-redis
The double presence of the label app.kubernetes.io/name is the most likely root cause
Reproduce the issue
Simply follow the ErpNext guide
Expected behavior
As we are able to deploy the chart with a manual Helm install/upgrade command, we expect that Flux can deploy the chart without the mentioned issue
Additional context
- Kubernetes version: 1.19
- Git provider: Gitlab private repo
- Container registry provider: docker hub
Below please provide the output of the following commands:
$ flux --version
flux version 0.15.3
$ flux check
► checking prerequisites
✔ kubectl 1.19.0 >=1.18.0-0
✔ Kubernetes 1.19.7 >=1.16.0-0
► checking controllers
✔ helm-controller: deployment ready
► ghcr.io/fluxcd/helm-controller:v0.11.1
✔ kustomize-controller: deployment ready
► ghcr.io/fluxcd/kustomize-controller:v0.13.0
✔ notification-controller: deployment ready
► ghcr.io/fluxcd/notification-controller:v0.15.0
✔ source-controller: deployment ready
► ghcr.io/fluxcd/source-controller:v0.15.2
✔ all checks passed
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 15 (5 by maintainers)
Just run into the same problem while upgrading from 0.18.0. to 0.23.0 Would be nice the error message could point to the exact part, where it’s failing. I was not able to find my duplicate “app” label at first.
Helm CLI and Flux v1 both used the client side apply, which is a bit more forgiving. Flux v2 does not permit duplicate entries. If you read the output of
helm templateon your chart, you should see the duplicate entries. Helm does not validate this at all, it simply emits a giant blob of stringly templated YAML and passes it onto the applier when it’s done with templating. The applier (effectively kubectl) condenses the duplicate entries into a single one, arbitrarily dropping one or the other passed value in favor of the one that wins.Flux v2 is validating through the server-side apply, which parses the YAML and notices things like a duplicate entry. You’ll have to fix it upstream in your chart. The most common error is a label that gets placed in some manifest, and then repeated in the template that manifest includes. It should be easy to detect and isolate this error if you pass the output of
helm templatethrough a YAML linter, so it can be fixed in the next published chart release upstream.I am getting this issue. But in my case, I have re-checked tenths of times for what flux is telling me is duplicated, and I cannot see any duped keys (yaml linting the helm templated with the values.yaml that I am using doesn’t show any dupes at all). See related discussion https://github.com/fluxcd/flux2/discussions/4890
Anyone apart from @kvaps has any idea on how to debug this issues? I have tried his approach, without success (it gives me no errors…)
Faced a similar problem. The controller cannot install the Chart due to a duplicate entries.
When installing through Helm cli, there is no such problem. Also Fluxcd:v1 (helm-operator) does not have such a problem too.
I have asked to modify the helm chart and here you can see the modification
https://github.com/frappe/helm/pull/92
The modification will fix the issue and the problem between Flux and Helm behaviors is a little bit too complex to be tracked here
I will close this issue once the chart will install correctly
Thanks for the support and the explanation of few internals