Skip to content

feat: Add HPA for Autoscaling Webhook and Workers#286

Open
dmfrahm wants to merge 5 commits into8gears:mainfrom
dmfrahm:main
Open

feat: Add HPA for Autoscaling Webhook and Workers#286
dmfrahm wants to merge 5 commits into8gears:mainfrom
dmfrahm:main

Conversation

@dmfrahm
Copy link
Copy Markdown

@dmfrahm dmfrahm commented Jan 13, 2026

What this PR does / why we need it

This PR introduces support for Horizontal Pod Autoscalers (HPA) for both the webhook and worker components in the Helm chart.

Fixes issue #179

Special notes for your reviewer

Based on PR #186 by @simonefrancia, just implements the fixes requested in there, just trying to get this over the finish line.
Per that PR (text copied from @simonefrancia's PR):

🆕 Changes Introduced

  • Added a new template:
    charts/n8n/templates/hpa.webhook.yaml
    Defines an HPA resource for the webhook deployment, conditionally created based on .Values.webhook.autoscaling.enabled.

  • Added a new template:
    charts/n8n/templates/hpa.worker.yaml
    Defines an HPA resource for the worker deployment, conditionally created based on .Values.worker.autoscaling.enabled.

⚙️ Configuration
Each HPA supports:

  • minReplicas
  • maxReplicas
  • CPU utilization threshold (targetCPUUtilizationPercentage)
  • Memory utilization threshold (targetMemoryUtilizationPercentage)

These values are configurable via:

webhook:
  autoscaling:
    enabled: true
    minReplicas: 1
    maxReplicas: 5
    targetCPUUtilizationPercentage: 80
    targetMemoryUtilizationPercentage: 75

worker:
  autoscaling:
    enabled: true
    minReplicas: 1
    maxReplicas: 5
    targetCPUUtilizationPercentage: 80
    targetMemoryUtilizationPercentage: 75

🧪 Notes

  • The HPA definitions are optional and only deployed if enabled in values.
  • This enhances scalability and resource efficiency for webhook and worker components.

Checklist

Please place an 'x' in all applicable fields and remove unrelated items.

Version and Documentation

Summary by CodeRabbit

  • New Features

    • Added Horizontal Pod Autoscaler support for workers and webhooks with optional CPU- and memory-based scaling; metrics only emitted when targets are set.
    • Configurable min/max replicas and per-component toggles for autoscaling.
  • Chores

    • Chart version bumped to 2.1.0 and release metadata updated.
  • Documentation

    • CONTRIBUTING: added commit message guidance; values docs clarified autoscaling/resource requirements.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 13, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5070d37 and ce1537c.

📒 Files selected for processing (1)
  • charts/n8n/values.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • charts/n8n/values.yaml

Walkthrough

Bumps n8n Helm chart to 2.1.0, adds conditional HorizontalPodAutoscaler templates for worker and webhook (with optional CPU/memory metrics), updates autoscaling/resource guidance and formatting in values.yaml, and adds a "Commit Messages" section to CONTRIBUTING.md.

Changes

Cohort / File(s) Summary
Chart metadata
charts/n8n/Chart.yaml
Version bumped 2.0.12.1.0; artifacthub.io/changes updated to indicate added HPA support for workers and webhooks.
HPA templates
charts/n8n/templates/hpa.worker.yaml, charts/n8n/templates/hpa.webhook.yaml
New Helm templates that conditionally render Kubernetes HorizontalPodAutoscaler resources for worker and webhook deployments. Configurable minReplicas/maxReplicas; include CPU and/or memory utilization metric blocks only when corresponding values are present.
Values / comments
charts/n8n/values.yaml
Rewrote/clarified resource and autoscaling guidance comments to require resources.requests when using CPU/memory-based autoscaling; no functional defaults changed.
Docs
CONTRIBUTING.md
Added "Commit Messages" section recommending Conventional Commits and linking to the specification.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer (Helm)
    participant Helm as Helm renderer
    participant K8s as Kubernetes API
    participant Metrics as Metrics API
    participant HPA as K8s HPA Controller
    participant Deploy as Deployment

    Dev->>Helm: helm install/upgrade (chart v2.1.0)
    Helm->>K8s: Apply manifests (Deployment, optional HPA for worker/webhook)
    K8s->>HPA: Register HPA resources (if enabled)
    HPA->>Metrics: Query CPU/Memory utilization (if configured)
    Metrics-->>HPA: Return metrics
    HPA->>Deploy: Adjust replicas within min/max based on metrics
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Vad1mo
  • alexandre-k
🚥 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 'feat: Add HPA for Autoscaling Webhook and Workers' clearly and concisely summarizes the main changes—introducing horizontal pod autoscaler support for two components, which aligns with the primary objectives of the 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

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

🤖 Fix all issues with AI agents
In @charts/n8n/templates/hpa.webhook.yaml:
- Around line 1-14: The HPA template (hpa.webhook.yaml) can render empty
minReplicas/maxReplicas if .Values.webhook.autoscaling.minReplicas or
.Values.webhook.autoscaling.maxReplicas are undefined; update the template to
use Helm's default filter when rendering those fields (e.g., default to 1 for
minReplicas and 100 for maxReplicas) so that spec.minReplicas and
spec.maxReplicas always have valid numeric values, referencing the existing
variables .Values.webhook.autoscaling.minReplicas and
.Values.webhook.autoscaling.maxReplicas (or alternatively fall back to the main
autoscaling defaults) to avoid Kubernetes validation errors.
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 90cb6d7 and 9160661.

