diff --git a/CHANGELOG.md b/CHANGELOG.md index 9784dcdf..03d0dc68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 054598e7..a6384d45 100644 --- a/README.md +++ b/README.md @@ -791,6 +791,11 @@ Kubernetes: `^1.19.0-0` | store_gateway.​affinity.​podAntiAffinity.​preferredDuringSchedulingIgnoredDuringExecution[0].​podAffinityTerm.​topologyKey | string | `"kubernetes.io/hostname"` | | | store_gateway.​affinity.​podAntiAffinity.​preferredDuringSchedulingIgnoredDuringExecution[0].​weight | int | `100` | | | store_gateway.​annotations | object | `{}` | | +| store_gateway.​autoscaling.​behavior | object | `{}` | Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior | +| store_gateway.​autoscaling.​enabled | bool | `false` | | +| store_gateway.​autoscaling.​maxReplicas | int | `30` | | +| store_gateway.​autoscaling.​minReplicas | int | `3` | | +| store_gateway.​autoscaling.​targetMemoryUtilizationPercentage | int | `80` | | | store_gateway.​containerSecurityContext.​enabled | bool | `true` | | | store_gateway.​containerSecurityContext.​readOnlyRootFilesystem | bool | `true` | | | store_gateway.​enabled | bool | `true` | | diff --git a/templates/store-gateway/store-gateway-hpa.yaml b/templates/store-gateway/store-gateway-hpa.yaml new file mode 100644 index 00000000..04abdecb --- /dev/null +++ b/templates/store-gateway/store-gateway-hpa.yaml @@ -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 }} diff --git a/values.yaml b/values.yaml index 89c3a6e1..f4cbdb26 100644 --- a/values.yaml +++ b/values.yaml @@ -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