-
Notifications
You must be signed in to change notification settings - Fork 247
feat: add hpa for workers and webhooks #186
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
base: main
Are you sure you want to change the base?
Changes from all commits
4500e1e
5d96a06
553d930
29ecbf9
37f0aef
f6bedbe
504a379
4beedf5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 }} | ||
| {{- end }} | ||
|
|
||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Guard the - 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 |
||
| {{- end }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Guard the
metricssection to avoid emitting an empty listIf 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:🤖 Prompt for AI Agents