From a3ed774b314e3cb12a23d1816b9e3d162fa816ab Mon Sep 17 00:00:00 2001 From: Ash Ramasawmy Date: Fri, 10 May 2024 16:01:32 -0400 Subject: [PATCH] [bitnami/keycloak] Add HPA Behavior when scaling up and down Add ability to control the hpa behaviour when scaling up and down so that we can give Keycloak pods time to rebalance cache entries when scaling up/down Signed-off-by: Ash Ramasawmy --- bitnami/keycloak/Chart.yaml | 2 +- bitnami/keycloak/README.md | 26 +++++++++++++-------- bitnami/keycloak/templates/hpa.yaml | 17 ++++++++++++++ bitnami/keycloak/values.yaml | 36 +++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 11 deletions(-) diff --git a/bitnami/keycloak/Chart.yaml b/bitnami/keycloak/Chart.yaml index 9e557c4d3472b9..11dd973a12ab14 100644 --- a/bitnami/keycloak/Chart.yaml +++ b/bitnami/keycloak/Chart.yaml @@ -33,4 +33,4 @@ maintainers: name: keycloak sources: - https://github.com/bitnami/charts/tree/main/bitnami/keycloak -version: 21.1.3 +version: 21.2.0 diff --git a/bitnami/keycloak/README.md b/bitnami/keycloak/README.md index 6b5e93fd677e5f..84a7bbc362d1f4 100644 --- a/bitnami/keycloak/README.md +++ b/bitnami/keycloak/README.md @@ -511,16 +511,22 @@ As an alternative, you can use of the preset configurations for pod affinity, po ### Other parameters -| Name | Description | Value | -| -------------------------- | -------------------------------------------------------------- | ------- | -| `pdb.create` | Enable/disable a Pod Disruption Budget creation | `false` | -| `pdb.minAvailable` | Minimum number/percentage of pods that should remain scheduled | `1` | -| `pdb.maxUnavailable` | Maximum number/percentage of pods that may be made unavailable | `""` | -| `autoscaling.enabled` | Enable autoscaling for Keycloak | `false` | -| `autoscaling.minReplicas` | Minimum number of Keycloak replicas | `1` | -| `autoscaling.maxReplicas` | Maximum number of Keycloak replicas | `11` | -| `autoscaling.targetCPU` | Target CPU utilization percentage | `""` | -| `autoscaling.targetMemory` | Target Memory utilization percentage | `""` | +| Name | Description | Value | +| ----------------------------------------------------------- | -------------------------------------------------------------------------------------------- | ------- | +| `pdb.create` | Enable/disable a Pod Disruption Budget creation | `false` | +| `pdb.minAvailable` | Minimum number/percentage of pods that should remain scheduled | `1` | +| `pdb.maxUnavailable` | Maximum number/percentage of pods that may be made unavailable | `""` | +| `autoscaling.enabled` | Enable autoscaling for Keycloak | `false` | +| `autoscaling.minReplicas` | Minimum number of Keycloak replicas | `1` | +| `autoscaling.maxReplicas` | Maximum number of Keycloak replicas | `11` | +| `autoscaling.targetCPU` | Target CPU utilization percentage | `""` | +| `autoscaling.targetMemory` | Target Memory utilization percentage | `""` | +| `autoscaling.behavior.scaleUp.stabilizationWindowSeconds` | The number of seconds for which past recommendations should be considered while scaling up | `120` | +| `autoscaling.behavior.scaleUp.selectPolicy` | The priority of policies that the autoscaler will apply when scaling up | `Max` | +| `autoscaling.behavior.scaleUp.policies` | HPA scaling policies when scaling up | `[]` | +| `autoscaling.behavior.scaleDown.stabilizationWindowSeconds` | The number of seconds for which past recommendations should be considered while scaling down | `300` | +| `autoscaling.behavior.scaleDown.selectPolicy` | The priority of policies that the autoscaler will apply when scaling down | `Max` | +| `autoscaling.behavior.scaleDown.policies` | HPA scaling policies when scaling down | `[]` | ### Metrics parameters diff --git a/bitnami/keycloak/templates/hpa.yaml b/bitnami/keycloak/templates/hpa.yaml index 4219298b502e1c..ff673c2fcf3f27 100644 --- a/bitnami/keycloak/templates/hpa.yaml +++ b/bitnami/keycloak/templates/hpa.yaml @@ -46,4 +46,21 @@ spec: averageUtilization: {{ .Values.autoscaling.targetMemory }} {{- end }} {{- end }} + {{- if or .Values.autoscaling.behavior.scaleDown.policies .Values.autoscaling.behavior.scaleUp.policies }} + behavior: + {{- if .Values.autoscaling.behavior.scaleDown.policies }} + scaleDown: + stabilizationWindowSeconds: {{ .Values.autoscaling.behavior.scaleDown.stabilizationWindowSeconds }} + selectPolicy: {{ .Values.autoscaling.behavior.scaleDown.selectPolicy }} + policies: + {{- toYaml .Values.autoscaling.behavior.scaleDown.policies | nindent 8 }} + {{- end }} + {{- if .Values.autoscaling.behavior.scaleUp.policies }} + scaleUp: + stabilizationWindowSeconds: {{ .Values.autoscaling.behavior.scaleUp.stabilizationWindowSeconds }} + selectPolicy: {{ .Values.autoscaling.behavior.scaleUp.selectPolicy }} + policies: + {{- toYaml .Values.autoscaling.behavior.scaleUp.policies | nindent 8 }} + {{- end }} + {{- end }} {{- end }} diff --git a/bitnami/keycloak/values.yaml b/bitnami/keycloak/values.yaml index 6c7955ec10aaa0..52304e59de4027 100644 --- a/bitnami/keycloak/values.yaml +++ b/bitnami/keycloak/values.yaml @@ -912,6 +912,7 @@ pdb: ## maxUnavailable: "" ## Keycloak Autoscaling configuration +## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/ ## @param autoscaling.enabled Enable autoscaling for Keycloak ## @param autoscaling.minReplicas Minimum number of Keycloak replicas ## @param autoscaling.maxReplicas Maximum number of Keycloak replicas @@ -924,6 +925,41 @@ autoscaling: maxReplicas: 11 targetCPU: "" targetMemory: "" + ## HPA Scaling Behavior + ## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#configurable-scaling-behavior + ## + behavior: + ## HPA behavior when scaling up + ## @param autoscaling.behavior.scaleUp.stabilizationWindowSeconds The number of seconds for which past recommendations should be considered while scaling up + ## @param autoscaling.behavior.scaleUp.selectPolicy The priority of policies that the autoscaler will apply when scaling up + ## @param autoscaling.behavior.scaleUp.policies [array] HPA scaling policies when scaling up + ## e.g: + ## Policy to scale 20% of the pod in 60s + ## - type: Percent + ## value: 20 + ## periodSeconds: 60 + ## + scaleUp: + stabilizationWindowSeconds: 120 + selectPolicy: Max + policies: [] + ## HPA behavior when scaling down + ## @param autoscaling.behavior.scaleDown.stabilizationWindowSeconds The number of seconds for which past recommendations should be considered while scaling down + ## @param autoscaling.behavior.scaleDown.selectPolicy The priority of policies that the autoscaler will apply when scaling down + ## @param autoscaling.behavior.scaleDown.policies [array] HPA scaling policies when scaling down + ## e.g: + ## Policy to scale one pod in 300s + ## - type: Pods + ## value: 1 + ## periodSeconds: 300 + ## + scaleDown: + stabilizationWindowSeconds: 300 + selectPolicy: Max + policies: + - type: Pods + value: 1 + periodSeconds: 300 ## @section Metrics parameters ##