📒 Files selected for processing (3)
  • charts/n8n/Chart.yaml
  • charts/n8n/templates/hpa.webhook.yaml
  • charts/n8n/templates/hpa.worker.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/hpa.webhook.yaml

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

(syntax)

charts/n8n/templates/hpa.worker.yaml

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

(syntax)

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

15-33: Metrics configuration looks correct.

The conditional logic properly handles optional CPU and memory utilization targets. The or check on line 15 ensures the metrics block is only rendered when at least one target is specified, avoiding an empty metrics array.

charts/n8n/Chart.yaml (2)

3-3: Version bump follows semantic versioning.

Minor version increment from 2.0.1 to 2.1.0 is appropriate for adding new features (HPA support) that are backward-compatible.


36-38: Changelog entry is accurate.

The artifacthub.io/changes annotation correctly documents the new HPA feature with kind: added.

charts/n8n/templates/hpa.worker.yaml (1)

1-34: Template structure is consistent with webhook HPA.

The worker HPA template mirrors the webhook HPA, which is good for consistency. Default values for minReplicas (1) and maxReplicas (100) are already defined in values.yaml and correctly referenced by the template.

Likely an incorrect or invalid review comment.

@dmfrahm
Copy link
Copy Markdown
Author

dmfrahm commented Jan 13, 2026

@Vad1mo I think I've implemented the fixes you requested in #186 and that CodeRabbit also tagged on here. Any chance we could get 👀 on this? Would love to get this feature set implemented! Let me know if you want me to fix the below nitpick!

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 (1)
charts/n8n/templates/hpa.worker.yaml (1)

1-1: Same nil-pointer concern as webhook template.

Apply the same guard against undefined parent keys here.

♻️ Safer conditional pattern
-{{- if .Values.worker.autoscaling.enabled }}
+{{- if and .Values.worker .Values.worker.autoscaling .Values.worker.autoscaling.enabled }}
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9160661 and dea2eb2.

📒 Files selected for processing (2)
  • charts/n8n/templates/hpa.webhook.yaml
  • charts/n8n/templates/hpa.worker.yaml
🧰 Additional context used
🧠 Learnings (1)
📓 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.
🪛 YAMLlint (1.37.1)
charts/n8n/templates/hpa.webhook.yaml

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

(syntax)

charts/n8n/templates/hpa.worker.yaml

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

(syntax)

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

2-34: LGTM! HPA template structure is correct.

The template correctly uses the autoscaling/v2 API and properly conditionalizes the metrics section. The structure follows Kubernetes HPA best practices with optional CPU and memory utilization targets.

