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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## master / unreleased

* [FEATURE] Add `query_frontend.autoscaling` to create a HorizontalPodAutoscaler for the query-frontend, for setups that use the query-scheduler #706

## 3.7.0 / 2026-11-20

* [ENHANCEMENT] Render `podAnnotations` with `tpl`, so the default `prometheus.io/port` annotations follow `config.server.http_listen_port` #410
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,13 @@ Kubernetes: `^1.19.0-0`
| query_frontend.​affinity.​podAntiAffinity.​preferredDuringSchedulingIgnoredDuringExecution[0].​podAffinityTerm.​topologyKey | string | `"kubernetes.io/hostname"` | |
| query_frontend.​affinity.​podAntiAffinity.​preferredDuringSchedulingIgnoredDuringExecution[0].​weight | int | `100` | |
| query_frontend.​annotations | object | `{}` | |
| query_frontend.​autoscaling.​behavior | object | `{}` | Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior |
| query_frontend.​autoscaling.​enabled | bool | `false` | Creates a HorizontalPodAutoscaler for the query-frontend pods. Only scale the query-frontend when the query-scheduler is enabled, otherwise the query queue lives in the query-frontend. Ref: https://cortexmetrics.io/docs/operations/scaling-query-frontend/ |
| query_frontend.​autoscaling.​extraMetrics | list | `[]` | Optional custom and external metrics for the query-frontend pods to scale on |
| query_frontend.​autoscaling.​maxReplicas | int | `10` | |
| query_frontend.​autoscaling.​minReplicas | int | `2` | |
| query_frontend.​autoscaling.​targetCPUUtilizationPercentage | int | `80` | |
| query_frontend.​autoscaling.​targetMemoryUtilizationPercentage | int | `0` | |
| query_frontend.​containerSecurityContext.​enabled | bool | `true` | |
| query_frontend.​containerSecurityContext.​readOnlyRootFilesystem | bool | `true` | |
| query_frontend.​enabled | bool | `true` | |
Expand Down
2 changes: 2 additions & 0 deletions templates/query-frontend/query-frontend-dep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ metadata:
annotations:
{{- toYaml .Values.query_frontend.annotations | nindent 4 }}
spec:
{{- if not .Values.query_frontend.autoscaling.enabled }}
replicas: {{ .Values.query_frontend.replicas }}
{{- end }}
selector:
matchLabels:
{{- include "cortex.queryFrontendSelectorLabels" . | nindent 6 }}
Expand Down
42 changes: 42 additions & 0 deletions templates/query-frontend/query-frontend-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if and .Values.query_frontend.enabled .Values.query_frontend.autoscaling.enabled -}}
{{- with .Values.query_frontend.autoscaling -}}
apiVersion: {{ include "cortex.hpaVersion" $ }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "cortex.queryFrontendFullname" $ }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "cortex.queryFrontendLabels" $ | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "cortex.queryFrontendFullname" $ }}
minReplicas: {{ .minReplicas }}
maxReplicas: {{ .maxReplicas }}
metrics:
{{- with .targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .extraMetrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,20 @@ query_frontend:
enabled: true
replicas: 2

autoscaling:
# -- Creates a HorizontalPodAutoscaler for the query-frontend pods. Only scale the query-frontend
# when the query-scheduler is enabled, otherwise the query queue lives in the query-frontend.
# Ref: https://cortexmetrics.io/docs/operations/scaling-query-frontend/
enabled: false
minReplicas: 2
maxReplicas: 10
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 0 # 80
# -- Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior
behavior: {}
# -- Optional custom and external metrics for the query-frontend pods to scale on
extraMetrics: []

service:
annotations: {}
labels: {}
Expand Down
Loading