Skip to content

Commit

Permalink
Add hpa behavior helm chart (#6393)
Browse files Browse the repository at this point in the history
* modify hpa yaml

* add HPA behavior support to helm chart

* new helm version 0.33.0 2024-02-20

* update helm chart version

* modify HPA to handle empty policies field

* add tests

* remove trailing spaces

* make docs
  • Loading branch information
wildum authored Feb 20, 2024
1 parent 7211f08 commit 781dfe8
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 2 deletions.
7 changes: 7 additions & 0 deletions operations/helm/charts/grafana-agent/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ internal API changes are not present.
Unreleased
----------

0.33.0 (2024-02-20)
-------------------

### Features

- Add HPA behavior support for scaling up and down. (@wildum)

### Enhancements

- Allow setting tlsConfig for serviceMonitor (@captncraig)
Expand Down
2 changes: 1 addition & 1 deletion operations/helm/charts/grafana-agent/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: grafana-agent
description: 'Grafana Agent'
type: application
version: 0.32.0
version: 0.33.0
appVersion: 'v0.39.2'

dependencies:
Expand Down
8 changes: 7 additions & 1 deletion operations/helm/charts/grafana-agent/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Grafana Agent Helm chart

![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![Version: 0.32.0](https://img.shields.io/badge/Version-0.32.0-informational?style=flat-square) ![AppVersion: v0.39.2](https://img.shields.io/badge/AppVersion-v0.39.2-informational?style=flat-square)
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![Version: 0.33.0](https://img.shields.io/badge/Version-0.33.0-informational?style=flat-square) ![AppVersion: v0.39.2](https://img.shields.io/badge/AppVersion-v0.39.2-informational?style=flat-square)

Helm chart for deploying [Grafana Agent][] to Kubernetes.

Expand Down Expand Up @@ -74,6 +74,12 @@ use the older mode (called "static mode"), set the `agent.mode` value to
| controller.autoscaling.enabled | bool | `false` | Creates a HorizontalPodAutoscaler for controller type deployment. |
| controller.autoscaling.maxReplicas | int | `5` | The upper limit for the number of replicas to which the autoscaler can scale up. |
| controller.autoscaling.minReplicas | int | `1` | The lower limit for the number of replicas to which the autoscaler can scale down. |
| controller.autoscaling.scaleDown.policies | list | `[]` | List of policies to determine the scale-down behavior. |
| controller.autoscaling.scaleDown.selectPolicy | string | `"Max"` | Determines which of the provided scaling-down policies to apply if multiple are specified. |
| controller.autoscaling.scaleDown.stabilizationWindowSeconds | int | `300` | The duration that the autoscaling mechanism should look back on to make decisions about scaling down. |
| controller.autoscaling.scaleUp.policies | list | `[]` | List of policies to determine the scale-up behavior. |
| controller.autoscaling.scaleUp.selectPolicy | string | `"Max"` | Determines which of the provided scaling-up policies to apply if multiple are specified. |
| controller.autoscaling.scaleUp.stabilizationWindowSeconds | int | `0` | The duration that the autoscaling mechanism should look back on to make decisions about scaling up. |
| controller.autoscaling.targetCPUUtilizationPercentage | int | `0` | Average CPU utilization across all relevant pods, a percentage of the requested value of the resource for the pods. Setting `targetCPUUtilizationPercentage` to 0 will disable CPU scaling. |
| controller.autoscaling.targetMemoryUtilizationPercentage | int | `80` | Average Memory utilization across all relevant pods, a percentage of the requested value of the resource for the pods. Setting `targetMemoryUtilizationPercentage` to 0 will disable Memory scaling. |
| controller.dnsPolicy | string | `"ClusterFirst"` | Configures the DNS policy for the pod. https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ controller:
type: deployment
autoscaling:
enabled: true
scaleDown:
policies:
- type: Pods
value: 4
periodSeconds: 60
selectPolicy: Min
stabilizationWindowSeconds: 100
scaleUp:
policies:
- type: Pods
value: 4
periodSeconds: 60
- type: Percent
value: 100
periodSeconds: 15
stabilizationWindowSeconds: 80
agent:
resources:
requests:
Expand Down
27 changes: 27 additions & 0 deletions operations/helm/charts/grafana-agent/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,33 @@ spec:
{{- with .Values.controller.autoscaling }}
minReplicas: {{ .minReplicas }}
maxReplicas: {{ .maxReplicas }}
behavior:
{{- with .scaleDown }}
scaleDown:
{{- if .policies }}
policies:
{{- range .policies }}
- type: {{ .type }}
value: {{ .value }}
periodSeconds: {{ .periodSeconds }}
{{- end }}
selectPolicy: {{ .selectPolicy }}
{{- end }}
stabilizationWindowSeconds: {{ .stabilizationWindowSeconds }}
{{- end }}
{{- with .scaleUp }}
scaleUp:
{{- if .policies }}
policies:
{{- range .policies }}
- type: {{ .type }}
value: {{ .value }}
periodSeconds: {{ .periodSeconds }}
{{- end }}
selectPolicy: {{ .selectPolicy }}
{{- end }}
stabilizationWindowSeconds: {{ .stabilizationWindowSeconds }}
{{- end }}
metrics:
# Changing the order of the metrics will cause ArgoCD to go into a sync loop
# memory needs to be first.
Expand Down
22 changes: 22 additions & 0 deletions operations/helm/charts/grafana-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,28 @@ controller:
# -- Average Memory utilization across all relevant pods, a percentage of the requested value of the resource for the pods. Setting `targetMemoryUtilizationPercentage` to 0 will disable Memory scaling.
targetMemoryUtilizationPercentage: 80

scaleDown:
# -- List of policies to determine the scale-down behavior.
policies: []
# - type: Pods
# value: 4
# periodSeconds: 60
# -- Determines which of the provided scaling-down policies to apply if multiple are specified.
selectPolicy: Max
# -- The duration that the autoscaling mechanism should look back on to make decisions about scaling down.
stabilizationWindowSeconds: 300

scaleUp:
# -- List of policies to determine the scale-up behavior.
policies: []
# - type: Pods
# value: 4
# periodSeconds: 60
# -- Determines which of the provided scaling-up policies to apply if multiple are specified.
selectPolicy: Max
# -- The duration that the autoscaling mechanism should look back on to make decisions about scaling up.
stabilizationWindowSeconds: 0

# -- Affinity configuration for pods.
affinity: {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ spec:
name: grafana-agent
minReplicas: 1
maxReplicas: 5
behavior:
scaleDown:
policies:
- type: Pods
value: 4
periodSeconds: 60
selectPolicy: Min
stabilizationWindowSeconds: 100
scaleUp:
policies:
- type: Pods
value: 4
periodSeconds: 60
- type: Percent
value: 100
periodSeconds: 15
selectPolicy: Max
stabilizationWindowSeconds: 80
metrics:
# Changing the order of the metrics will cause ArgoCD to go into a sync loop
# memory needs to be first.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ spec:
name: grafana-agent
minReplicas: 1
maxReplicas: 5
behavior:
scaleDown:
stabilizationWindowSeconds: 300
scaleUp:
stabilizationWindowSeconds: 0
metrics:
# Changing the order of the metrics will cause ArgoCD to go into a sync loop
# memory needs to be first.
Expand Down

0 comments on commit 781dfe8

Please sign in to comment.