Skip to content

Added stateful deployment for main#187

Closed
fank wants to merge 5 commits into8gears:mainfrom
fank:fk_statefulmain
Closed

Added stateful deployment for main#187
fank wants to merge 5 commits into8gears:mainfrom
fank:fk_statefulmain

Conversation

@fank
Copy link
Copy Markdown
Contributor

@fank fank commented May 21, 2025

This pull request introduces support for deploying n8n as a StatefulSet in Kubernetes, enabling better handling of persistent volumes for multi-replica setups. It includes updates to the Helm chart, configuration files, and documentation to guide users on when and how to use StatefulSets instead of Deployments.

StatefulSet Support

  • Documentation Updates:

    • Added a new section in README.md explaining the differences between StatefulSets and Deployments, their use cases, and configuration requirements. Includes a warning about incompatibility with persistence.existingClaim when using StatefulSets.
    • Added an example configuration file (examples/values_stateful.yaml) for deploying n8n as a StatefulSet with individual persistent volumes per replica.
    • Updated examples/README.md to reference the new example configuration.
  • Helm Chart Enhancements:

    • Introduced a new main.useStatefulSet flag in values.yaml to toggle between StatefulSet and Deployment.
    • Added a validation check in _helpers.tpl to ensure persistence.existingClaim is not used with StatefulSets.
    • Updated deployment.yaml to skip Deployment creation when main.useStatefulSet is true. [1] [2]
    • Created a new statefulset.yaml template for StatefulSet deployments, including support for volumeClaimTemplates and other StatefulSet-specific configurations.
  • Persistence Configuration:

    • Modified _helpers.tpl to ensure dynamic PVC provisioning is only used for Deployments when main.useStatefulSet is false.

Summary by CodeRabbit

  • New Features
    • Optional StatefulSet deployment providing per-replica persistent volumes, with corresponding headless + regular service behavior and an example values file for multi-replica setups.
  • Bug Fixes
    • Pre-deployment validation to prevent incompatible persistence + StatefulSet configurations.
  • Documentation
    • Expanded deployment guide explaining Deployment vs StatefulSet, recommended production settings, and configuration guidance for multi-replica deployments.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented May 21, 2025

Walkthrough

Adds optional StatefulSet deployment support to the n8n Helm chart via a new main.useStatefulSet flag, new StatefulSet and headless Service templates, validation for persistence configuration, conditional PVC/Deployment rendering, and updated docs/examples and chart metadata.

Changes

Cohort / File(s) Summary
Documentation & Examples
README.md, examples/README.md, examples/values_stateful.yaml
Documented "Deployment Types", added values_stateful.yaml showing multi-replica StatefulSet with per-replica PVCs and Redis, and guidance/notes for StatefulSet usage.
Values & Chart Metadata
charts/n8n/values.yaml, charts/n8n/Chart.yaml
Added main.useStatefulSet: false flag in values schema; bumped chart version to 2.1.0 and updated artifacthub changelog.
Helm helper templates
charts/n8n/templates/_helpers.tpl
Added n8n.validateStatefulSet template for configuration validation; updated dynamic PVC logic to skip when useStatefulSet is true.
Resource templates
charts/n8n/templates/deployment.yaml, charts/n8n/templates/statefulset.yaml, charts/n8n/templates/pvc.yaml, charts/n8n/templates/service-headless.yaml, charts/n8n/templates/service.yaml
Deployment is only rendered when useStatefulSet is false; new statefulset.yaml implements StatefulSet + volumeClaimTemplates; PVC template skipped for StatefulSet mode; added headless Service for StatefulSet; Service name/type templating adjusted.

Sequence Diagram(s)

sequenceDiagram
  participant Helm as Helm chart
  participant K8sAPI as Kubernetes API
  participant Headless as Headless Service
  participant StatefulSet as StatefulSet controller
  participant PVC as PersistentVolumeClaim
  participant PV as PersistentVolume
  Helm->>K8sAPI: render & apply templates (statefulset.yaml, service-headless)
  K8sAPI->>Headless: create headless Service
  K8sAPI->>StatefulSet: create StatefulSet resource
  StatefulSet->>K8sAPI: create Pod replica N
  StatefulSet->>PVC: request PVC via volumeClaimTemplates
  PVC->>PV: provision PV (dynamic provisioning)
  PV->>Pod: mount volume to Pod
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Vad1mo
  • RoseSecurity
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding StatefulSet deployment support for the n8n Helm chart, which is the primary objective of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🧹 Recent nitpick comments
charts/n8n/templates/statefulset.yaml (2)

17-25: Consider adding updateStrategy and podManagementPolicy options.

StatefulSets often benefit from configurable updateStrategy (e.g., RollingUpdate with partition) and podManagementPolicy (e.g., Parallel for faster scaling). Currently, these default to Kubernetes defaults (RollingUpdate and OrderedReady), which is fine for most cases, but exposing them via values would provide flexibility.

🔧 Optional addition
 spec:
   {{- if not .Values.main.autoscaling.enabled }}
   replicas: {{ .Values.main.replicaCount }}
   {{- end }}
+  {{- with .Values.main.statefulSet.updateStrategy }}
+  updateStrategy:
+    {{- toYaml . | nindent 4 }}
+  {{- end }}
+  {{- if .Values.main.statefulSet.podManagementPolicy }}
+  podManagementPolicy: {{ .Values.main.statefulSet.podManagementPolicy }}
+  {{- end }}
   serviceName: {{ include "n8n.fullname" . }}-headless

