Skip to content

Commit

Permalink
Add option for configuring HPA with custom/external metrics (#467)
Browse files Browse the repository at this point in the history
* feat: option for custom/external metrics HPA

Signed-off-by: Loc Mai <locmai0201@gmail.com>

* docs: update CHANGELOG.md

Signed-off-by: Loc Mai <locmai0201@gmail.com>

* fix: lint

Signed-off-by: Loc Mai <locmai0201@gmail.com>

* docs: re-gen README

Signed-off-by: Loc Mai <locmai0201@gmail.com>

* docs: update CHANGELOG

Signed-off-by: Loc Mai <locmai0201@gmail.com>

* docs: update README format

Signed-off-by: Loc Mai <locmai0201@gmail.com>

* fix: lint

Signed-off-by: Loc Mai <locmai0201@gmail.com>

* chore: remove example

Signed-off-by: Loc Mai <locmai0201@gmail.com>

* docs: shorten description

Signed-off-by: Loc Mai <locmai0201@gmail.com>

---------

Signed-off-by: Loc Mai <locmai0201@gmail.com>
  • Loading branch information
locmai committed Jun 27, 2023
1 parent 8d883fd commit d335fe6
Show file tree
Hide file tree
Showing 9 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 @@ -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
* [DEPENDENCY] Update quay.io/cortexproject/cortex Docker tag to v1.15.2 #459
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ Kubernetes: `^1.19.0-0`
| distributor.&ZeroWidthSpace;annotations | object | `{}` | |
| distributor.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;behavior | object | `{}` | Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior |
| distributor.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;enabled | bool | `false` | Creates a HorizontalPodAutoscaler for the distributor pods. |
| distributor.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;extraMetrics | 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 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics and https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects |
| distributor.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;maxReplicas | int | `30` | |
| distributor.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;minReplicas | int | `2` | |
| distributor.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;targetCPUUtilizationPercentage | int | `80` | |
Expand Down Expand Up @@ -327,6 +328,7 @@ Kubernetes: `^1.19.0-0`
| ingester.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;behavior.&ZeroWidthSpace;scaleDown.&ZeroWidthSpace;stabilizationWindowSeconds | int | `3600` | uses metrics from the past 1h to make scaleDown decisions |
| ingester.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;behavior.&ZeroWidthSpace;scaleUp.&ZeroWidthSpace;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.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;enabled | bool | `false` | |
| ingester.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;extraMetrics | 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 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics and https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects |
| ingester.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;maxReplicas | int | `30` | |
| ingester.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;minReplicas | int | `3` | |
| ingester.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;targetMemoryUtilizationPercentage | int | `80` | |
Expand Down Expand Up @@ -425,6 +427,7 @@ Kubernetes: `^1.19.0-0`
| nginx.&ZeroWidthSpace;annotations | object | `{}` | |
| nginx.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;behavior | object | `{}` | Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior |
| nginx.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;enabled | bool | `false` | Creates a HorizontalPodAutoscaler for the nginx pods. |
| nginx.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;extraMetrics | 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 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics and https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects |
| nginx.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;maxReplicas | int | `30` | |
| nginx.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;minReplicas | int | `2` | |
| nginx.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;targetCPUUtilizationPercentage | int | `80` | |
Expand Down Expand Up @@ -572,6 +575,7 @@ Kubernetes: `^1.19.0-0`
| querier.&ZeroWidthSpace;annotations | object | `{}` | |
| querier.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;behavior | object | `{}` | Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior |
| querier.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;enabled | bool | `false` | Creates a HorizontalPodAutoscaler for the querier pods. |
| querier.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;extraMetrics | 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 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics and https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects |
| querier.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;maxReplicas | int | `30` | |
| querier.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;minReplicas | int | `2` | |
| querier.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;targetCPUUtilizationPercentage | int | `80` | |
Expand Down Expand Up @@ -714,6 +718,7 @@ Kubernetes: `^1.19.0-0`
| ruler.&ZeroWidthSpace;annotations | object | `{}` | |
| ruler.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;behavior | object | `{}` | Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior |
| ruler.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;enabled | bool | `false` | Creates a HorizontalPodAutoscaler for the ruler. |
| ruler.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;extraMetrics | 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 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics and https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects |
| ruler.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;maxReplicas | int | `30` | |
| ruler.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;minReplicas | int | `2` | |
| ruler.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;targetCPUUtilizationPercentage | int | `80` | |
Expand Down Expand Up @@ -792,6 +797,7 @@ Kubernetes: `^1.19.0-0`
| 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;extraMetrics | 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 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics and https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects |
| store_gateway.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;maxReplicas | int | `30` | |
| store_gateway.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;minReplicas | int | `3` | |
| store_gateway.&ZeroWidthSpace;autoscaling.&ZeroWidthSpace;targetMemoryUtilizationPercentage | int | `80` | |
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 .extraMetrics }}
{{- 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 .extraMetrics }}
{{- 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 .extraMetrics }}
{{- 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 .extraMetrics }}
{{- 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 .extraMetrics }}
{{- 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 .extraMetrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .behavior }}
behavior:
{{- toYaml . | nindent 4 }}
Expand Down
18 changes: 18 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ 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 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics and https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects
extraMetrics: []

persistentVolume:
subPath:
Expand Down Expand Up @@ -496,6 +499,9 @@ 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 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics and https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects
extraMetrics: []

lifecycle:
# -- The /shutdown preStop hook is recommended as part of the ingester
Expand Down Expand Up @@ -624,6 +630,9 @@ 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 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics and https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects
extraMetrics: []

validation:
# -- Checks that the ruler is compatible with horizontal scaling,
Expand Down Expand Up @@ -773,6 +782,9 @@ 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 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics and https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects
extraMetrics: []

persistentVolume:
subPath:
Expand Down Expand Up @@ -1293,6 +1305,9 @@ 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 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics and https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects
extraMetrics: []

store_gateway:
enabled: true
Expand Down Expand Up @@ -1354,6 +1369,9 @@ 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 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics and https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects
extraMetrics: []

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

0 comments on commit d335fe6

Please sign in to comment.