Skip to content

Commit 1d499d0

Browse files
Simple-Analysiscalvin
and
calvin
authored
Add support for memory utilization in HorizontalPodAutoscaler (opensearch-project#530)
* Signed-off-by: Simple-Analysis 4850112+Simple-Analysis@users.noreply.github.com Add support for memory utilization in HorizontalPodAutoscaler Signed-off-by: calvin <calvin.harrison@home.lab> * Update charts/opensearch-dashboards/CHANGELOG.md Signed-off-by: Simple-Analysis <74850112+Simple-Analysis@users.noreply.github.com> * Update README.md - Added autoscaling notes Signed-off-by: Simple-Analysis <74850112+Simple-Analysis@users.noreply.github.com> * Update charts/opensearch-dashboards/Chart.yaml Signed-off-by: Simple-Analysis <74850112+Simple-Analysis@users.noreply.github.com> --------- Signed-off-by: calvin <calvin.harrison@home.lab> Signed-off-by: Simple-Analysis <74850112+Simple-Analysis@users.noreply.github.com> Co-authored-by: calvin <calvin.harrison@home.lab>
1 parent 0dfa606 commit 1d499d0

File tree

6 files changed

+66
-7
lines changed

6 files changed

+66
-7
lines changed

charts/opensearch-dashboards/CHANGELOG.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
### Fixed
1414
### Security
1515
---
16+
## [2.16.1]
17+
### Added
18+
- Support for newer HorizontalPodAutoscaler api in Dashboards
19+
- Ability to configure HorizontalPodAutoscaler to use memory as a metric source type
20+
### Changed
21+
### Deprecated
22+
### Removed
23+
### Fixed
24+
### Security
25+
---
1626
## [2.16.0]
1727
### Added
18-
- Updated OpenSearch Dashboards appVersion to 2.12.0
28+
- Updated OpenSearch Dashboards appVersion to 2.12.0
1929
### Changed
2030
### Deprecated
2131
### Removed

charts/opensearch-dashboards/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 2.16.0
18+
version: 2.16.1
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

charts/opensearch-dashboards/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@
7878
| `topologySpreadConstraints` | Configuration for pod [topologySpreadConstraints][] | `[]` |
7979
| `updateStrategy` | The [updateStrategy][] for the StatefulSet. By default Kubernetes will wait for the cluster to be green after upgrading each pod. Setting this to `OnDelete` will allow you to manually delete each pod during upgrades | `RollingUpdate` |
8080
| `extraObjects` | Array of extra K8s manifests to deploy | list `[]` |
81-
| `autoscaling` | Prerequisite: Install/Configure metrics server, to install use `kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml`, See https://github.com/kubernetes-sigs/metrics-server. Configurable pod autoscaling stratergy to scale based on `targetCPUUtilizationPercentage`, configure `minReplicas` and `maxReplicas` for desired scaling | false |
81+
| `autoscaling.enabled` | Prerequisite: Install/Configure metrics server, to install use `kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml`, See https://github.com/kubernetes-sigs/metrics-server. | false |
82+
| `autoscaling.minReplicas` | The lower limit for the number of replicas to which the autoscaler can scale down. | 1 |
83+
| `autoscaling.maxReplicas` | The upper limit for the number of replicas to which the autoscaler can scale up. | 10 |
84+
| `autoscaling.targetCPU` | The target value of the average CPU across all OpenSearch Dashboards pods. | 80 |
85+
| `autoscaling.targetMemory` | The target value of the average memory across all OpenSearch Dashboards pods. Value should be tuned based on the requested memory value for OpenSearch Dashboards pods. Scaling based on memory utilization may be necessary for large datasets or complex dashboards. | 80 |
8286
| `livenessProbe` | Configuration fields for the liveness [probe][] | see [exampleLiveness][] in `values.yaml`|
8387
| `readinessProbe` | Configuration fields for the readiness [probe][] | see [exampleReadiness][] in `values.yaml`|
8488
| `startupProbe` | Configuration fields for the startup [probe][] | see [exampleStartup][] in `values.yaml` |

charts/opensearch-dashboards/templates/_helpers.tpl

+15
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,21 @@ Return the appropriate apiVersion for ingress.
7474
{{- end -}}
7575
{{- end -}}
7676

77+
{{/*
78+
Return the appropriate apiVersion for Horizontal Pod Autoscaler.
79+
*/}}
80+
{{- define "opensearch-dashboards.hpa.apiVersion" -}}
81+
{{- if $.Capabilities.APIVersions.Has "autoscaling/v2/HorizontalPodAutoscaler" }}
82+
{{- print "autoscaling/v2" }}
83+
{{- else if $.Capabilities.APIVersions.Has "autoscaling/v2beta2/HorizontalPodAutoscaler" }}
84+
{{- print "autoscaling/v2beta2" }}
85+
{{- else if $.Capabilities.APIVersions.Has "autoscaling/v2beta1/HorizontalPodAutoscaler" }}
86+
{{- print "autoscaling/v2beta1" }}
87+
{{- else }}
88+
{{- print "autoscaling/v1" }}
89+
{{- end }}
90+
{{- end }}
91+
7792
{{/*
7893
Return if ingress is stable.
7994
*/}}

charts/opensearch-dashboards/templates/autoscaler.yaml

+31-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- if .Values.autoscaling.enabled -}}
2-
apiVersion: autoscaling/v1
2+
apiVersion: {{ include "opensearch-dashboards.hpa.apiVersion" . }}
33
kind: HorizontalPodAutoscaler
44
metadata:
55
name: {{ template "opensearch-dashboards.fullname" . }}-hpa
@@ -11,5 +11,33 @@ spec:
1111
apiVersion: apps/v1
1212
kind: Deployment
1313
name: {{ template "opensearch-dashboards.fullname" . }}
14-
targetCPUUtilizationPercentage: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
15-
{{- end }}
14+
{{- if eq (include "opensearch-dashboards.hpa.apiVersion" .) "autoscaling/v1" }}
15+
targetCPUUtilizationPercentage: {{ .Values.autoscaling.targetCPUUtilizationPercentage | default .Values.autoscaling.targetCPU }}
16+
{{- else }}
17+
metrics:
18+
{{- if .Values.autoscaling.targetMemory }}
19+
- type: Resource
20+
resource:
21+
name: memory
22+
{{- if eq (include "opensearch-dashboards.hpa.apiVersion" .) "autoscaling/v2beta1" }}
23+
targetAverageUtilization: {{ .Values.autoscaling.targetMemory }}
24+
{{- else }}
25+
target:
26+
type: Utilization
27+
averageUtilization: {{ .Values.autoscaling.targetMemory }}
28+
{{- end }}
29+
{{- end }}
30+
{{- if or .Values.autoscaling.targetCPU .Values.autoscaling.targetCPUUtilizationPercentage }}
31+
- type: Resource
32+
resource:
33+
name: cpu
34+
{{- if eq (include "opensearch-dashboards.hpa.apiVersion" .) "autoscaling/v2beta1" }}
35+
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage | default .Values.autoscaling.targetCPU }}
36+
{{- else }}
37+
target:
38+
type: Utilization
39+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage | default .Values.autoscaling.targetCPU }}
40+
{{- end }}
41+
{{- end }}
42+
{{- end }}
43+
{{- end }}

charts/opensearch-dashboards/values.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ autoscaling:
199199
enabled: false
200200
minReplicas: 1
201201
maxReplicas: 10
202-
targetCPUUtilizationPercentage: 80
202+
# The legacy `targetCPUUtilizationPercentage` key has been deprecated in favor of `targetCPU`
203+
targetCPU: "80"
204+
targetMemory: "80"
203205

204206
updateStrategy:
205207
type: "Recreate"

0 commit comments

Comments
 (0)