From 781dfe8981c48f35c9d4add849cf1ec7346f3ad4 Mon Sep 17 00:00:00 2001 From: William Dumont Date: Tue, 20 Feb 2024 17:16:22 +0100 Subject: [PATCH] Add hpa behavior helm chart (#6393) * 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 --- .../helm/charts/grafana-agent/CHANGELOG.md | 7 +++++ .../helm/charts/grafana-agent/Chart.yaml | 2 +- .../helm/charts/grafana-agent/README.md | 8 +++++- .../create-deployment-autoscaling-values.yaml | 16 +++++++++++ .../charts/grafana-agent/templates/hpa.yaml | 27 +++++++++++++++++++ .../helm/charts/grafana-agent/values.yaml | 22 +++++++++++++++ .../grafana-agent/templates/hpa.yaml | 18 +++++++++++++ .../grafana-agent/templates/hpa.yaml | 5 ++++ 8 files changed, 103 insertions(+), 2 deletions(-) diff --git a/operations/helm/charts/grafana-agent/CHANGELOG.md b/operations/helm/charts/grafana-agent/CHANGELOG.md index 4d03e6820796..8a570429343e 100644 --- a/operations/helm/charts/grafana-agent/CHANGELOG.md +++ b/operations/helm/charts/grafana-agent/CHANGELOG.md @@ -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) diff --git a/operations/helm/charts/grafana-agent/Chart.yaml b/operations/helm/charts/grafana-agent/Chart.yaml index bc15d163221a..b36914c3dfe2 100644 --- a/operations/helm/charts/grafana-agent/Chart.yaml +++ b/operations/helm/charts/grafana-agent/Chart.yaml @@ -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: diff --git a/operations/helm/charts/grafana-agent/README.md b/operations/helm/charts/grafana-agent/README.md index a12cf967c1ca..e329a85b7528 100644 --- a/operations/helm/charts/grafana-agent/README.md +++ b/operations/helm/charts/grafana-agent/README.md @@ -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. @@ -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 | diff --git a/operations/helm/charts/grafana-agent/ci/create-deployment-autoscaling-values.yaml b/operations/helm/charts/grafana-agent/ci/create-deployment-autoscaling-values.yaml index 3847b823d9cb..9a0f9ff7126c 100644 --- a/operations/helm/charts/grafana-agent/ci/create-deployment-autoscaling-values.yaml +++ b/operations/helm/charts/grafana-agent/ci/create-deployment-autoscaling-values.yaml @@ -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: diff --git a/operations/helm/charts/grafana-agent/templates/hpa.yaml b/operations/helm/charts/grafana-agent/templates/hpa.yaml index 9b1ea3736821..829fbcc9b29b 100644 --- a/operations/helm/charts/grafana-agent/templates/hpa.yaml +++ b/operations/helm/charts/grafana-agent/templates/hpa.yaml @@ -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. diff --git a/operations/helm/charts/grafana-agent/values.yaml b/operations/helm/charts/grafana-agent/values.yaml index 4796397b993b..d481ae0ab290 100644 --- a/operations/helm/charts/grafana-agent/values.yaml +++ b/operations/helm/charts/grafana-agent/values.yaml @@ -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: {} diff --git a/operations/helm/tests/create-deployment-autoscaling/grafana-agent/templates/hpa.yaml b/operations/helm/tests/create-deployment-autoscaling/grafana-agent/templates/hpa.yaml index 2317e963fb11..b181724fe4d8 100644 --- a/operations/helm/tests/create-deployment-autoscaling/grafana-agent/templates/hpa.yaml +++ b/operations/helm/tests/create-deployment-autoscaling/grafana-agent/templates/hpa.yaml @@ -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. diff --git a/operations/helm/tests/create-statefulset-autoscaling/grafana-agent/templates/hpa.yaml b/operations/helm/tests/create-statefulset-autoscaling/grafana-agent/templates/hpa.yaml index e2277ceb7fda..a6674c612a43 100644 --- a/operations/helm/tests/create-statefulset-autoscaling/grafana-agent/templates/hpa.yaml +++ b/operations/helm/tests/create-statefulset-autoscaling/grafana-agent/templates/hpa.yaml @@ -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.