77-78: Wrap lifecycle in a conditional for consistency.

The lifecycle block is rendered unconditionally, which produces lifecycle: (null) when .Values.main.lifecycle is empty or undefined. While technically valid YAML, this is inconsistent with other optional fields like command, livenessProbe, and readinessProbe that use {{- with }} wrappers.

♻️ Proposed fix
-          lifecycle:
-            {{- toYaml .Values.main.lifecycle | nindent 12 }}
+          {{- with .Values.main.lifecycle }}
+          lifecycle:
+            {{- toYaml . | nindent 12 }}
+          {{- end }}
📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9ad439b and 2b2463a.

📒 Files selected for processing (1)
  • charts/n8n/templates/statefulset.yaml
🧰 Additional context used
🪛 YAMLlint (1.37.1)
charts/n8n/templates/statefulset.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: lint-test
🔇 Additional comments (5)
charts/n8n/templates/statefulset.yaml (5)

1-16: Static analysis false positive; metadata looks good.

The YAMLlint error on line 1 is a false positive—YAMLlint doesn't understand Helm/Go template syntax. The conditional, validation call, and metadata structure are correct.


26-50: Pod template metadata and init section look good.

The checksum annotation for config change detection, conditional pod annotations/labels, and init container support with tpl for dynamic templating are all well-implemented.


79-98: Container port, probes, and volume mounts are correctly configured.

The port extraction with fallback to 5678, conditional probes, and the mandatory data volume mount for persistence are all properly implemented.


99-121: Volumes and scheduling configuration are correct.

The volumes section appropriately only renders extraVolumes since the data volume is automatically provided by volumeClaimTemplates. The hasKey check for terminationGracePeriodSeconds correctly allows setting an explicit value of 0.


122-146: volumeClaimTemplates configuration is well-structured.

The PVC template correctly:

  • Names the volume data to match the container's volumeMount
  • Supports optional annotations
  • Handles storageClass with the standard Helm convention ("-" for explicit empty storageClassName)
  • Configures accessModes and storage size from values

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (7)
examples/values_stateful.yaml (4)

1-1: Add space after comment marker to improve readability
YAML conventions recommend a space after the #. Change line 1 from:

#stateful deployment for multiple replicas with persistent state per replica

to:

# stateful deployment for multiple replicas with persistent state per replica
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 1-1: wrong new line character: expected \n

(new-lines)


7-7: Remove trailing whitespace
Line 7 contains trailing spaces. Please remove them to satisfy YAML lint rules and avoid unnecessary diff noise.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 7-7: trailing spaces

(trailing-spaces)


18-18: Remove trailing whitespace
Line 18 contains trailing spaces. Removing them keeps the file clean and lint-compliant.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 18-18: trailing spaces

(trailing-spaces)


32-38: Add accessModes for Valkey persistence
For consistency with main.persistence, consider specifying:

valkey:
  primary:
    persistence:
      enabled: true
      size: 2Gi
      accessModes:
        - ReadWriteOnce

This makes storage requirements explicit.

README.md (2)

50-50: Add missing comma for clarity
Insert a comma after “persistent volume” in line 50 so it reads:

“…all pods share the same persistent volume, which can lead to data corruption…”

🧰 Tools
🪛 LanguageTool

[uncategorized] ~50-~50: A comma might be missing here.
Context: ...ent, all pods share the same persistent volume which can lead to data corruption as mu...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)


63-66: Clarify required persistence.type setting
The warning mentions persistence.enabled and persistence.storageClass, but for StatefulSets you must also set:

persistence:
  type: dynamic

Please update the note to include persistence.type for completeness.

charts/n8n/templates/statefulset.yaml (1)

71-75: Refine env empty-list logic
The current | ternary nil "[]" may emit env: null when extraEnv is non-empty, leading to invalid YAML. Consider refactoring to:

env:
  {{- if .Values.main.extraEnv }}
  {{- range $key, $value := .Values.main.extraEnv }}
  - name: {{ $key }}
    {{ toYaml $value | nindent 4 }}
  {{- end }}
  {{- else }}
  []
  {{- end }}

This ensures env is always a proper array.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 565fbf7 and bc97564.

📒 Files selected for processing (7)
  • README.md (2 hunks)
  • charts/n8n/templates/_helpers.tpl (2 hunks)
  • charts/n8n/templates/deployment.yaml (2 hunks)
  • charts/n8n/templates/statefulset.yaml (1 hunks)
  • charts/n8n/values.yaml (1 hunks)
  • examples/README.md (1 hunks)
  • examples/values_stateful.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
charts/n8n/templates/deployment.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

examples/values_stateful.yaml

[error] 1-1: wrong new line character: expected \n

(new-lines)


[error] 7-7: trailing spaces

(trailing-spaces)


[error] 18-18: trailing spaces

(trailing-spaces)


[error] 24-24: trailing spaces

(trailing-spaces)

charts/n8n/templates/statefulset.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)


[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)


[warning] 11-11: wrong indentation: expected 2 but found 4

(indentation)

🪛 LanguageTool
README.md

[uncategorized] ~50-~50: A comma might be missing here.
Context: ...ent, all pods share the same persistent volume which can lead to data corruption as mu...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

🔇 Additional comments (7)
charts/n8n/values.yaml (1)

51-53: LGTM: Well-documented StatefulSet configuration flag

The addition of the useStatefulSet parameter is well-documented and appropriately defaulted to false to maintain backward compatibility with existing deployments. This flag enables users to choose between Deployment and StatefulSet for their n8n instances.

