Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for configuring HPA with custom/external metrics #467

Merged
merged 12 commits into from
Jun 27, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## master / unreleased

* [ENHANCEMENT] Add option to autoscale on multiple metrics and custom metrics metrics #467
* [DEPENDENCY] Update quay.io/cortexproject/cortex Docker tag to v1.15.0 #453
* [DEPENDENCY] Update quay.io/cortexproject/cortex Docker tag to v1.15.1 #456
* [BUGFIX] Correctly interpret .Capabilities.KubeVersion when it looks like a prerelease #457
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ Kubernetes: `^1.19.0-0`
| distributor.​affinity.​podAntiAffinity.​preferredDuringSchedulingIgnoredDuringExecution[0].​weight | int | `100` | |
| distributor.​annotations | object | `{}` | |
| distributor.​autoscaling.​behavior | object | `{}` | Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior |
| distributor.​autoscaling.​customMetrics | list | `[]` | Optional custom and external metrics for the distributor pods to scale on In order to use this option , define a list of of specific following either: - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects For example: - type: External external: metric: name: queue_messages_ready selector: matchLabels: queue: "worker_tasks" target: type: AverageValue averageValue: 30 |
| distributor.​autoscaling.​enabled | bool | `false` | Creates a HorizontalPodAutoscaler for the distributor pods. |
| distributor.​autoscaling.​maxReplicas | int | `30` | |
| distributor.​autoscaling.​minReplicas | int | `2` | |
Expand Down Expand Up @@ -326,6 +327,7 @@ Kubernetes: `^1.19.0-0`
| 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 |
| ingester.​autoscaling.​behavior.​scaleDown.​stabilizationWindowSeconds | int | `3600` | uses metrics from the past 1h to make scaleDown decisions |
| 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 |
| ingester.​autoscaling.​customMetrics | list | `[]` | Optional custom and external metrics for the ingester pods to scale on In order to use this option , define a list of of specific following either: - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects For example: - type: External external: metric: name: queue_messages_ready selector: matchLabels: queue: "worker_tasks" target: type: AverageValue averageValue: 30 |
| ingester.​autoscaling.​enabled | bool | `false` | |
| ingester.​autoscaling.​maxReplicas | int | `30` | |
| ingester.​autoscaling.​minReplicas | int | `3` | |
Expand Down Expand Up @@ -424,6 +426,7 @@ Kubernetes: `^1.19.0-0`
| nginx.​affinity | object | `{}` | |
| nginx.​annotations | object | `{}` | |
| nginx.​autoscaling.​behavior | object | `{}` | Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior |
| nginx.​autoscaling.​customMetrics | list | `[]` | Optional custom and external metrics for the nginx pods to scale on In order to use this option , define a list of of specific following either: - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects For example: - type: External external: metric: name: queue_messages_ready selector: matchLabels: queue: "worker_tasks" target: type: AverageValue averageValue: 30 |
| nginx.​autoscaling.​enabled | bool | `false` | Creates a HorizontalPodAutoscaler for the nginx pods. |
| nginx.​autoscaling.​maxReplicas | int | `30` | |
| nginx.​autoscaling.​minReplicas | int | `2` | |
Expand Down Expand Up @@ -571,6 +574,7 @@ Kubernetes: `^1.19.0-0`
| querier.​affinity.​podAntiAffinity.​preferredDuringSchedulingIgnoredDuringExecution[0].​weight | int | `100` | |
| querier.​annotations | object | `{}` | |
| querier.​autoscaling.​behavior | object | `{}` | Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior |
| querier.​autoscaling.​customMetrics | list | `[]` | Optional custom and external metrics for the querier pods to scale on In order to use this option , define a list of of specific following either: - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects For example: - type: External external: metric: name: queue_messages_ready selector: matchLabels: queue: "worker_tasks" target: type: AverageValue averageValue: 30 |
| querier.​autoscaling.​enabled | bool | `false` | Creates a HorizontalPodAutoscaler for the querier pods. |
| querier.​autoscaling.​maxReplicas | int | `30` | |
| querier.​autoscaling.​minReplicas | int | `2` | |
Expand Down Expand Up @@ -713,6 +717,7 @@ Kubernetes: `^1.19.0-0`
| ruler.​affinity | object | `{}` | |
| ruler.​annotations | object | `{}` | |
| ruler.​autoscaling.​behavior | object | `{}` | Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior |
| ruler.​autoscaling.​customMetrics | list | `[]` | Optional custom and external metrics for the ruler pods to scale on In order to use this option , define a list of of specific following either: - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects For example: - type: External external: metric: name: queue_messages_ready selector: matchLabels: queue: "worker_tasks" target: type: AverageValue averageValue: 30 |
| ruler.​autoscaling.​enabled | bool | `false` | Creates a HorizontalPodAutoscaler for the ruler. |
| ruler.​autoscaling.​maxReplicas | int | `30` | |
| ruler.​autoscaling.​minReplicas | int | `2` | |
Expand Down Expand Up @@ -791,6 +796,7 @@ Kubernetes: `^1.19.0-0`
| 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.​customMetrics | list | `[]` | Optional custom and external metrics for the store gateway pods to scale on In order to use this option , define a list of of specific following either: - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects For example: - type: External external: metric: name: queue_messages_ready selector: matchLabels: queue: "worker_tasks" target: type: AverageValue averageValue: 30 |
| store_gateway.​autoscaling.​enabled | bool | `false` | |
| store_gateway.​autoscaling.​maxReplicas | int | `30` | |
| store_gateway.​autoscaling.​minReplicas | int | `3` | |
Expand Down
3 changes: 3 additions & 0 deletions templates/distributor/distributor-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ spec:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .customMetrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .behavior }}
behavior:
{{- toYaml . | nindent 4 }}
Expand Down
3 changes: 3 additions & 0 deletions templates/ingester/ingester-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ spec:
target:
type: Utilization
averageUtilization: {{ .targetMemoryUtilizationPercentage }}
{{- with .customMetrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .behavior }}
behavior:
{{- toYaml . | nindent 4 }}
Expand Down
3 changes: 3 additions & 0 deletions templates/nginx/nginx-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ spec:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .customMetrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .behavior }}
behavior:
{{- toYaml . | nindent 4 }}
Expand Down
3 changes: 3 additions & 0 deletions templates/querier/querier-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ spec:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .customMetrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .behavior }}
behavior:
{{- toYaml . | nindent 4 }}
Expand Down
3 changes: 3 additions & 0 deletions templates/ruler/ruler-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ spec:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .customMetrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .behavior }}
behavior:
{{- toYaml . | nindent 4 }}
Expand Down
3 changes: 3 additions & 0 deletions templates/store-gateway/store-gateway-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ spec:
target:
type: Utilization
averageUtilization: {{ .targetMemoryUtilizationPercentage }}
{{- with .customMetrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .behavior }}
behavior:
{{- toYaml . | nindent 4 }}
Expand Down
108 changes: 108 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,24 @@ distributor:
targetMemoryUtilizationPercentage: 0 # 80
# -- Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior
behavior: {}
# -- Optional custom and external metrics for the distributor pods to scale on
# In order to use this option , define a list of of specific following either:
# - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics
# - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects
#
# For example:
#
# - type: External
# external:
# metric:
# name: queue_messages_ready
# selector:
# matchLabels:
# queue: "worker_tasks"
# target:
# type: AverageValue
# averageValue: 30
customMetrics: []
locmai marked this conversation as resolved.
Show resolved Hide resolved

