Skip to content

Commit

Permalink
[bitnami/keycloak] Add HPA Behavior when scaling up and down
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Ash Ramasawmy authored and Ash Ramasawmy committed May 10, 2024
1 parent 06373e1 commit a3ed774
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bitnami/keycloak/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 16 additions & 10 deletions bitnami/keycloak/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions bitnami/keycloak/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
36 changes: 36 additions & 0 deletions bitnami/keycloak/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
##

Expand Down

0 comments on commit a3ed774

Please sign in to comment.