examples/README.md (1)

12-12: LGTM: Clear documentation of the new example

The README has been properly updated to reference the new StatefulSet example configuration file, which will help users understand how to deploy n8n with individual persistent volumes per replica.

charts/n8n/templates/deployment.yaml (1)

1-1: LGTM: Appropriate conditional rendering of Deployment

The conditional wrapping ensures that the Deployment resource is only created when useStatefulSet is false, preventing resource conflicts when using StatefulSets. This implementation allows the seamless transition between deployment types.

The static analysis tool flagging a YAML syntax error is a false positive due to the Helm template syntax being processed before the YAML is rendered.

Also applies to: 125-125

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/_helpers.tpl (2)

70-70: LGTM: Proper PVC handling for different deployment types

The PVC logic has been correctly modified to only create dynamic PVCs when not using StatefulSets. This prevents duplicate volume claim creation since StatefulSets will handle PVC creation through volumeClaimTemplates.


105-110: LGTM: Important validation to prevent misconfiguration

The new validation function is an excellent safeguard that prevents users from configuring incompatible options. By failing early with a clear error message when both useStatefulSet=true and persistence.existingClaim is specified, you help users avoid confusing runtime errors.

charts/n8n/templates/statefulset.yaml (2)

1-3: Conditional rendering and validation are applied correctly
The if .Values.main.useStatefulSet guard and include "n8n.validateStatefulSet" call ensure the StatefulSet is only rendered when intended and that the configuration is validated.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)


62-70:

Details

❓ Verification inconclusive

Verify envFrom indentation and optionality
Indentation errors in templated blocks can cause unexpected rendering. Use helm template to confirm that envFrom: and its child entries for ConfigMapRef and SecretRef appear only when defined and are indented correctly.


🏁 Script executed:

#!/bin/bash
# Render only the StatefulSet template and lint it
helm template . \
  --values examples/values_stateful.yaml \
  --set main.useStatefulSet=true \
  -s charts/n8n/templates/statefulset.yaml | yamllint -

Length of output: 236


Manual Verification Required: Confirm envFrom Indentation

Our environment couldn’t run the Helm CLI, so automated linting didn’t execute. Please verify locally that:

  • envFrom: only appears when .Values.main.config or .Values.main.secret are set
  • The child entries (configMapRef / secretRef) are indented correctly under envFrom:

Run this command in your local setup and ensure no errors are reported:

helm template . \
  --values examples/values_stateful.yaml \
  --set main.useStatefulSet=true \
  -s charts/n8n/templates/statefulset.yaml \
| yamllint -

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb8f395 and d275b47.

📒 Files selected for processing (2)
  • charts/n8n/templates/pvc.yaml (1 hunks)
  • charts/n8n/templates/statefulset.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
charts/n8n/templates/pvc.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/statefulset.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)


[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)


[warning] 11-11: wrong indentation: expected 2 but found 4

(indentation)

🔇 Additional comments (4)
charts/n8n/templates/pvc.yaml (2)

1-29: Conditional PVC creation aligns with StatefulSet support.
The addition of (not .Values.main.useStatefulSet) to the if guard on line 1 correctly prevents standalone PVC resources from being rendered when useStatefulSet is enabled, since StatefulSets manage volumes via volumeClaimTemplates. This change avoids PVC conflicts and is consistent with the new StatefulSet template logic.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)


1-29: Ignore YAMLLint false positive on Helm templating.
The YAMLLint error syntax error: expected the node content, but found '-' arises from Helm's Go templating syntax, not an actual YAML issue. You can safely disregard this warning.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/statefulset.yaml (2)

1-2: Validate StatefulSet configuration at the top-level.
Wrapping the template in {{- if .Values.main.useStatefulSet }} and invoking n8n.validateStatefulSet ensures that StatefulSet-specific preconditions (persistence enabled, no existing claims) are enforced early. This promotes fail-fast behavior for misconfigurations.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)


9-11: Indentation warnings are false positives.
The static analysis warnings at lines 9–11 (wrong indentation) stem from Helm template directives, not actual YAML formatting errors. The existing nindent calls correctly handle indentation for conditional blocks and can be ignored.

🧰 Tools
🪛 YAMLlint (1.37.1)

[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)


[warning] 11-11: wrong indentation: expected 2 but found 4

(indentation)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
examples/values_stateful.yaml (2)

1-1: Nitpick: Standardize header formatting.
There’s no newline before the first line and missing space after #. Consider revising to:

# Stateful deployment for multiple replicas with persistent state per replica
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 1-1: wrong new line character: expected \n

(new-lines)


9-9: Remove trailing whitespace.
Lines 9, 20, and 26 contain trailing spaces. Cleaning these improves YAML linting and readability.

Also applies to: 20-20, 26-26

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 9-9: trailing spaces

(trailing-spaces)

README.md (1)

50-50: Typographical nitpick: missing comma.
Add a comma after "persistent volume" for clarity:

- all pods share the same persistent volume which can lead to data corruption as multiple replicas try to access the same files simultaneously.
+ all pods share the same persistent volume, which can lead to data corruption as multiple replicas try to access the same files simultaneously.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~50-~50: A comma might be missing here.
Context: ...ent, all pods share the same persistent volume which can lead to data corruption as mu...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

charts/n8n/templates/statefulset.yaml (1)

