From bace24bea8c0b69340a4be73c7bc46a63d63be8f Mon Sep 17 00:00:00 2001 From: Muhammad Arsalan Date: Fri, 23 Jan 2026 22:38:06 -0600 Subject: [PATCH 1/2] Add Kubernetes autoscaling support for core services - Implement HPA resources for 8 services (fuzzer-bot, coverage-bot, build-bot, pov-reproducer, tracer-bot, patcher, seed-gen, task-downloader) - Add autoscaling configuration to service values files (disabled by default) - Update deployment templates to support conditional replica counts when HPA is enabled - Adjust resource requests for better HPA accuracy (fuzzer-bot, coverage-bot, pov-reproducer, tracer-bot) - Add autoscaling documentation to global values.yaml Resolves #348 --- .../build-bot/templates/deployment.yaml | 2 ++ .../k8s/charts/build-bot/templates/hpa.yaml | 34 +++++++++++++++++++ deployment/k8s/charts/build-bot/values.yaml | 16 +++++++++ .../coverage-bot/templates/deployment.yaml | 2 ++ .../charts/coverage-bot/templates/hpa.yaml | 34 +++++++++++++++++++ .../k8s/charts/coverage-bot/values.yaml | 20 +++++++++-- .../fuzzer-bot/templates/deployment.yaml | 2 ++ .../k8s/charts/fuzzer-bot/templates/hpa.yaml | 34 +++++++++++++++++++ deployment/k8s/charts/fuzzer-bot/values.yaml | 22 +++++++++++- .../charts/patcher/templates/deployment.yaml | 2 ++ .../k8s/charts/patcher/templates/hpa.yaml | 34 +++++++++++++++++++ deployment/k8s/charts/patcher/values.yaml | 12 +++++++ .../pov-reproducer/templates/deployment.yaml | 2 ++ .../charts/pov-reproducer/templates/hpa.yaml | 34 +++++++++++++++++++ .../k8s/charts/pov-reproducer/values.yaml | 21 ++++++++++-- .../charts/seed-gen/templates/deployment.yaml | 2 ++ .../k8s/charts/seed-gen/templates/hpa.yaml | 34 +++++++++++++++++++ deployment/k8s/charts/seed-gen/values.yaml | 12 +++++++ .../task-downloader/templates/deployment.yaml | 2 ++ .../charts/task-downloader/templates/hpa.yaml | 34 +++++++++++++++++++ .../k8s/charts/task-downloader/values.yaml | 12 +++++++ .../tracer-bot/templates/deployment.yaml | 2 ++ .../k8s/charts/tracer-bot/templates/hpa.yaml | 34 +++++++++++++++++++ deployment/k8s/charts/tracer-bot/values.yaml | 14 +++++++- deployment/k8s/values.yaml | 12 +++++++ 25 files changed, 423 insertions(+), 6 deletions(-) create mode 100644 deployment/k8s/charts/build-bot/templates/hpa.yaml create mode 100644 deployment/k8s/charts/coverage-bot/templates/hpa.yaml create mode 100644 deployment/k8s/charts/fuzzer-bot/templates/hpa.yaml create mode 100644 deployment/k8s/charts/patcher/templates/hpa.yaml create mode 100644 deployment/k8s/charts/pov-reproducer/templates/hpa.yaml create mode 100644 deployment/k8s/charts/seed-gen/templates/hpa.yaml create mode 100644 deployment/k8s/charts/task-downloader/templates/hpa.yaml create mode 100644 deployment/k8s/charts/tracer-bot/templates/hpa.yaml diff --git a/deployment/k8s/charts/build-bot/templates/deployment.yaml b/deployment/k8s/charts/build-bot/templates/deployment.yaml index 743e3e81..76c3b8d5 100644 --- a/deployment/k8s/charts/build-bot/templates/deployment.yaml +++ b/deployment/k8s/charts/build-bot/templates/deployment.yaml @@ -6,7 +6,9 @@ metadata: labels: app: build-bot spec: + {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount | default 1 }} + {{- end }} selector: matchLabels: app: build-bot diff --git a/deployment/k8s/charts/build-bot/templates/hpa.yaml b/deployment/k8s/charts/build-bot/templates/hpa.yaml new file mode 100644 index 00000000..67d28567 --- /dev/null +++ b/deployment/k8s/charts/build-bot/templates/hpa.yaml @@ -0,0 +1,34 @@ +{{- if and .Values.enabled .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-build-bot + labels: + app: build-bot +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-build-bot + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} + {{- with .Values.autoscaling.behavior }} + behavior: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployment/k8s/charts/build-bot/values.yaml b/deployment/k8s/charts/build-bot/values.yaml index eab264e6..df216cf9 100644 --- a/deployment/k8s/charts/build-bot/values.yaml +++ b/deployment/k8s/charts/build-bot/values.yaml @@ -11,3 +11,19 @@ resources: replicaCount: 4 timer: 5000 logLevel: "DEBUG" + +# Autoscaling configuration +autoscaling: + enabled: false + minReplicas: 2 + maxReplicas: 12 + targetCPUUtilizationPercentage: 75 + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + scaleUp: + stabilizationWindowSeconds: 60 + policies: + - type: Pods + value: 3 + periodSeconds: 60 diff --git a/deployment/k8s/charts/coverage-bot/templates/deployment.yaml b/deployment/k8s/charts/coverage-bot/templates/deployment.yaml index 04d29dea..67bbebaf 100644 --- a/deployment/k8s/charts/coverage-bot/templates/deployment.yaml +++ b/deployment/k8s/charts/coverage-bot/templates/deployment.yaml @@ -6,7 +6,9 @@ metadata: labels: app: coverage-bot spec: + {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount | default 1 }} + {{- end }} selector: matchLabels: app: coverage-bot diff --git a/deployment/k8s/charts/coverage-bot/templates/hpa.yaml b/deployment/k8s/charts/coverage-bot/templates/hpa.yaml new file mode 100644 index 00000000..f135f8eb --- /dev/null +++ b/deployment/k8s/charts/coverage-bot/templates/hpa.yaml @@ -0,0 +1,34 @@ +{{- if and .Values.enabled .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-coverage-bot + labels: + app: coverage-bot +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-coverage-bot + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} + {{- with .Values.autoscaling.behavior }} + behavior: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployment/k8s/charts/coverage-bot/values.yaml b/deployment/k8s/charts/coverage-bot/values.yaml index 75273be2..1dfee5dc 100644 --- a/deployment/k8s/charts/coverage-bot/values.yaml +++ b/deployment/k8s/charts/coverage-bot/values.yaml @@ -6,5 +6,21 @@ resources: cpu: 2000m memory: 16Gi requests: - cpu: 250m - memory: 256Mi + cpu: 500m + memory: 6Gi + +# Autoscaling configuration +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 6 + targetCPUUtilizationPercentage: 70 + behavior: + scaleDown: + stabilizationWindowSeconds: 600 + scaleUp: + stabilizationWindowSeconds: 120 + policies: + - type: Pods + value: 1 + periodSeconds: 60 diff --git a/deployment/k8s/charts/fuzzer-bot/templates/deployment.yaml b/deployment/k8s/charts/fuzzer-bot/templates/deployment.yaml index 775675e2..7b00fc61 100644 --- a/deployment/k8s/charts/fuzzer-bot/templates/deployment.yaml +++ b/deployment/k8s/charts/fuzzer-bot/templates/deployment.yaml @@ -6,7 +6,9 @@ metadata: labels: app: fuzzer-bot spec: + {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount | default 1 }} + {{- end }} selector: matchLabels: app: fuzzer-bot diff --git a/deployment/k8s/charts/fuzzer-bot/templates/hpa.yaml b/deployment/k8s/charts/fuzzer-bot/templates/hpa.yaml new file mode 100644 index 00000000..2e82d964 --- /dev/null +++ b/deployment/k8s/charts/fuzzer-bot/templates/hpa.yaml @@ -0,0 +1,34 @@ +{{- if and .Values.enabled .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-fuzzer-bot + labels: + app: fuzzer-bot +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-fuzzer-bot + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} + {{- with .Values.autoscaling.behavior }} + behavior: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployment/k8s/charts/fuzzer-bot/values.yaml b/deployment/k8s/charts/fuzzer-bot/values.yaml index 2124c7da..01fc6e33 100644 --- a/deployment/k8s/charts/fuzzer-bot/values.yaml +++ b/deployment/k8s/charts/fuzzer-bot/values.yaml @@ -6,7 +6,7 @@ resources: memory: 4Gi requests: cpu: 250m - memory: 256Mi + memory: 1536Mi timeout: 900 timer: 5000 @@ -25,3 +25,23 @@ healthCheck: timeoutSeconds: 10 # Allow 2 failures before restarting failureThreshold: 2 + +# Autoscaling configuration +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 10 + targetCPUUtilizationPercentage: 75 + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + policies: + - type: Percent + value: 25 + periodSeconds: 60 + scaleUp: + stabilizationWindowSeconds: 60 + policies: + - type: Pods + value: 2 + periodSeconds: 60 diff --git a/deployment/k8s/charts/patcher/templates/deployment.yaml b/deployment/k8s/charts/patcher/templates/deployment.yaml index 1e4f4c0e..42715091 100644 --- a/deployment/k8s/charts/patcher/templates/deployment.yaml +++ b/deployment/k8s/charts/patcher/templates/deployment.yaml @@ -6,7 +6,9 @@ metadata: labels: app: patcher spec: + {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount | default 1 }} + {{- end }} selector: matchLabels: app: patcher diff --git a/deployment/k8s/charts/patcher/templates/hpa.yaml b/deployment/k8s/charts/patcher/templates/hpa.yaml new file mode 100644 index 00000000..bac1bdf7 --- /dev/null +++ b/deployment/k8s/charts/patcher/templates/hpa.yaml @@ -0,0 +1,34 @@ +{{- if and .Values.enabled .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-patcher + labels: + app: patcher +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-patcher + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} + {{- with .Values.autoscaling.behavior }} + behavior: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployment/k8s/charts/patcher/values.yaml b/deployment/k8s/charts/patcher/values.yaml index 47859a97..564cdf67 100644 --- a/deployment/k8s/charts/patcher/values.yaml +++ b/deployment/k8s/charts/patcher/values.yaml @@ -9,3 +9,15 @@ resources: requests: cpu: 200m memory: 256Mi + +# Autoscaling configuration +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 5 + targetCPUUtilizationPercentage: 70 + behavior: + scaleDown: + stabilizationWindowSeconds: 600 + scaleUp: + stabilizationWindowSeconds: 120 diff --git a/deployment/k8s/charts/pov-reproducer/templates/deployment.yaml b/deployment/k8s/charts/pov-reproducer/templates/deployment.yaml index b86e38e0..478d6d01 100644 --- a/deployment/k8s/charts/pov-reproducer/templates/deployment.yaml +++ b/deployment/k8s/charts/pov-reproducer/templates/deployment.yaml @@ -3,7 +3,9 @@ kind: Deployment metadata: name: {{ .Release.Name }}-pov-reproducer spec: + {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount | default 1 }} + {{- end }} selector: matchLabels: app: pov-reproducer diff --git a/deployment/k8s/charts/pov-reproducer/templates/hpa.yaml b/deployment/k8s/charts/pov-reproducer/templates/hpa.yaml new file mode 100644 index 00000000..791c07bb --- /dev/null +++ b/deployment/k8s/charts/pov-reproducer/templates/hpa.yaml @@ -0,0 +1,34 @@ +{{- if and .Values.enabled .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-pov-reproducer + labels: + app: pov-reproducer +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-pov-reproducer + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} + {{- with .Values.autoscaling.behavior }} + behavior: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployment/k8s/charts/pov-reproducer/values.yaml b/deployment/k8s/charts/pov-reproducer/values.yaml index 55b696f9..90b912c1 100644 --- a/deployment/k8s/charts/pov-reproducer/values.yaml +++ b/deployment/k8s/charts/pov-reproducer/values.yaml @@ -7,10 +7,27 @@ resources: cpu: 2000m memory: 8Gi requests: - cpu: 100m - memory: 1Gi + cpu: 500m + memory: 3Gi # POV Reproducer specific configuration povReproducer: sleepTime: 5.0 maxRetries: 100000 + +# Autoscaling configuration +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 8 + targetCPUUtilizationPercentage: 70 + targetMemoryUtilizationPercentage: 75 + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + scaleUp: + stabilizationWindowSeconds: 90 + policies: + - type: Pods + value: 2 + periodSeconds: 60 diff --git a/deployment/k8s/charts/seed-gen/templates/deployment.yaml b/deployment/k8s/charts/seed-gen/templates/deployment.yaml index 8e80a533..86ff5326 100644 --- a/deployment/k8s/charts/seed-gen/templates/deployment.yaml +++ b/deployment/k8s/charts/seed-gen/templates/deployment.yaml @@ -6,7 +6,9 @@ metadata: labels: app: seed-gen spec: + {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount | default 1 }} + {{- end }} selector: matchLabels: app: seed-gen diff --git a/deployment/k8s/charts/seed-gen/templates/hpa.yaml b/deployment/k8s/charts/seed-gen/templates/hpa.yaml new file mode 100644 index 00000000..9be87700 --- /dev/null +++ b/deployment/k8s/charts/seed-gen/templates/hpa.yaml @@ -0,0 +1,34 @@ +{{- if and .Values.enabled .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-seed-gen + labels: + app: seed-gen +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-seed-gen + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} + {{- with .Values.autoscaling.behavior }} + behavior: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployment/k8s/charts/seed-gen/values.yaml b/deployment/k8s/charts/seed-gen/values.yaml index cb0e95fa..5bfdfdea 100644 --- a/deployment/k8s/charts/seed-gen/values.yaml +++ b/deployment/k8s/charts/seed-gen/values.yaml @@ -20,3 +20,15 @@ healthCheck: timeoutSeconds: 10 # Allow 2 failures before restarting failureThreshold: 2 + +# Autoscaling configuration +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 4 + targetCPUUtilizationPercentage: 75 + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + scaleUp: + stabilizationWindowSeconds: 120 diff --git a/deployment/k8s/charts/task-downloader/templates/deployment.yaml b/deployment/k8s/charts/task-downloader/templates/deployment.yaml index 10ef9e6e..5cfcbdd7 100644 --- a/deployment/k8s/charts/task-downloader/templates/deployment.yaml +++ b/deployment/k8s/charts/task-downloader/templates/deployment.yaml @@ -3,7 +3,9 @@ kind: Deployment metadata: name: {{ .Release.Name }}-task-downloader spec: + {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount | default 1 }} + {{- end }} selector: matchLabels: app: task-downloader diff --git a/deployment/k8s/charts/task-downloader/templates/hpa.yaml b/deployment/k8s/charts/task-downloader/templates/hpa.yaml new file mode 100644 index 00000000..02a06ecf --- /dev/null +++ b/deployment/k8s/charts/task-downloader/templates/hpa.yaml @@ -0,0 +1,34 @@ +{{- if and .Values.enabled .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-task-downloader + labels: + app: task-downloader +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-task-downloader + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} + {{- with .Values.autoscaling.behavior }} + behavior: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployment/k8s/charts/task-downloader/values.yaml b/deployment/k8s/charts/task-downloader/values.yaml index 8690258f..2bc6d089 100644 --- a/deployment/k8s/charts/task-downloader/values.yaml +++ b/deployment/k8s/charts/task-downloader/values.yaml @@ -8,3 +8,15 @@ resources: requests: cpu: 100m memory: 256Mi + +# Autoscaling configuration +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 3 + targetCPUUtilizationPercentage: 80 + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + scaleUp: + stabilizationWindowSeconds: 180 diff --git a/deployment/k8s/charts/tracer-bot/templates/deployment.yaml b/deployment/k8s/charts/tracer-bot/templates/deployment.yaml index 534b1e34..739cbc49 100644 --- a/deployment/k8s/charts/tracer-bot/templates/deployment.yaml +++ b/deployment/k8s/charts/tracer-bot/templates/deployment.yaml @@ -6,7 +6,9 @@ metadata: labels: app: tracer-bot spec: + {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount | default 1 }} + {{- end }} selector: matchLabels: app: tracer-bot diff --git a/deployment/k8s/charts/tracer-bot/templates/hpa.yaml b/deployment/k8s/charts/tracer-bot/templates/hpa.yaml new file mode 100644 index 00000000..e0b24df8 --- /dev/null +++ b/deployment/k8s/charts/tracer-bot/templates/hpa.yaml @@ -0,0 +1,34 @@ +{{- if and .Values.enabled .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-tracer-bot + labels: + app: tracer-bot +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-tracer-bot + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} + {{- with .Values.autoscaling.behavior }} + behavior: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployment/k8s/charts/tracer-bot/values.yaml b/deployment/k8s/charts/tracer-bot/values.yaml index c3b817b2..9bedbcb2 100644 --- a/deployment/k8s/charts/tracer-bot/values.yaml +++ b/deployment/k8s/charts/tracer-bot/values.yaml @@ -8,7 +8,7 @@ resources: memory: 4Gi requests: cpu: 100m - memory: 256Mi + memory: 1536Mi # Number of replicas replicaCount: 1 @@ -24,3 +24,15 @@ healthCheck: timeoutSeconds: 10 # Allow 2 failures before restarting failureThreshold: 2 + +# Autoscaling configuration +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 6 + targetCPUUtilizationPercentage: 75 + behavior: + scaleDown: + stabilizationWindowSeconds: 600 + scaleUp: + stabilizationWindowSeconds: 120 diff --git a/deployment/k8s/values.yaml b/deployment/k8s/values.yaml index 4995b478..30847d0a 100644 --- a/deployment/k8s/values.yaml +++ b/deployment/k8s/values.yaml @@ -104,6 +104,18 @@ volumes: size: "1Gi" accessMode: ReadWriteOnce +# Autoscaling Configuration +# Each service can enable HPA by setting autoscaling.enabled=true in its values +# Example: +# fuzzer-bot: +# autoscaling: +# enabled: true +# minReplicas: 1 +# maxReplicas: 10 +# Prerequisites: +# - metrics-server must be installed in the cluster +# - For Minikube: minikube addons enable metrics-server +# - For AKS: metrics-server is pre-installed # Dind daemon chart configuration dind-daemon: From 3c9a7c7a698f5a109e9653b57e7cbb0b29f66515 Mon Sep 17 00:00:00 2001 From: Muhammad Arsalan Date: Sat, 24 Jan 2026 12:49:22 -0600 Subject: [PATCH 2/2] Address PR review: refactor HPA templates and revert resource changes - Revert resource request increases to original values - Extract shared HPA template into _helpers.tpl to reduce duplication - Add memory-based scaling for memory-intensive services - Document scale-down stabilization window choices --- .../k8s/charts/build-bot/templates/hpa.yaml | 35 +--------------- deployment/k8s/charts/build-bot/values.yaml | 1 + .../charts/coverage-bot/templates/hpa.yaml | 35 +--------------- .../k8s/charts/coverage-bot/values.yaml | 6 ++- .../k8s/charts/fuzzer-bot/templates/hpa.yaml | 35 +--------------- deployment/k8s/charts/fuzzer-bot/values.yaml | 4 +- .../k8s/charts/patcher/templates/hpa.yaml | 35 +--------------- deployment/k8s/charts/patcher/values.yaml | 1 + .../charts/pov-reproducer/templates/hpa.yaml | 35 +--------------- .../k8s/charts/pov-reproducer/values.yaml | 5 ++- .../k8s/charts/seed-gen/templates/hpa.yaml | 35 +--------------- deployment/k8s/charts/seed-gen/values.yaml | 1 + .../charts/task-downloader/templates/hpa.yaml | 35 +--------------- .../k8s/charts/task-downloader/values.yaml | 1 + .../k8s/charts/tracer-bot/templates/hpa.yaml | 35 +--------------- deployment/k8s/charts/tracer-bot/values.yaml | 4 +- deployment/k8s/templates/_helpers.tpl | 42 +++++++++++++++++++ 17 files changed, 67 insertions(+), 278 deletions(-) diff --git a/deployment/k8s/charts/build-bot/templates/hpa.yaml b/deployment/k8s/charts/build-bot/templates/hpa.yaml index 67d28567..8367674a 100644 --- a/deployment/k8s/charts/build-bot/templates/hpa.yaml +++ b/deployment/k8s/charts/build-bot/templates/hpa.yaml @@ -1,34 +1 @@ -{{- if and .Values.enabled .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ .Release.Name }}-build-bot - labels: - app: build-bot -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ .Release.Name }}-build-bot - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} - {{- with .Values.autoscaling.behavior }} - behavior: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} +{{ include "buttercup.hpa" . }} diff --git a/deployment/k8s/charts/build-bot/values.yaml b/deployment/k8s/charts/build-bot/values.yaml index df216cf9..905d7812 100644 --- a/deployment/k8s/charts/build-bot/values.yaml +++ b/deployment/k8s/charts/build-bot/values.yaml @@ -20,6 +20,7 @@ autoscaling: targetCPUUtilizationPercentage: 75 behavior: scaleDown: + # 300s: build tasks are relatively short-lived and can tolerate faster scale-down stabilizationWindowSeconds: 300 scaleUp: stabilizationWindowSeconds: 60 diff --git a/deployment/k8s/charts/coverage-bot/templates/hpa.yaml b/deployment/k8s/charts/coverage-bot/templates/hpa.yaml index f135f8eb..8367674a 100644 --- a/deployment/k8s/charts/coverage-bot/templates/hpa.yaml +++ b/deployment/k8s/charts/coverage-bot/templates/hpa.yaml @@ -1,34 +1 @@ -{{- if and .Values.enabled .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ .Release.Name }}-coverage-bot - labels: - app: coverage-bot -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ .Release.Name }}-coverage-bot - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} - {{- with .Values.autoscaling.behavior }} - behavior: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} +{{ include "buttercup.hpa" . }} diff --git a/deployment/k8s/charts/coverage-bot/values.yaml b/deployment/k8s/charts/coverage-bot/values.yaml index 1dfee5dc..80dcea27 100644 --- a/deployment/k8s/charts/coverage-bot/values.yaml +++ b/deployment/k8s/charts/coverage-bot/values.yaml @@ -6,8 +6,8 @@ resources: cpu: 2000m memory: 16Gi requests: - cpu: 500m - memory: 6Gi + cpu: 250m + memory: 256Mi # Autoscaling configuration autoscaling: @@ -15,8 +15,10 @@ autoscaling: minReplicas: 1 maxReplicas: 6 targetCPUUtilizationPercentage: 70 + targetMemoryUtilizationPercentage: 75 behavior: scaleDown: + # 600s: long-running coverage analysis should not be interrupted by premature scale-down stabilizationWindowSeconds: 600 scaleUp: stabilizationWindowSeconds: 120 diff --git a/deployment/k8s/charts/fuzzer-bot/templates/hpa.yaml b/deployment/k8s/charts/fuzzer-bot/templates/hpa.yaml index 2e82d964..8367674a 100644 --- a/deployment/k8s/charts/fuzzer-bot/templates/hpa.yaml +++ b/deployment/k8s/charts/fuzzer-bot/templates/hpa.yaml @@ -1,34 +1 @@ -{{- if and .Values.enabled .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ .Release.Name }}-fuzzer-bot - labels: - app: fuzzer-bot -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ .Release.Name }}-fuzzer-bot - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} - {{- with .Values.autoscaling.behavior }} - behavior: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} +{{ include "buttercup.hpa" . }} diff --git a/deployment/k8s/charts/fuzzer-bot/values.yaml b/deployment/k8s/charts/fuzzer-bot/values.yaml index 01fc6e33..6a21447b 100644 --- a/deployment/k8s/charts/fuzzer-bot/values.yaml +++ b/deployment/k8s/charts/fuzzer-bot/values.yaml @@ -6,7 +6,7 @@ resources: memory: 4Gi requests: cpu: 250m - memory: 1536Mi + memory: 256Mi timeout: 900 timer: 5000 @@ -32,8 +32,10 @@ autoscaling: minReplicas: 1 maxReplicas: 10 targetCPUUtilizationPercentage: 75 + targetMemoryUtilizationPercentage: 80 behavior: scaleDown: + # 300s: shorter-lived fuzzing tasks can tolerate faster scale-down stabilizationWindowSeconds: 300 policies: - type: Percent diff --git a/deployment/k8s/charts/patcher/templates/hpa.yaml b/deployment/k8s/charts/patcher/templates/hpa.yaml index bac1bdf7..8367674a 100644 --- a/deployment/k8s/charts/patcher/templates/hpa.yaml +++ b/deployment/k8s/charts/patcher/templates/hpa.yaml @@ -1,34 +1 @@ -{{- if and .Values.enabled .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ .Release.Name }}-patcher - labels: - app: patcher -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ .Release.Name }}-patcher - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} - {{- with .Values.autoscaling.behavior }} - behavior: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} +{{ include "buttercup.hpa" . }} diff --git a/deployment/k8s/charts/patcher/values.yaml b/deployment/k8s/charts/patcher/values.yaml index 564cdf67..db206bf7 100644 --- a/deployment/k8s/charts/patcher/values.yaml +++ b/deployment/k8s/charts/patcher/values.yaml @@ -18,6 +18,7 @@ autoscaling: targetCPUUtilizationPercentage: 70 behavior: scaleDown: + # 600s: LLM-powered patching tasks are long-running and should not be interrupted stabilizationWindowSeconds: 600 scaleUp: stabilizationWindowSeconds: 120 diff --git a/deployment/k8s/charts/pov-reproducer/templates/hpa.yaml b/deployment/k8s/charts/pov-reproducer/templates/hpa.yaml index 791c07bb..8367674a 100644 --- a/deployment/k8s/charts/pov-reproducer/templates/hpa.yaml +++ b/deployment/k8s/charts/pov-reproducer/templates/hpa.yaml @@ -1,34 +1 @@ -{{- if and .Values.enabled .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ .Release.Name }}-pov-reproducer - labels: - app: pov-reproducer -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ .Release.Name }}-pov-reproducer - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} - {{- with .Values.autoscaling.behavior }} - behavior: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} +{{ include "buttercup.hpa" . }} diff --git a/deployment/k8s/charts/pov-reproducer/values.yaml b/deployment/k8s/charts/pov-reproducer/values.yaml index 90b912c1..186d4e3c 100644 --- a/deployment/k8s/charts/pov-reproducer/values.yaml +++ b/deployment/k8s/charts/pov-reproducer/values.yaml @@ -7,8 +7,8 @@ resources: cpu: 2000m memory: 8Gi requests: - cpu: 500m - memory: 3Gi + cpu: 100m + memory: 1Gi # POV Reproducer specific configuration povReproducer: @@ -24,6 +24,7 @@ autoscaling: targetMemoryUtilizationPercentage: 75 behavior: scaleDown: + # 300s: POV reproduction tasks are relatively short-lived stabilizationWindowSeconds: 300 scaleUp: stabilizationWindowSeconds: 90 diff --git a/deployment/k8s/charts/seed-gen/templates/hpa.yaml b/deployment/k8s/charts/seed-gen/templates/hpa.yaml index 9be87700..8367674a 100644 --- a/deployment/k8s/charts/seed-gen/templates/hpa.yaml +++ b/deployment/k8s/charts/seed-gen/templates/hpa.yaml @@ -1,34 +1 @@ -{{- if and .Values.enabled .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ .Release.Name }}-seed-gen - labels: - app: seed-gen -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ .Release.Name }}-seed-gen - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} - {{- with .Values.autoscaling.behavior }} - behavior: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} +{{ include "buttercup.hpa" . }} diff --git a/deployment/k8s/charts/seed-gen/values.yaml b/deployment/k8s/charts/seed-gen/values.yaml index 5bfdfdea..13bd6192 100644 --- a/deployment/k8s/charts/seed-gen/values.yaml +++ b/deployment/k8s/charts/seed-gen/values.yaml @@ -29,6 +29,7 @@ autoscaling: targetCPUUtilizationPercentage: 75 behavior: scaleDown: + # 300s: seed generation tasks are relatively short-lived stabilizationWindowSeconds: 300 scaleUp: stabilizationWindowSeconds: 120 diff --git a/deployment/k8s/charts/task-downloader/templates/hpa.yaml b/deployment/k8s/charts/task-downloader/templates/hpa.yaml index 02a06ecf..8367674a 100644 --- a/deployment/k8s/charts/task-downloader/templates/hpa.yaml +++ b/deployment/k8s/charts/task-downloader/templates/hpa.yaml @@ -1,34 +1 @@ -{{- if and .Values.enabled .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ .Release.Name }}-task-downloader - labels: - app: task-downloader -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ .Release.Name }}-task-downloader - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} - {{- with .Values.autoscaling.behavior }} - behavior: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} +{{ include "buttercup.hpa" . }} diff --git a/deployment/k8s/charts/task-downloader/values.yaml b/deployment/k8s/charts/task-downloader/values.yaml index 2bc6d089..97eab549 100644 --- a/deployment/k8s/charts/task-downloader/values.yaml +++ b/deployment/k8s/charts/task-downloader/values.yaml @@ -17,6 +17,7 @@ autoscaling: targetCPUUtilizationPercentage: 80 behavior: scaleDown: + # 300s: download tasks are short-lived and can tolerate faster scale-down stabilizationWindowSeconds: 300 scaleUp: stabilizationWindowSeconds: 180 diff --git a/deployment/k8s/charts/tracer-bot/templates/hpa.yaml b/deployment/k8s/charts/tracer-bot/templates/hpa.yaml index e0b24df8..8367674a 100644 --- a/deployment/k8s/charts/tracer-bot/templates/hpa.yaml +++ b/deployment/k8s/charts/tracer-bot/templates/hpa.yaml @@ -1,34 +1 @@ -{{- if and .Values.enabled .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ .Release.Name }}-tracer-bot - labels: - app: tracer-bot -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ .Release.Name }}-tracer-bot - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} - {{- with .Values.autoscaling.behavior }} - behavior: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} +{{ include "buttercup.hpa" . }} diff --git a/deployment/k8s/charts/tracer-bot/values.yaml b/deployment/k8s/charts/tracer-bot/values.yaml index 9bedbcb2..256e4802 100644 --- a/deployment/k8s/charts/tracer-bot/values.yaml +++ b/deployment/k8s/charts/tracer-bot/values.yaml @@ -8,7 +8,7 @@ resources: memory: 4Gi requests: cpu: 100m - memory: 1536Mi + memory: 256Mi # Number of replicas replicaCount: 1 @@ -31,8 +31,10 @@ autoscaling: minReplicas: 1 maxReplicas: 6 targetCPUUtilizationPercentage: 75 + targetMemoryUtilizationPercentage: 80 behavior: scaleDown: + # 600s: long-running trace analysis should not be interrupted by premature scale-down stabilizationWindowSeconds: 600 scaleUp: stabilizationWindowSeconds: 120 diff --git a/deployment/k8s/templates/_helpers.tpl b/deployment/k8s/templates/_helpers.tpl index 5ee3a1e7..71200380 100644 --- a/deployment/k8s/templates/_helpers.tpl +++ b/deployment/k8s/templates/_helpers.tpl @@ -217,3 +217,45 @@ Usage: {{- include "buttercup.apiKeySecretVolume" (dict "secretName" "litellm-ap secret: secretName: {{ .secretName }} {{- end -}} + +{{/* +Define a shared HorizontalPodAutoscaler template for all services. +Uses .Chart.Name to dynamically resolve the service name from each subchart. +Usage (in subchart's hpa.yaml): {{ include "buttercup.hpa" . }} +*/}} +{{- define "buttercup.hpa" -}} +{{- if and .Values.enabled .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }} + labels: + app: {{ .Chart.Name }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }}-{{ .Chart.Name }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} + {{- with .Values.autoscaling.behavior }} + behavior: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} +{{- end -}}