Skip to content

Commit 4bf5aca

Browse files
authored
graceful shutdown of ingesters (#195)
* graceful shutdown of ingesters Signed-off-by: Tom Hayward <[email protected]> * tolerate auto-scale-down now that it is safe Signed-off-by: Tom Hayward <[email protected]> * allow overriding preStop hook Signed-off-by: Tom Hayward <[email protected]>
1 parent 91969f6 commit 4bf5aca

File tree

5 files changed

+31
-4
lines changed

5 files changed

+31
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* [FEATURE] Add autoscaler for queriers #190
66
* [FEATURE] Add autoscaler for distributors #189
77
* [FEATURE] Add autoscaler for ingesters #182
8+
* [ENHANCEMENT] Graceful shutdown of ingesters #195
89
* [ENHANCEMENT] Define namespace in templates #184
910
* [ENHANCEMENT] Use FQDN for memcached addresses #175
1011
* [ENHANCEMENT] Optionally generate endpoints for `X-Scope-OrgID` injection (multi-tenancy) #180

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,8 @@ Kubernetes: `^1.19.0-0`
466466
| ingester.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.topologyKey | string | `"kubernetes.io/hostname"` | |
467467
| ingester.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].weight | int | `100` | |
468468
| ingester.annotations | object | `{}` | |
469-
| 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 |
469+
| ingester.autoscaling.behavior.scaleDown.policies | list | `[{"periodSeconds":1800,"type":"Pods","value":1}]` | see https://cortexmetrics.io/docs/guides/ingesters-scaling-up-and-down/#scaling-down for scaledown details |
470+
| ingester.autoscaling.behavior.scaleDown.stabilizationWindowSeconds | int | `3600` | uses metrics from the past 1h to make scaleDown decisions |
470471
| 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 |
471472
| ingester.autoscaling.enabled | bool | `false` | |
472473
| ingester.autoscaling.maxReplicas | int | `30` | |
@@ -481,6 +482,7 @@ Kubernetes: `^1.19.0-0`
481482
| ingester.extraVolumeMounts | list | `[]` | |
482483
| ingester.extraVolumes | list | `[]` | |
483484
| ingester.initContainers | list | `[]` | |
485+
| ingester.lifecycle.preStop | object | `{"httpGet":{"path":"/ingester/shutdown","port":"http-metrics"}}` | The /shutdown preStop hook is recommended as part of the ingester scaledown process, but can be removed to optimize rolling restarts in instances that will never be scaled down or when using chunks storage with WAL disabled. https://cortexmetrics.io/docs/guides/ingesters-scaling-up-and-down/#scaling-down |
484486
| ingester.livenessProbe.httpGet.path | string | `"/ready"` | |
485487
| ingester.livenessProbe.httpGet.port | string | `"http-metrics"` | |
486488
| ingester.livenessProbe.httpGet.scheme | string | `"HTTP"` | |

templates/ingester/ingester-dep.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ spec:
103103
{{- if .Values.ingester.env }}
104104
{{ toYaml .Values.ingester.env | nindent 12 }}
105105
{{- end }}
106+
{{- with .Values.ingester.lifecycle }}
107+
lifecycle:
108+
{{- toYaml . | nindent 12 }}
109+
{{- end }}
106110
{{- with .Values.ingester.extraContainers }}
107111
{{ toYaml . | nindent 8 }}
108112
{{- end }}

templates/ingester/ingester-statefulset.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,8 @@ spec:
151151
{{- if .Values.ingester.env }}
152152
{{- toYaml .Values.ingester.env | nindent 12 }}
153153
{{- end }}
154+
{{- with .Values.ingester.lifecycle }}
155+
lifecycle:
156+
{{- toYaml . | nindent 12 }}
157+
{{- end }}
154158
{{- end -}}

values.yaml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,14 @@ ingester:
537537
targetMemoryUtilizationPercentage: 80
538538
behavior:
539539
scaleDown:
540-
# -- Scaledown procedure varies, so automatic scaledown is disabled
541-
# Ref: https://cortexmetrics.io/docs/guides/ingesters-scaling-up-and-down/#scaling-down
542-
selectPolicy: Disabled
540+
# -- see https://cortexmetrics.io/docs/guides/ingesters-scaling-up-and-down/#scaling-down for scaledown details
541+
policies:
542+
- type: Pods
543+
value: 1
544+
# set to no less than 2x the maximum between -blocks-storage.bucket-store.sync-interval and -compactor.cleanup-interval
545+
periodSeconds: 1800
546+
# -- uses metrics from the past 1h to make scaleDown decisions
547+
stabilizationWindowSeconds: 3600
543548
scaleUp:
544549
# -- This default scaleup policy allows adding 1 pod every 30 minutes.
545550
# Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior
@@ -548,6 +553,17 @@ ingester:
548553
value: 1
549554
periodSeconds: 1800
550555

556+
lifecycle:
557+
# -- The /shutdown preStop hook is recommended as part of the ingester
558+
# scaledown process, but can be removed to optimize rolling restarts in
559+
# instances that will never be scaled down or when using chunks storage
560+
# with WAL disabled.
561+
# https://cortexmetrics.io/docs/guides/ingesters-scaling-up-and-down/#scaling-down
562+
preStop:
563+
httpGet:
564+
path: "/ingester/shutdown"
565+
port: http-metrics
566+
551567
## DEPRECATED: use persistentVolume.subPath instead
552568
persistence:
553569
subPath:

0 commit comments

Comments
 (0)