Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions charts/n8n/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: n8n
version: 1.0.15
appVersion: 1.112.0
version: 1.0.16
appVersion: 1.112.1
type: application
description: "Helm Chart for deploying n8n on Kubernetes, a fair-code workflow automation platform with native AI capabilities for technical teams. Easily automate tasks across different services."
home: https://github.com/8gears/n8n-helm-chart
Expand Down Expand Up @@ -34,5 +34,5 @@
artifacthub.io/prerelease: "false"
# supported kinds are added, changed, deprecated, removed, fixed and security.
artifacthub.io/changes: |
- kind: changed
description: "Update n8n app version to 1.112.0"
- kind: added

Check failure on line 37 in charts/n8n/Chart.yaml

View workflow job for this annotation

GitHub Actions / lint-test

37:18 [trailing-spaces] trailing spaces
description: "add support autoscaling workers and webhooks"
33 changes: 33 additions & 0 deletions charts/n8n/templates/hpa.webhook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- if .Values.webhook.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "n8n.fullname" . }}-webhook
labels:
{{- include "n8n.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "n8n.fullname" . }}-webhook
minReplicas: {{ .Values.webhook.autoscaling.minReplicas }}
maxReplicas: {{ .Values.webhook.autoscaling.maxReplicas }}
metrics:
{{- if .Values.webhook.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.webhook.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.webhook.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.webhook.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
Comment on lines +15 to +31
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Guard the metrics section to avoid emitting an empty list
If neither CPU nor memory targets are set, the template will create an empty metrics: field, which is invalid. Wrap the entire block in a conditional that checks for at least one metric. For example:

-  metrics:
-    {{- if .Values.webhook.autoscaling.targetCPUUtilizationPercentage }}
-    - type: Resource
-      resource:
-        name: cpu
-        target:
-          type: Utilization
-          averageUtilization: {{ .Values.webhook.autoscaling.targetCPUUtilizationPercentage }}
-    {{- end }}
-    {{- if .Values.webhook.autoscaling.targetMemoryUtilizationPercentage }}
-    - type: Resource
-      resource:
-        name: memory
-        target:
-          type: Utilization
-          averageUtilization: {{ .Values.webhook.autoscaling.targetMemoryUtilizationPercentage }}
-    {{- end }}
+  {{- if or .Values.webhook.autoscaling.targetCPUUtilizationPercentage .Values.webhook.autoscaling.targetMemoryUtilizationPercentage }}
+  metrics:
+    {{- if .Values.webhook.autoscaling.targetCPUUtilizationPercentage }}
+    - type: Resource
+      resource:
+        name: cpu
+        target:
+          type: Utilization
+          averageUtilization: {{ .Values.webhook.autoscaling.targetCPUUtilizationPercentage }}
+    {{- end }}
+    {{- if .Values.webhook.autoscaling.targetMemoryUtilizationPercentage }}
+    - type: Resource
+      resource:
+        name: memory
+        target:
+          type: Utilization
+          averageUtilization: {{ .Values.webhook.autoscaling.targetMemoryUtilizationPercentage }}
+    {{- end }}
+  {{- end }}
🤖 Prompt for AI Agents
In charts/n8n/templates/hpa.webhook.yaml around lines 15 to 31, the metrics
section can emit an empty list if neither CPU nor memory utilization targets are
set, which is invalid. To fix this, wrap the entire metrics block in a
conditional that checks if at least one of the targetCPUUtilizationPercentage or
targetMemoryUtilizationPercentage values is defined, so the metrics field is
only included when there is at least one metric specified.

{{- end }}

32 changes: 32 additions & 0 deletions charts/n8n/templates/hpa.worker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.worker.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "n8n.fullname" . }}-worker
labels:
{{- include "n8n.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "n8n.fullname" . }}-worker
minReplicas: {{ .Values.worker.autoscaling.minReplicas }}
maxReplicas: {{ .Values.worker.autoscaling.maxReplicas }}
metrics:
{{- if .Values.worker.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.worker.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
Comment on lines +15 to +31
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Guard the metrics section to avoid emitting an empty list
If neither CPU nor memory targets are set, the template will create an empty metrics: field, which is invalid. Wrap the entire block in a conditional that checks for at least one metric. For example:

-  metrics:
-    {{- if .Values.worker.autoscaling.targetCPUUtilizationPercentage }}
-    - type: Resource
-      resource:
-        name: cpu
-        target:
-          type: Utilization
-          averageUtilization: {{ .Values.worker.autoscaling.targetCPUUtilizationPercentage }}
-    {{- end }}
-    {{- if .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
-    - type: Resource
-      resource:
-        name: memory
-        target:
-          type: Utilization
-          averageUtilization: {{ .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
-    {{- end }}
+  {{- if or .Values.worker.autoscaling.targetCPUUtilizationPercentage .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
+  metrics:
+    {{- if .Values.worker.autoscaling.targetCPUUtilizationPercentage }}
+    - type: Resource
+      resource:
+        name: cpu
+        target:
+          type: Utilization
+          averageUtilization: {{ .Values.worker.autoscaling.targetCPUUtilizationPercentage }}
+    {{- end }}
+    {{- if .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
+    - type: Resource
+      resource:
+        name: memory
+        target:
+          type: Utilization
+          averageUtilization: {{ .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
+    {{- end }}
+  {{- end }}
🤖 Prompt for AI Agents
In charts/n8n/templates/hpa.worker.yaml around lines 15 to 31, the metrics
section may emit an empty list if neither CPU nor memory targets are set, which
is invalid. Wrap the entire metrics block in a conditional that checks if either
.Values.worker.autoscaling.targetCPUUtilizationPercentage or
.Values.worker.autoscaling.targetMemoryUtilizationPercentage is set, so the
metrics field is only included when there is at least one metric defined.

{{- end }}
Loading