Skip to content

Commit 5061ce8

Browse files
authored
add autoscaler for queriers (#190)
Signed-off-by: Tom Hayward <[email protected]>
1 parent 175d620 commit 5061ce8

File tree

6 files changed

+62
-0
lines changed

6 files changed

+62
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## master / unreleased
44

5+
* [FEATURE] Add autoscaler for queriers #190
56
* [FEATURE] Add autoscaler for distributors #189
67
* [FEATURE] Add autoscaler for ingesters #182
78
* [ENHANCEMENT] Define namespace in templates #184

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,12 @@ Kubernetes: `^1.19.0-0`
632632
| querier.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.topologyKey | string | `"kubernetes.io/hostname"` | |
633633
| querier.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].weight | int | `100` | |
634634
| querier.annotations | object | `{}` | |
635+
| querier.autoscaling.behavior | object | `{}` | Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior |
636+
| querier.autoscaling.enabled | bool | `false` | Creates a HorizontalPodAutoscaler for the querier pods. |
637+
| querier.autoscaling.maxReplicas | int | `30` | |
638+
| querier.autoscaling.minReplicas | int | `2` | |
639+
| querier.autoscaling.targetCPUUtilizationPercentage | int | `80` | |
640+
| querier.autoscaling.targetMemoryUtilizationPercentage | int | `0` | |
635641
| querier.containerSecurityContext.enabled | bool | `true` | |
636642
| querier.containerSecurityContext.readOnlyRootFilesystem | bool | `true` | |
637643
| querier.env | list | `[]` | |

ci/test-values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,8 @@ distributor:
6767
autoscaling:
6868
enabled: true
6969
minReplicas: 1
70+
querier:
71+
autoscaling:
72+
enabled: true
7073
nginx:
7174
replicas: 1

templates/querier/querier-dep.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ metadata:
88
annotations:
99
{{- toYaml .Values.querier.annotations | nindent 4 }}
1010
spec:
11+
{{- if not .Values.querier.autoscaling.enabled }}
1112
replicas: {{ .Values.querier.replicas }}
13+
{{- end }}
1214
selector:
1315
matchLabels:
1416
{{- include "cortex.querierSelectorLabels" . | nindent 6 }}

templates/querier/querier-hpa.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{{- with .Values.querier.autoscaling -}}
2+
{{- if .enabled }}
3+
apiVersion: autoscaling/v2beta2
4+
kind: HorizontalPodAutoscaler
5+
metadata:
6+
name: {{ include "cortex.querierFullname" $ }}
7+
namespace: {{ $.Release.Namespace }}
8+
labels:
9+
{{- include "cortex.querierLabels" $ | nindent 4 }}
10+
spec:
11+
scaleTargetRef:
12+
apiVersion: apps/v1
13+
kind: Deployment
14+
name: {{ include "cortex.querierFullname" $ }}
15+
minReplicas: {{ .minReplicas }}
16+
maxReplicas: {{ .maxReplicas }}
17+
metrics:
18+
{{- with .targetCPUUtilizationPercentage }}
19+
- type: Resource
20+
resource:
21+
name: cpu
22+
target:
23+
type: Utilization
24+
averageUtilization: {{ . }}
25+
{{- end }}
26+
{{- with .targetMemoryUtilizationPercentage }}
27+
- type: Resource
28+
resource:
29+
name: memory
30+
target:
31+
type: Utilization
32+
averageUtilization: {{ . }}
33+
{{- end }}
34+
{{- with .behavior }}
35+
behavior:
36+
{{- toYaml . | nindent 4 }}
37+
{{- end }}
38+
{{- end }}
39+
{{- end }}

values.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,17 @@ querier:
819819
topologyKey: 'kubernetes.io/hostname'
820820

821821
annotations: {}
822+
823+
autoscaling:
824+
# -- Creates a HorizontalPodAutoscaler for the querier pods.
825+
enabled: false
826+
minReplicas: 2
827+
maxReplicas: 30
828+
targetCPUUtilizationPercentage: 80
829+
targetMemoryUtilizationPercentage: 0 # 80
830+
# -- Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior
831+
behavior: {}
832+
822833
persistence:
823834
subPath:
824835

0 commit comments

Comments
 (0)