Note: The YAMLlint error in static analysis is a false positive—{{- is valid Helm template syntax for whitespace control.


1-1: No action needed. The webhook.autoscaling structure is already defined in values.yaml with sensible defaults (enabled: false, minReplicas: 1, maxReplicas: 100, etc.). Helm Go templates safely handle undefined nested keys by evaluating them to false rather than throwing errors, so the template pattern used here is safe and correct. This same pattern is consistently used across all HPA templates in the chart (main, worker, webhook).

charts/n8n/templates/hpa.worker.yaml (2)

14-14: Inconsistent default maxReplicas between webhook and worker.

Worker defaults to maxReplicas: 100 while webhook defaults to maxReplicas: 10. If intentional (workers may need more scaling headroom), this is fine. Otherwise, consider aligning the defaults for consistency.

Is this difference intentional? Workers processing background jobs may indeed need more replicas than webhooks handling HTTP traffic, but a 10x difference in defaults could surprise users.


2-34: LGTM! Template structure mirrors webhook HPA correctly.

The worker HPA template follows the same correct pattern as the webhook template, using autoscaling/v2 with conditional metrics.

@dmfrahm
Copy link
Copy Markdown
Author

dmfrahm commented Jan 16, 2026

@Vad1mo Got the commit message updated, should pass that check now

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

🤖 Fix all issues with AI agents
In `@charts/n8n/templates/hpa.worker.yaml`:
- Around line 15-33: Add a clear warning in the Helm values docs/NOTES.txt that
when using HPA metrics (controlled by
.Values.worker.autoscaling.targetCPUUtilizationPercentage or
.Values.worker.autoscaling.targetMemoryUtilizationPercentage) the worker pods
must have resource requests set; instruct users to set
worker.resources.requests.cpu and/or worker.resources.requests.memory (or update
worker.resources) because leaving worker.resources: {} prevents HPA from
calculating CPU/memory utilization correctly.
♻️ Duplicate comments (1)
charts/n8n/templates/hpa.webhook.yaml (1)

1-14: Previous nil-safety concern has been addressed.

The template now includes proper defaults using | default 1 and | default 100 for minReplicas and maxReplicas respectively, preventing invalid manifests when these values are not explicitly configured.

Bump n8n version to 2.1.0 and update changelog

Add HorizontalPodAutoscaler for webhook service

Rename hpa.workers.yaml to hpa.webhook.yaml

Add HorizontalPodAutoscaler for worker deployment

Update charts/n8n/templates/hpa.webhook.yaml from coderabbit's suggestion

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

Add default values for Worker HPA min and max replicas

Set default values for minReplicas and maxReplicas in HPA configuration.

Increase maxReplicas for webhook deployment to 100

Matches the root values.yaml

Signed-off-by: dmfrahm <martik87@gmail.com>
Added guidelines for commit messages following conventional commits style.

Signed-off-by: dmfrahm <martik87@gmail.com>
Signed-off-by: dmfrahm <martik87@gmail.com>
Signed-off-by: dmfrahm <martik87@gmail.com>
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

🤖 Fix all issues with AI agents
In `@charts/n8n/values.yaml`:
- Around line 453-456: Remove the duplicated word "target" from the autoscaling
note comments so they read "...If you use targetCPUUtilizationPercentage or
targetMemoryUtilizationPercentage, you **MUST** set the requests..." (update
both occurrences that mention targetCPUUtilizationPercentage and
targetMemoryUtilizationPercentage and the example referencing
resources.requests.cpu).

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/values.yaml`:
- Around line 40-44: The YAML for ingress.hosts is misindented: the list item
(the mapping containing host/paths/pathType) must be indented beneath the hosts
key; update the block under ingress.hosts so the "- host: workflow.example.com"
mapping is nested under hosts (and its child keys path and pathType indented
accordingly) to produce a valid YAML structure for the ingress.hosts list.
- Around line 79-80: The values file currently leaves main.extraEnv empty which
renders as null; change the default for main.extraEnv to an empty map so
templates expecting a map get {} instead of null. Update the values.yaml entry
for extraEnv (the main.extraEnv key) to explicitly be an empty map ({}),
ensuring it matches the worker/webhook defaults and prevents template rendering
issues where a map is expected.

@dmfrahm
Copy link
Copy Markdown
Author

dmfrahm commented Jan 29, 2026

@Vad1mo @mbaitelman @alexandre-k

Please review and let me know if any further updates are needed

@dmfrahm
Copy link
Copy Markdown
Author

dmfrahm commented Feb 4, 2026

@Vad1mo @mbaitelman @alexandre-k

I've successfully run the linting actions in my own PR, still waiting on someone to approve their run here and get this approved/merged in!

@dmfrahm
Copy link
Copy Markdown
Author

dmfrahm commented Mar 3, 2026

What steps need to happen for this to be reviewed? It's been over a month with zero feedback, and that is incredibly frustrating.

…s.yaml

Signed-off-by: dmfrahm <martik87@gmail.com>
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.

1 participant