17-21: Expose StatefulSet updateStrategy & podManagementPolicy.
Currently the default update strategy and pod management policy are used. Consider adding configurable updateStrategy and podManagementPolicy in values.yaml to enable controlled rolling updates and parallel pod startups:

main:
  statefulset:
    updateStrategy:
      type: RollingUpdate
      partition: 0
    podManagementPolicy: Parallel
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d275b47 and dc37d49.

📒 Files selected for processing (5)
  • README.md (2 hunks)
  • charts/n8n/templates/service-headless.yaml (1 hunks)
  • charts/n8n/templates/service.yaml (1 hunks)
  • charts/n8n/templates/statefulset.yaml (1 hunks)
  • examples/values_stateful.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
charts/n8n/templates/service.yaml

[error] 4-4: syntax error: expected , but found '{'

(syntax)

charts/n8n/templates/service-headless.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/statefulset.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)


[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)


[warning] 11-11: wrong indentation: expected 2 but found 4

(indentation)

examples/values_stateful.yaml

[error] 1-1: wrong new line character: expected \n

(new-lines)


[error] 9-9: trailing spaces

(trailing-spaces)


[error] 20-20: trailing spaces

(trailing-spaces)


[error] 26-26: trailing spaces

(trailing-spaces)

🪛 LanguageTool
README.md

[uncategorized] ~50-~50: A comma might be missing here.
Context: ...ent, all pods share the same persistent volume which can lead to data corruption as mu...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

🔇 Additional comments (4)
charts/n8n/templates/service.yaml (1)

4-4: ⚠️ Potential issue

Fix default Service type value.
The default for .Values.main.service.type is defined as "ClusterIP_" (with a trailing underscore) which is invalid. It should be "ClusterIP".
Apply this diff:

-  type: {{ default "ClusterIP_" .Values.main.service.type }}
+  type: {{ default "ClusterIP" .Values.main.service.type }}

Likely an incorrect or invalid review comment.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 4-4: syntax error: expected , but found '{'

(syntax)

charts/n8n/templates/service-headless.yaml (1)

1-5: The headless Service template correctly conditionally renders when useStatefulSet is enabled and aligns with the StatefulSet’s serviceName.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

README.md (1)

44-54: Documentation clear and comprehensive.
The new "Deployment Types" section effectively explains when to use Deployments vs StatefulSets and references the example configuration.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~50-~50: A comma might be missing here.
Context: ...ent, all pods share the same persistent volume which can lead to data corruption as mu...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

charts/n8n/templates/statefulset.yaml (1)

1-3: StatefulSet conditional inclusion & validation.
Including the n8n.validateStatefulSet helper ensures invalid PVC configurations (e.g., existingClaim with StatefulSets) are caught early.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

@joshuabaird
Copy link
Copy Markdown
Contributor

@fank This is a useful feature. Do you have the time to wrap it up? Thanks!

@fank
Copy link
Copy Markdown
Contributor Author

fank commented Aug 7, 2025

@joshuabaird I am still actively using it in production, I will come back to this to clean it up!
I want to ensure I am testing this deeply before I want it to get this merged.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
charts/n8n/templates/service.yaml (2)

4-4: Quote the generated service name to avoid parsing issues