persistentVolume:
subPath:
Expand Down Expand Up @@ -496,6 +514,24 @@ ingester:
- type: Pods
value: 1
periodSeconds: 1800
# -- Optional custom and external metrics for the ingester pods to scale on
# In order to use this option , define a list of of specific following either:
# - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics
# - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects
#
# For example:
#
# - type: External
# external:
# metric:
# name: queue_messages_ready
# selector:
# matchLabels:
# queue: "worker_tasks"
# target:
# type: AverageValue
# averageValue: 30
customMetrics: []

lifecycle:
# -- The /shutdown preStop hook is recommended as part of the ingester
Expand Down Expand Up @@ -624,6 +660,24 @@ ruler:
targetMemoryUtilizationPercentage: 80
# -- Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior
behavior: {}
# -- Optional custom and external metrics for the ruler pods to scale on
# In order to use this option , define a list of of specific following either:
# - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics
# - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects
#
# For example:
#
# - type: External
# external:
# metric:
# name: queue_messages_ready
# selector:
# matchLabels:
# queue: "worker_tasks"
# target:
# type: AverageValue
# averageValue: 30
locmai marked this conversation as resolved.
Show resolved Hide resolved
customMetrics: []

validation:
# -- Checks that the ruler is compatible with horizontal scaling,
Expand Down Expand Up @@ -773,6 +827,24 @@ querier:
targetMemoryUtilizationPercentage: 0 # 80
# -- Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior
behavior: {}
# -- Optional custom and external metrics for the querier pods to scale on
# In order to use this option , define a list of of specific following either:
# - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics
# - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects
#
# For example:
#
# - type: External
# external:
# metric:
# name: queue_messages_ready
# selector:
# matchLabels:
# queue: "worker_tasks"
# target:
# type: AverageValue
# averageValue: 30
customMetrics: []

persistentVolume:
subPath:
Expand Down Expand Up @@ -1293,6 +1365,24 @@ nginx:
targetMemoryUtilizationPercentage: 0 # 80
# -- Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior
behavior: {}
# -- Optional custom and external metrics for the nginx pods to scale on
# In order to use this option , define a list of of specific following either:
# - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics
# - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects
#
# For example:
#
# - type: External
# external:
# metric:
# name: queue_messages_ready
# selector:
# matchLabels:
# queue: "worker_tasks"
# target:
# type: AverageValue
# averageValue: 30
customMetrics: []

store_gateway:
enabled: true
Expand Down Expand Up @@ -1354,6 +1444,24 @@ store_gateway:
targetMemoryUtilizationPercentage: 80
# -- Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior
behavior: {}
# -- Optional custom and external metrics for the store gateway pods to scale on
# In order to use this option , define a list of of specific following either:
# - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics
# - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects
#
# For example:
#
# - type: External
# external:
# metric:
# name: queue_messages_ready
# selector:
# matchLabels:
# queue: "worker_tasks"
# target:
# type: AverageValue
# averageValue: 30
customMetrics: []

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