Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm tpl override issue in Flux #1197

Closed
anthony-pastor opened this issue Apr 2, 2021 · 10 comments
Closed

Helm tpl override issue in Flux #1197

anthony-pastor opened this issue Apr 2, 2021 · 10 comments

Comments

@anthony-pastor
Copy link

anthony-pastor commented Apr 2, 2021

We are using FluxCD v0.11.0.

We are trying to deploy a Helm Chart using tpl overrides with Flux:

flux -n jordan-golang-demo-app get hr
NAME                  	READY	MESSAGE                                                                                                                                                                                                                                          	REVISION	SUSPENDED 
jordan-golang-demo-app	False	Helm install failed: error while running post render on files: missing metadata.name in object {map[apiVersion:v1 kind:Service metadata:<nil> spec:map[ports:[map[port:80 protocol:TCP targetPort:8080]] selector:map[service:golang-demo-app]]]}

PS: Both charts are working with a manual Helm install/upgrade command:

helm upgrade --wait --install test-golang-demo-app -n reproduce-golang-demo-app charts/golang-demo-app/ --create-namespace
Release "test-golang-demo-app" does not exist. Installing it now.
NAME: test-golang-demo-app
LAST DEPLOYED: Fri Apr  2 17:46:11 2021
NAMESPACE: reproduce-golang-demo-app
STATUS: deployed
REVISION: 1
TEST SUITE: None
@hiddeco
Copy link
Member

hiddeco commented Apr 6, 2021

Would be very useful to also have a copy of the HelmRelease at hand before debugging this any further.

@anthony-pastor
Copy link
Author

@hiddeco This was the latest test of our helmrelease definition:

---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: jordan-golang-demo-app
  namespace: jordan-golang-demo-app
spec:
  chart:
    spec:
      chart: charts/golang-demo-app
      sourceRef:
        namespace: flux-system
        kind: GitRepository
        name: jordan-golang-demo-app
  interval: 30s
  targetNamespace: jordan-golang-demo-app
  releaseName: jordan-golang-demo-app

@hiddeco
Copy link
Member

hiddeco commented Apr 6, 2021

I do not see a createNamespace: true in the spec there, while you run the helm install with --create-namespace. (But the namespace already exists, as the HelmRelease is placed in the same directory).

Can you try downgrading to 0.8.2 and see if that solves the issue? If so, fluxcd/helm-controller#238 likely is the cause.

@stefanprodan
Copy link
Member

@hiddeco based on kind:Service metadata:<nil> I guess the chart generates an invalid Kubernetes object. Maybe Helm renders this https://github.com/JordanGoasdoue/golang-demo-app-reproduce-flux-error/blob/main/charts/golang-demo-app/templates/svc.yaml#L12-L17 after post-render?

@hiddeco
Copy link
Member

hiddeco commented Apr 6, 2021

That should be impossible, as Helm first renders the resources as it would normally, and then calls the post-render, see:

https://github.com/helm/helm/blob/c9fe3d118caec699eb2565df9838673af379ce12/pkg/action/install.go#L240
https://github.com/helm/helm/blob/c9fe3d118caec699eb2565df9838673af379ce12/pkg/action/action.go#L105
https://github.com/helm/helm/blob/c9fe3d118caec699eb2565df9838673af379ce12/pkg/action/action.go#L219

It should thus not make any modifications afterwards, and it looks like Helm itself fails to produce a valid manifest.

@JordanGoasdoue
Copy link

JordanGoasdoue commented Apr 6, 2021

Hello guys,

Thanks for the answers.

Just to be sure we are all on same input:

In fluxcd v2:
Looking at the svc.yaml (but it's same for deployment.yaml)

The error is like if from Fluxcd it's not possible to take as default the values from https://github.com/JordanGoasdoue/golang-demo-app-reproduce-flux-error/blob/non-working-version/charts/golang-demo-app/templates/_metadata.yaml

With both these version, it's working with helm, and on the template or install we have the right values

We tried with already created namespaces, but we will try to rollback and see what happen 👌

@anthony-pastor
Copy link
Author

@hiddeco we tried the same thing with a Flux 0.8.2 bootstraped cluster and we got the same issue:
jordan-golang-demo-app False Helm install failed: error while running post render on files: missing metadata.name in object {map[apiVersion:v1 kind:Service metadata:<nil> spec:map[ports:[map[port:80 protocol:TCP targetPort:8080]] selector:map[service:golang-demo-app]]]} False

@hiddeco
Copy link
Member

hiddeco commented Apr 6, 2021

Using Helm v3.5.3 I get the following error for the chart source:

$ helm version
version.BuildInfo{Version:"v3.5.3", GitCommit:"041ce5a2c17a58be0fcd5f5e16fb3e7e95fea622", GitTreeState:"dirty", GoVersion:"go1.16.2"}
$ helm install . --debug --dry-run --generate-name --namespace foo
install.go:173: [debug] Original chart version: ""
install.go:190: [debug] CHART PATH: /home/hidde/Projects/golang-demo-app-reproduce-flux-error/charts/golang-demo-app

Error: rendered manifests contain a resource that already exists. Unable to continue with install: could not get information about the resource: resource name may not be empty
helm.go:81: [debug] resource name may not be empty

I think the error is thus with the chart, and not with the helm-controller.

@anthony-pastor
Copy link
Author

Very interesting @hiddeco, we observe the same behavior.

  • Helm version 3.4.2: it still works to install the Chart.
  • Helm version 3.5.3: it fails.
    Thanks, we will dig with Helm then.

@hiddeco
Copy link
Member

hiddeco commented Apr 7, 2021

Closing this, as it is essentially an upstream issue.

@hiddeco hiddeco closed this as completed Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants