Skip to content

Commit ae2167f

Browse files
committed
add autoscaler for ingesters
Signed-off-by: Tom Hayward <[email protected]>
1 parent f5dde9c commit ae2167f

File tree

6 files changed

+58
-0
lines changed

6 files changed

+58
-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 ingesters #182
56
* [ENHANCEMENT] Use FQDN for memcached addresses #175
67

78
## 0.6.0 / 2021-06-28

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,12 @@ Kubernetes: `^1.19.0-0`
458458
| ingester.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.topologyKey | string | `"kubernetes.io/hostname"` | |
459459
| ingester.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].weight | int | `100` | |
460460
| ingester.annotations | object | `{}` | |
461+
| ingester.autoscaling.behavior.scaleDown.selectPolicy | string | `"Disabled"` | Scaledown procedure varies, so automatic scaledown is disabled Ref: https://cortexmetrics.io/docs/guides/ingesters-scaling-up-and-down/#scaling-down |
462+
| ingester.autoscaling.behavior.scaleUp.policies | list | `[{"periodSeconds":1800,"type":"Pods","value":1}]` | This default scaleup policy allows adding 1 pod every 30 minutes. Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior |
463+
| ingester.autoscaling.enabled | bool | `false` | |
464+
| ingester.autoscaling.maxReplicas | int | `30` | |
465+
| ingester.autoscaling.minReplicas | int | `3` | |
466+
| ingester.autoscaling.targetMemoryUtilizationPercentage | int | `80` | |
461467
| ingester.containerSecurityContext.enabled | bool | `true` | |
462468
| ingester.containerSecurityContext.readOnlyRootFilesystem | bool | `true` | |
463469
| ingester.env | list | `[]` | |

templates/ingester/ingester-dep.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ metadata:
99
annotations:
1010
{{- toYaml .Values.ingester.annotations | nindent 4 }}
1111
spec:
12+
{{- if not .Values.ingester.autoscaling.enabled }}
1213
replicas: {{ .Values.ingester.replicas }}
14+
{{- end }}
1315
selector:
1416
matchLabels:
1517
{{- include "cortex.ingesterSelectorLabels" . | nindent 6 }}

templates/ingester/ingester-hpa.yaml

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

templates/ingester/ingester-statefulset.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ metadata:
99
annotations:
1010
{{- toYaml .Values.ingester.annotations | nindent 4 }}
1111
spec:
12+
{{- if not .Values.ingester.autoscaling.enabled }}
1213
replicas: {{ .Values.ingester.replicas }}
14+
{{- end }}
1315
selector:
1416
matchLabels:
1517
{{- include "cortex.ingesterSelectorLabels" . | nindent 6 }}

values.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,24 @@ ingester:
511511

512512
annotations: {}
513513

514+
autoscaling:
515+
enabled: false
516+
minReplicas: 3
517+
maxReplicas: 30
518+
targetMemoryUtilizationPercentage: 80
519+
behavior:
520+
scaleDown:
521+
# -- Scaledown procedure varies, so automatic scaledown is disabled
522+
# Ref: https://cortexmetrics.io/docs/guides/ingesters-scaling-up-and-down/#scaling-down
523+
selectPolicy: Disabled
524+
scaleUp:
525+
# -- This default scaleup policy allows adding 1 pod every 30 minutes.
526+
# Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior
527+
policies:
528+
- type: Pods
529+
value: 1
530+
periodSeconds: 1800
531+
514532
## DEPRECATED: use persistentVolume.subPath instead
515533
persistence:
516534
subPath:

0 commit comments

Comments
 (0)