Although Helm usually renders the value without problems, quoting the entire name string guards against accidental colon/space characters sneaking in from template helpers and makes the YAML friendlier to external linters (they often choke on the first { they see, as hinted by the YAML-lint warning).

-name: {{ include "n8n.fullname" . }}{{ if .Values.main.useStatefulSet }}-svc{{ end }}
+name: "{{ include "n8n.fullname" . }}{{ if .Values.main.useStatefulSet }}-svc{{ end }}"

12-12: Quote the service type for consistency

Upstream Kubernetes examples normally quote the value of type, and quoting also sidesteps edge cases where users pass a lower-case value that is later upper-cased by templating logic.

-type: {{ default "ClusterIP" .Values.main.service.type }}
+type: {{ default "ClusterIP" .Values.main.service.type | quote }}
examples/values_stateful.yaml (2)

1-1: Convert CRLF to LF line endings

The file is committed with \r\n line endings (YAML-lint “wrong new line character”). This causes noisy diffs and can break tooling on Unix environments. Re-save the file with LF endings only.


20-24: Remind users to externalise secrets

encryption_key is hard-coded in the example. Even though it’s a placeholder string, beginners often copy the file verbatim. Adding a brief comment recommending a Kubernetes secret (or at least an environment variable) avoids accidental plaintext keys in Git.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc37d49 and 18f8b6f.

📒 Files selected for processing (3)
  • README.md (2 hunks)
  • charts/n8n/templates/service.yaml (1 hunks)
  • examples/values_stateful.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md
🧰 Additional context used
🪛 YAMLlint (1.37.1)
charts/n8n/templates/service.yaml

[error] 4-4: syntax error: expected , but found '{'

(syntax)

examples/values_stateful.yaml

[error] 1-1: wrong new line character: expected \n

(new-lines)

🔇 Additional comments (2)
charts/n8n/templates/service.yaml (1)

18-20: Confirm selector labels still match the StatefulSet pods

When main.useStatefulSet is true, the workload switches from Deployment to StatefulSet. Please double-check that the StatefulSet template still sets app.kubernetes.io/type: master; otherwise this service will not pick up the pods and traffic will break.

examples/values_stateful.yaml (1)

12-18: Validate persistence.type: dynamic matches the chart enum

The base values.yaml for the chart historically accepted type: pvc / type: hostPath or similar. “dynamic” is new; if the helper templates don’t recognise this value the StatefulSet will not render the volumeClaimTemplates. Please verify the helpers in _helpers.tpl handle "dynamic".

@joshuabaird
Copy link
Copy Markdown
Contributor

Thanks so much, @fank!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
charts/n8n/templates/deployment.yaml (2)

1-1: Guard clause is correct but should defensively handle a missing value

useStatefulSet is a newly-introduced flag, so older values.yaml files may omit it. Helm treats an undefined value as nil, which is falsy, but the not operator will return true for nil.
If that implicit behaviour is acceptable, leave as-is; otherwise wrap with default for explicitness and future-proofing:

-{{- if not .Values.main.useStatefulSet }}
+{{- if not (default false .Values.main.useStatefulSet) }}

125-125: Closing directive matches, but keep a blank line after it

Helm’s {{- end }} already trims the preceding newline. Adding one explicit newline after the closing tag avoids concatenating with whatever follows in concatenated manifests and keeps helm template output tidy.

-{{- end }}
+{{- end }}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18f8b6f and 0f68ce2.

📒 Files selected for processing (6)
  • .github/workflows/lint-test.yaml (1 hunks)
  • README.md (2 hunks)
  • charts/n8n/templates/deployment.yaml (2 hunks)
  • charts/n8n/templates/service.yaml (1 hunks)
  • charts/n8n/values.yaml (1 hunks)
  • examples/README.md (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • examples/README.md
  • .github/workflows/lint-test.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • charts/n8n/templates/service.yaml
  • charts/n8n/values.yaml
  • README.md
🧰 Additional context used
🪛 YAMLlint (1.37.1)
charts/n8n/templates/deployment.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

@fank fank force-pushed the fk_statefulmain branch 3 times, most recently from 92fa413 to e1b203f Compare August 7, 2025 13:54
@fank fank marked this pull request as ready for review August 7, 2025 13:54
@fank
Copy link
Copy Markdown
Contributor Author

fank commented Aug 7, 2025

@Vad1mo feel free to review

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🔭 Outside diff range comments (1)
charts/n8n/templates/pvc.yaml (1)

15-18: Incorrect use of {{- strips indentation → PVC YAML becomes invalid

Because {{- range ... }} trims the leading four spaces, list items are emitted flush-left:

  accessModes:
- "ReadWriteOnce"

This breaks YAML parsing.

-    {{- range .Values.main.persistence.accessModes }}
-    - {{ . | quote }}
-    {{- end }}
+    {{- range .Values.main.persistence.accessModes }}
+      - {{ . | quote }}
+    {{- end }}

or switch to nindent:

-    {{- range .Values.main.persistence.accessModes }}
-    - {{ . | quote }}
-    {{- end }}
+{{- range .Values.main.persistence.accessModes }}
+  - {{ . | quote }}
+{{- end }}
🧹 Nitpick comments (4)
charts/n8n/templates/deployment.yaml (1)

125-125: Minor: closing {{- end }} is easy to overlook

Consider adding a short comment so future edits don’t accidentally delete the opening guard:

{{- end }}{{/* useStatefulSet guard */}}
.github/workflows/lint-test.yaml (1)

50-50: Missing newline at EOF

Add a trailing newline to satisfy YAML-lint and keep Git diffs clean.

examples/values_stateful.yaml (1)

1-38: CRLF line endings & placeholder secrets

  1. File currently has Windows CRLF endings; convert to LF to avoid helm-lint noise.
  2. encryption_key: "<shared-encryption-key>" is a good reminder, but users often forget. Consider referencing a Kubernetes Secret instead.

Example:

-      encryption_key: "<shared-encryption-key>"
+      # encryption_key: "<shared-encryption-key>"
+      encryption_key__existingSecret: n8n-encryption
charts/n8n/templates/statefulset.yaml (1)

1-16: YAML front-matter & indentation warnings

yamllint flags a top-level syntax error and indentation issues (see pipeline hints).
While templating often confuses linters, adding the standard document delimiter and consistent two-space indentation silences most false positives and improves readability:

+---
 {{- if .Values.main.useStatefulSet }}
 {{- include "n8n.validateStatefulSet" . -}}

Consider running helm template through yamllint -d relaxed in CI to catch real YAML mistakes early.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a63b51 and e1b203f.

📒 Files selected for processing (12)
  • .github/workflows/lint-test.yaml (2 hunks)
  • README.md (2 hunks)
  • charts/n8n/Chart.yaml (2 hunks)
  • charts/n8n/templates/_helpers.tpl (2 hunks)
  • charts/n8n/templates/deployment.yaml (2 hunks)
  • charts/n8n/templates/pvc.yaml (1 hunks)
  • charts/n8n/templates/service-headless.yaml (1 hunks)
  • charts/n8n/templates/service.yaml (1 hunks)
  • charts/n8n/templates/statefulset.yaml (1 hunks)
  • charts/n8n/values.yaml (1 hunks)
  • examples/README.md (1 hunks)
  • examples/values_stateful.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • charts/n8n/Chart.yaml
  • examples/README.md
  • charts/n8n/templates/service.yaml
  • charts/n8n/values.yaml
  • README.md
  • charts/n8n/templates/_helpers.tpl
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/lint-test.yaml

10-10: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)
.github/workflows/lint-test.yaml

[error] 50-50: no new line character at the end of file

(new-line-at-end-of-file)

charts/n8n/templates/deployment.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/pvc.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/service-headless.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/statefulset.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)


[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)


[warning] 11-11: wrong indentation: expected 2 but found 4

(indentation)

examples/values_stateful.yaml

[error] 1-1: wrong new line character: expected \n

(new-lines)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: lint-test
🔇 Additional comments (4)
charts/n8n/templates/pvc.yaml (1)

1-1: ✅ Condition correctly disables PVC when StatefulSet is enabled

Wrapping the PVC manifest with (not .Values.main.useStatefulSet) cleanly prevents duplicate/conflicting PVCs in StatefulSet mode.

charts/n8n/templates/deployment.yaml (1)

1-1: Deployment correctly gated behind !useStatefulSet

This prevents multiple workload controllers for the same pod spec. Nice.

.github/workflows/lint-test.yaml (1)

10-26: Downgrading core actions may break future CI runners

actions/checkout@v3, azure/setup-helm@v4.2.0, and chart-testing-action@v2.6.1 are all superseded. action-lint is already warning about checkout@v3.

Unless you have a reproducibility reason, upgrade to the latest major versions:

-uses: actions/checkout@v3
+uses: actions/checkout@v4

-uses: azure/setup-helm@v4.2.0
+uses: azure/setup-helm@v4
+with:
+  version: v3.14.4   # keep pin if really required

-uses: helm/chart-testing-action@v2.6.1
+uses: helm/chart-testing-action@v3
charts/n8n/templates/statefulset.yaml (1)

20-21: Ensure matching headless Service name

serviceName is set to {{ include "n8n.fullname" . }}-headless, but no headless Service template is included in this PR snippet. Pods will fail DNS resolution (<pod-ordinal>.<serviceName>) unless a Service with the exact same name (clusterIP: None) is rendered.

Please verify the chart renders a Service resource named {{ include "n8n.fullname" . }}-headless.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1b203f and 0357972.

📒 Files selected for processing (3)
  • charts/n8n/templates/pvc.yaml (2 hunks)
  • charts/n8n/templates/service-headless.yaml (1 hunks)
  • charts/n8n/templates/statefulset.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
charts/n8n/templates/pvc.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/service-headless.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/statefulset.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)


[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)


[warning] 11-11: wrong indentation: expected 2 but found 4

(indentation)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: lint-test
🔇 Additional comments (2)
charts/n8n/templates/pvc.yaml (1)

16-18: accessModes block can render with zero-indent → invalid YAML

Because {{- range ...}} trims the entire leading whitespace, the list items may be emitted starting at column 0 instead of the required indent under accessModes:. Some Kubernetes validators (and yamllint) will reject the manifest.

-  accessModes:
-{{- range .Values.main.persistence.accessModes }}
-    - {{ . | quote }}
-{{- end }}
+  accessModes:
+{{- range .Values.main.persistence.accessModes }}
+  - {{ . | quote }}
+{{- end }}

Removing the dash from {{- range or using nindent 2 after the range are both acceptable alternatives.

Likely an incorrect or invalid review comment.

charts/n8n/templates/service-headless.yaml (1)

17-18: Port lookup now matches Deployment — good catch

Switching to
get (default (dict) .Values.main.config.n8n) "port"
eliminates the earlier drift between Service and Pod ports.

@fank fank force-pushed the fk_statefulmain branch from 5371faf to 9193f50 Compare August 7, 2025 14:45
@fank fank requested a review from Vad1mo August 20, 2025 05:20
This PR introduces StatefulSet support for n8n deployments, enabling better handling
of persistent storage when running multiple replicas.

## Key Changes

- Add new StatefulSet template with volumeClaimTemplates for individual PVCs per replica
- Add headless Service for StatefulSet DNS management and pod identity
- Add useStatefulSet flag to toggle between Deployment and StatefulSet modes
- Update PVC template to skip creation when using StatefulSet (handled by volumeClaimTemplates)
- Add validation to prevent incompatible persistence configurations (existingClaim with StatefulSet)
- Include example configuration file for StatefulSet deployments
- Add comprehensive documentation explaining when and how to use StatefulSets

## Implementation Details

- StatefulSet creates individual PVCs for each replica, preventing data corruption from shared volumes
- Headless service provides stable network identity for StatefulSet pods
- Regular service (-svc suffix) provides load balancing for external access
- Validation helper ensures users don't misconfigure persistence settings
- All templates include namespace field for proper scoping

## Use Cases

StatefulSets are recommended when:
- Running multiple n8n replicas that need individual persistent storage
- Each instance needs to maintain its own workflow data
- Implementing high availability with proper data isolation

For proper multi-replica operation, users should:
- Enable Redis/Valkey for session state management
- Use external database instead of SQLite
- Configure shared encryption key across all replicas

Fixes #186
@fank
Copy link
Copy Markdown
Contributor Author

fank commented Sep 3, 2025

@Vad1mo changes and commit got cleaned up, based on latest changes in master.

@fank
Copy link
Copy Markdown
Contributor Author

fank commented Sep 28, 2025

@RoseSecurity any change for you to review this?

@ronballesteros
Copy link
Copy Markdown

Hello, are there plans to merge this soon?

apiVersion: v2
name: n8n
version: 1.0.14
version: 1.0.15
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this functionality fits more into a minor release than a patch.

fank added 2 commits January 13, 2026 21:40
Resolve conflict in Chart.yaml: bump version to 2.1.0 (minor release
for StatefulSet feature as per review feedback)
Sync with upstream deployment.yaml change to support configurable
terminationGracePeriodSeconds via main.terminationGracePeriodSeconds
@fank
Copy link
Copy Markdown
Contributor Author

fank commented Jan 13, 2026

Merged upstream/main and applied changes:

  • Bumped version to 2.1.0 (minor release for StatefulSet feature, as suggested by @RoseSecurity)
  • Synced terminationGracePeriodSeconds support to statefulset.yaml (added in upstream for deployment.yaml)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @charts/n8n/templates/statefulset.yaml:
- Around line 47-50: The initContainers block is mis-indented: change the
template indentation call for initContainers from nindent 10 to nindent 8 so
that the items under the initContainers: key align with the surrounding spec
(match the same indentation pattern used by containers:). Update the line
containing "{{ tpl (toYaml .Values.main.initContainers) . | nindent 10 }}" to
use "| nindent 8" so list entries are properly nested under the initContainers:
key.

In @examples/values_stateful.yaml:
- Around line 1-37: The YAML file (values_stateful.yaml) currently contains CRLF
line endings which break linting on Unix systems; convert the file to use LF
line endings (e.g., via your editor or a line-ending conversion tool), ensure
the file retains the same indentation and keys (useStatefulSet, persistence,
valkey, etc.), verify YAMLlint passes, and commit the updated file.
🧹 Nitpick comments (3)
charts/n8n/templates/service.yaml (1)

5-5: Document the service name change for StatefulSet mode.

The -svc suffix correctly differentiates this service from the headless service used by StatefulSets. However, users upgrading to StatefulSet mode should be aware that external references (e.g., Ingress backends, other services) will need to be updated to use the new service name.

Consider documenting this in the README or migration notes.

charts/n8n/templates/statefulset.yaml (2)

36-38: Inconsistent whitespace in podLabels rendering.

Line 37 has extra leading whitespace before {{ toYaml compared to similar blocks (e.g., line 11 uses {{- toYaml). This may cause extra blank lines in the rendered output.

♻️ Suggested fix
         {{- if .Values.main.podLabels }}
-          {{ toYaml .Values.main.podLabels | nindent 8 }}
+        {{- toYaml .Values.main.podLabels | nindent 8 }}
         {{- end }}

77-78: Consider conditional rendering for lifecycle block.

The lifecycle block is rendered unconditionally, resulting in an empty lifecycle: {} when no lifecycle hooks are configured. While Kubernetes accepts this, using {{- with }} would be more consistent with other optional sections.

♻️ Suggested refactor
+          {{- with .Values.main.lifecycle }}
           lifecycle:
-            {{- toYaml .Values.main.lifecycle | nindent 12 }}
+            {{- toYaml . | nindent 12 }}
+          {{- end }}
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0357972 and d95e3c3.

📒 Files selected for processing (11)
  • README.md
  • charts/n8n/Chart.yaml
  • charts/n8n/templates/_helpers.tpl
  • charts/n8n/templates/deployment.yaml
  • charts/n8n/templates/pvc.yaml
  • charts/n8n/templates/service-headless.yaml
  • charts/n8n/templates/service.yaml
  • charts/n8n/templates/statefulset.yaml
  • charts/n8n/values.yaml
  • examples/README.md
  • examples/values_stateful.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
  • examples/README.md
  • charts/n8n/values.yaml
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: tsch157
Repo: 8gears/n8n-helm-chart PR: 239
File: charts/n8n/Chart.yaml:3-4
Timestamp: 2025-09-02T08:05:39.372Z
Learning: n8n 1.110.0 is a pre-release version and should not be used in production deployments. Always verify if a version is stable before recommending upgrades in the n8n Helm chart.
📚 Learning: 2025-09-02T08:05:39.372Z
Learnt from: tsch157
Repo: 8gears/n8n-helm-chart PR: 239
File: charts/n8n/Chart.yaml:3-4
Timestamp: 2025-09-02T08:05:39.372Z
Learning: n8n 1.110.0 is a pre-release version and should not be used in production deployments. Always verify if a version is stable before recommending upgrades in the n8n Helm chart.

Applied to files:

  • charts/n8n/Chart.yaml
🪛 YAMLlint (1.37.1)
charts/n8n/templates/deployment.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/statefulset.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/service-headless.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

charts/n8n/templates/pvc.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

examples/values_stateful.yaml

[error] 1-1: wrong new line character: expected \n

(new-lines)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: lint-test
🔇 Additional comments (12)
charts/n8n/templates/pvc.yaml (1)

1-1: LGTM!

The additional (not .Values.main.useStatefulSet) condition correctly prevents standalone PVC creation when StatefulSet mode is enabled, since StatefulSets manage their own PVCs through volumeClaimTemplates.

Note: The YAMLlint syntax error is a false positive—Helm template directives ({{-) are valid Go template syntax that YAMLlint doesn't understand.

charts/n8n/templates/deployment.yaml (1)

1-1: LGTM!

The conditional wrapper correctly prevents Deployment creation when useStatefulSet is true, ensuring mutual exclusivity between Deployment and StatefulSet modes.

Note: The YAMLlint syntax error is a false positive for Helm template syntax.

Also applies to: 129-129

charts/n8n/templates/service.yaml (1)

14-14: LGTM!

The default service type is correctly set to ClusterIP.

charts/n8n/templates/_helpers.tpl (2)

70-73: LGTM!

The additional condition correctly ensures dynamic PVC provisioning only applies to Deployment mode. StatefulSets use volumeClaimTemplates instead.


105-113: Validation logic is correct and properly invoked.

The validation correctly enforces:

  1. existingClaim is incompatible with StatefulSets (which use volumeClaimTemplates)
  2. StatefulSets require persistence enabled

The helper is invoked in statefulset.yaml (line 2), confirming the validation runs before StatefulSet resources are created.

charts/n8n/Chart.yaml (2)

3-3: LGTM!

The version bump from 2.0.1 to 2.1.0 follows semver correctly for a new feature addition.


36-38: LGTM!

The changelog annotation correctly categorizes this as an "added" feature with an appropriate description.

examples/values_stateful.yaml (1)

19-23: Good example with clear placeholder indication.

The example correctly demonstrates the StatefulSet configuration with Redis and encryption key requirements. The <shared-encryption-key> placeholder clearly indicates users must replace it.

charts/n8n/templates/service-headless.yaml (1)

1-25: LGTM! Headless service correctly configured for StatefulSet.

The headless service is properly implemented with:

  • Conditional rendering when StatefulSet is enabled
  • clusterIP: None for headless behavior
  • Matching selector labels with the StatefulSet template
  • Graceful fallback for the port configuration

The YAMLlint syntax error is a false positive caused by the Helm templating directive.

charts/n8n/templates/statefulset.yaml (1)

118-141: volumeClaimTemplates implementation looks correct.

The volumeClaimTemplates section properly handles:

  • Annotations with range iteration
  • Access modes from values
  • Storage size from persistence settings
  • StorageClass with special handling for empty string ("-")
README.md (2)

40-68: Excellent documentation for the StatefulSet feature.

The documentation clearly explains:

  • When to use StatefulSet vs Deployment
  • Data corruption risks with shared volumes
  • Requirements for production StatefulSet deployments (Redis, external DB, encryption key)
  • The incompatibility warning for persistence.existingClaim
  • Service naming conventions

220-223: LGTM! Clear documentation of the new flag.

The useStatefulSet flag is properly documented with its purpose and default value.

- Fix initContainers indentation in statefulset.yaml (nindent 8)
- Convert values_stateful.yaml line endings from CRLF to LF
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @charts/n8n/templates/statefulset.yaml:
- Around line 36-38: The podLabels block in statefulset.yaml uses inconsistent
whitespace trimming which can break YAML indentation; update the template
invocation that renders .Values.main.podLabels to use the left-trim form so
whitespace is stripped—change the line using toYaml .Values.main.podLabels |
nindent 8 to use {{- toYaml .Values.main.podLabels | nindent 8 }} (keeping the
existing {{- if .Values.main.podLabels }} and {{- end }}), ensuring consistent
whitespace handling around the toYaml/nindent call.
- Around line 93-98: The StatefulSet pod spec supports
.Values.main.extraVolumeMounts but is missing a matching volumes: block, so add
a conditional volumes section that renders .Values.main.extraVolumes (e.g., wrap
toYaml .Values.main.extraVolumes with an if and nindent) placed after the
extraVolumeMounts block and before hostAliases; update the template around the
volumeMounts list (referencing volumeMounts and .Values.main.extraVolumeMounts)
to include this new conditional volumes block that references
.Values.main.extraVolumes so any mounts have corresponding volume definitions.
🧹 Nitpick comments (1)
charts/n8n/templates/statefulset.yaml (1)

77-78: Consider wrapping lifecycle in a conditional.

The lifecycle block is rendered unconditionally, unlike similar optional blocks (e.g., livenessProbe, readinessProbe on lines 83-90) which use {{- with ... }}. If .Values.main.lifecycle is not defined or empty, this could produce an empty lifecycle: {} block or cause templating issues.

Suggested fix using consistent pattern
-          lifecycle:
-            {{- toYaml .Values.main.lifecycle | nindent 12 }}
+          {{- with .Values.main.lifecycle }}
+          lifecycle:
+            {{- toYaml . | nindent 12 }}
+          {{- end }}
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d95e3c3 and 9ad439b.

📒 Files selected for processing (2)
  • charts/n8n/templates/statefulset.yaml
  • examples/values_stateful.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/values_stateful.yaml
🧰 Additional context used
🪛 YAMLlint (1.37.1)
charts/n8n/templates/statefulset.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: lint-test
🔇 Additional comments (4)
charts/n8n/templates/statefulset.yaml (4)

1-16: LGTM - Conditional rendering and metadata section.

The conditional check, validation helper inclusion, and metadata definition follow standard Helm patterns. The YAMLlint static analysis error is a false positive since Helm templates are not pure YAML until rendered.


17-25: LGTM - StatefulSet spec configuration.

The replicas conditional, headless service reference, and selector labels are correctly configured.


99-117: LGTM - Scheduling and termination configuration.

The optional pod spec fields (hostAliases, nodeSelector, affinity, tolerations) use consistent {{- with ... }} patterns. The terminationGracePeriodSeconds correctly uses hasKey to allow explicit zero values.


118-142: LGTM - volumeClaimTemplates configuration.

The PVC template correctly handles annotations, access modes, storage size, and the storageClass convention where "-" means explicitly no storage class (to avoid using the default). This follows common Helm chart patterns.

- Fix podLabels whitespace handling (use {{- for trim)
- Add missing volumes section for extraVolumes support
@fank fank requested a review from RoseSecurity January 19, 2026 13:34
@fank fank closed this Mar 2, 2026
@fank fank deleted the fk_statefulmain branch March 2, 2026 18:29
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

Successfully merging this pull request may close these issues.

4 participants