Skip to content

Commit

Permalink
Add HPA to store gateway (#406)
Browse files Browse the repository at this point in the history
* Add HPA to store gateway

Signed-off-by: Matthew Ames <mames@yelp.com>

* Fix changelog PR number

Signed-off-by: Matthew Ames <mames@yelp.com>

Signed-off-by: Matthew Ames <mames@yelp.com>
  • Loading branch information
SuperMatt authored Oct 19, 2022
1 parent ac382ed commit 858b6e2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [ENHANCEMENT] Add verboseLogging option to nginx config #402
* [DEPENDENCY] Update quay.io/cortexproject/cortex Docker tag to v1.13.1 #401
* [ENHANCEMENT] Add pod topology spread constrant option to Ingester/Alertmanager statefulset #403
* [ENHANCEMENT] Add HPA to store gateways #406

# 1.7.0 / 2022-09-23

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,11 @@ Kubernetes: `^1.19.0-0`
| store_gateway.&ZeroWidthSpace;affinity.&ZeroWidthSpace;podAntiAffinity.&ZeroWidthSpace;preferredDuringSchedulingIgnoredDuringExecution[0].&ZeroWidthSpace;podAffinityTerm.&ZeroWidthSpace;topologyKey | string | `"kubernetes.io/hostname"` | |
| store_gateway.&ZeroWidthSpace;affinity.&ZeroWidthSpace;podAntiAffinity.&ZeroWidthSpace;preferredDuringSchedulingIgnoredDuringExecution[0].&ZeroWidthSpace;weight | int | `100` | |
| store_gateway.&ZeroWidthSpace;annotations | object | `{}` | |
| store_gateway.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;behavior | object | `{}` | Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior |
| store_gateway.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;enabled | bool | `false` | |
| store_gateway.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;maxReplicas | int | `30` | |
| store_gateway.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;minReplicas | int | `3` | |
| store_gateway.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;targetMemoryUtilizationPercentage | int | `80` | |
| store_gateway.&ZeroWidthSpace;containerSecurityContext.&ZeroWidthSpace;enabled | bool | `true` | |
| store_gateway.&ZeroWidthSpace;containerSecurityContext.&ZeroWidthSpace;readOnlyRootFilesystem | bool | `true` | |
| store_gateway.&ZeroWidthSpace;enabled | bool | `true` | |
Expand Down
29 changes: 29 additions & 0 deletions templates/store-gateway/store-gateway-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- if and .Values.store_gateway.enabled .Values.store_gateway.autoscaling.enabled -}}
{{- with .Values.store_gateway.autoscaling -}}
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "cortex.storeGatewayFullname" $ }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "cortex.storeGatewayLabels" $ | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: StatefulSet
name: {{ include "cortex.storeGatewayFullname" $ }}
minReplicas: {{ .minReplicas }}
maxReplicas: {{ .maxReplicas }}
metrics:
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .targetMemoryUtilizationPercentage }}
{{- with .behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
8 changes: 8 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,14 @@ store_gateway:

annotations: {}

autoscaling:
enabled: false
minReplicas: 3
maxReplicas: 30
targetMemoryUtilizationPercentage: 80
# -- Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior
behavior: {}

persistentVolume:
# -- If true Store-gateway will create/use a Persistent Volume Claim
# If false, use emptyDir
Expand Down

0 comments on commit 858b6e2

Please sign in to comment.