8gears / n8n-helm-chart

A Kubernetes Helm chart for n8n a Workflow Automation Tool. Easily automate tasks across different services.
https://artifacthub.io/packages/helm/open-8gears/n8n
Apache License 2.0
187 stars 97 forks source link

Fix persistence init container indentation #85

Closed fk-flip closed 5 months ago

fk-flip commented 5 months ago

Observed on master and Helm Chart version 0.23.0

Indentation for the newly introduced init-data-dir init container (#82) is incorrect, resulting in Helm templating errors when setting and making use of .Values.initContainers:

values.yaml:

initContainers:
  - name: wait-for-postgres
    image: ghcr.io/patrickdappollonio/wait-for:v1.0.0
    env:
    - name: POSTGRES_ADDRESS
      value: "postgresql:5432"
    command:
      - /wait-for
    args:
      - --host="$(POSTGRES_ADDRESS)"
      - --timeout=240s
      - --verbose

Rendered Helm Deployment:

[...]
      initContainers:
      - name: init-data-dir
        image: "n8nio/n8n:1.33.1"
        command: ["/bin/sh", "-c", "mkdir -p /home/node/.n8n/"]
        volumeMounts:
        - name: data
          mountPath: /home/node/.n8n

        - args:
          - --host="$(POSTGRES_ADDRESS)"
          - --timeout=240s
          - --verbose
          command:
          - /wait-for
          env:
          - name: POSTGRES_ADDRESS
            value: postgresql:5432
          image: ghcr.io/patrickdappollonio/wait-for:v1.0.0
          name: wait-for-postgres
[...]

Observed error:

error validating data: [ValidationError(Deployment.spec.template.spec.initContainers[0].volumeMounts[1]): unknown field "args" in io.k8s.api.core.v1.VolumeMount, ValidationError(Deployment.spec.template.spec.initContainers[0].volumeMounts[1]): unknown field "command" in io.k8s.api.core.v1.VolumeMount, ValidationError(Deployment.spec.template.spec.initContainers[0].volumeMounts[1]): unknown field "env" in io.k8s.api.core.v1.VolumeMount, ValidationError(Deployment.spec.template.spec.initContainers[0].volumeMounts[1]): unknown field "image" in io.k8s.api.core.v1.VolumeMount, ValidationError(Deployment.spec.template.spec.initContainers[0].volumeMounts[1]): missing required field "mountPath" in io.k8s.api.core.v1.VolumeMount]

As you can see, due to the wrong indentation, the additional configured init container is not treated as such but as additional volume mount for the init-data-dir init container.

Vad1mo commented 5 months ago

@Karitham, can you also have a look?

Karitham commented 5 months ago

At first glance, both the original and the fix are valid yaml. It seems this issue only appears when you also have your own init-containters because the identation is different! Good catch.

fk-flip commented 5 months ago

@Vad1mo thanks for merging. Can you please release this in a new Chart version as it's currently blocking us from updating n8n, thanks!

Vad1mo commented 5 months ago

it is already, see https://artifacthub.io/packages/helm/open-8gears/n8n?modal=changelog