From 44329b13aefb91ffc04aba8fffaf2b674baa341c Mon Sep 17 00:00:00 2001 From: ranchodeluxe Date: Sat, 30 Sep 2023 06:26:06 -0700 Subject: [PATCH 1/4] hpa draft before locust --- helm-chart/.gitignore | 1 + helm-chart/eoapi/CHANGELOG.md | 20 ++++++++------ helm-chart/eoapi/Chart.yaml | 4 +-- helm-chart/eoapi/templates/services/hpa.yaml | 28 ++++++++++++++++++++ helm-chart/eoapi/test-unittest-values.yaml | 12 +++++++++ helm-chart/eoapi/values.yaml | 18 +++++++++++++ 6 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 helm-chart/.gitignore create mode 100644 helm-chart/eoapi/templates/services/hpa.yaml diff --git a/helm-chart/.gitignore b/helm-chart/.gitignore new file mode 100644 index 00000000..c6f42624 --- /dev/null +++ b/helm-chart/.gitignore @@ -0,0 +1 @@ +.deploy.sh diff --git a/helm-chart/eoapi/CHANGELOG.md b/helm-chart/eoapi/CHANGELOG.md index e7153ab3..35d82f58 100644 --- a/helm-chart/eoapi/CHANGELOG.md +++ b/helm-chart/eoapi/CHANGELOG.md @@ -1,33 +1,37 @@ -version numbers below correspond to helm chart `appVersion`: see ./helm-chart/eoapi/Chart.yaml +##### version numbers below correspond to helm chart `appVersion`: see ./helm-chart/eoapi/Chart.yaml --- -# 0.1.6 (2023-09-27) +### 0.1.7 (2023-10-01) + +* adds `autoscaling` options to each service for HPA + +### 0.1.6 (2023-09-27) * adds `docServer.enable` flag to the `values.yaml` and service templates -# 0.1.5 (2023-09-16) +### 0.1.5 (2023-09-16) * adds a cpu and memory limits/requests to the `db` config block -# 0.1.4 (2023-09-09) +### 0.1.4 (2023-09-09) * adds a `testing: false` value to `values.yaml` * plumb through `{{ $.Release.Name }}` into all the right templates so our CI can `helm install` into a single namespace and run tests in parallel -# 0.1.3 (2023-09-05) +### 0.1.3 (2023-09-05) * test on GKE and add documentation where needed for [GKE template changes](https://github.com/developmentseed/eoapi-k8s/issues/29) * CI/CD should run on GKE so we debug less test failures on minikube for [move CI/CD away from minikube](https://github.com/developmentseed/eoapi-k8s/issues/36) * documentation about default configuration and additional options for [documentation](https://github.com/developmentseed/eoapi-k8s/issues/19) -# 0.1.2 (2023-08-31) +### 0.1.2 (2023-08-31) * move `command` blocks out to `values.yml` for [generalizing ticket](https://github.com/developmentseed/eoapi-k8s/issues/31) * add `livenessProbe` for all deployments for [livenessProbe bug](https://github.com/developmentseed/eoapi-k8s/issues/26) -# 0.1.1 (2023-07-21) +### 0.1.1 (2023-07-21) * For the shared-nginx ingress option [add root path with docs](https://github.com/developmentseed/eoapi-k8s/issues/18) pointing to path rewrites -# 0.1.0 (2023-07-01) +### 0.1.0 (2023-07-01) * Adds basic AWS EKS services with ALB and NLB options diff --git a/helm-chart/eoapi/Chart.yaml b/helm-chart/eoapi/Chart.yaml index 8a562232..c7aa5c13 100644 --- a/helm-chart/eoapi/Chart.yaml +++ b/helm-chart/eoapi/Chart.yaml @@ -17,10 +17,10 @@ kubeVersion: ">=1.23.0-0" # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: "0.1.8" +version: "0.1.9" # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "0.1.6" +appVersion: "0.1.7" diff --git a/helm-chart/eoapi/templates/services/hpa.yaml b/helm-chart/eoapi/templates/services/hpa.yaml new file mode 100644 index 00000000..be97d604 --- /dev/null +++ b/helm-chart/eoapi/templates/services/hpa.yaml @@ -0,0 +1,28 @@ +{{- range $serviceName, $v := .Values -}} +{{- if (or (eq $serviceName "raster") (eq $serviceName "stac") (eq $serviceName "vector")) }} +{{- if index $v "autoscaling" "enabled" }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: hpa-{{ $serviceName }}-{{ $.Release.Name }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ $serviceName }}-{{ $.Release.Name }} + minReplicas: {{ index $v "autoscaling" "minReplicas" }} + maxReplicas: {{ index $v "autoscaling" "maxReplicas" }} + metrics: + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ index $v "autoscaling" "utilizationTarget" "memory" }} +--- +{{/* END: if index $v "autoscaling" "enabled" */}} +{{- end }} +{{/* END: if (or (eq $serviceName "raster") (eq $serviceName "stac") (eq $serviceName "vector")) */}} +{{- end }} +{{/* END: range $serviceName, $v := .Values*/}} +{{- end }} diff --git a/helm-chart/eoapi/test-unittest-values.yaml b/helm-chart/eoapi/test-unittest-values.yaml index cab1145a..15994f9f 100644 --- a/helm-chart/eoapi/test-unittest-values.yaml +++ b/helm-chart/eoapi/test-unittest-values.yaml @@ -16,6 +16,10 @@ db: memory: "1024Mi" raster: enabled: true + autoscaling: + enabled: true + utilizationTarget: + memory: 90 settings: resources: limits: @@ -26,6 +30,10 @@ raster: memory: "1024Mi" stac: enabled: true + autoscaling: + enabled: true + utilizationTarget: + memory: 90 settings: resources: limits: @@ -36,6 +44,10 @@ stac: memory: "1024Mi" vector: enabled: true + autoscaling: + enabled: true + utilizationTarget: + memory: 90 settings: resources: limits: diff --git a/helm-chart/eoapi/values.yaml b/helm-chart/eoapi/values.yaml index 2aa23f59..9a19b7c3 100644 --- a/helm-chart/eoapi/values.yaml +++ b/helm-chart/eoapi/values.yaml @@ -89,6 +89,12 @@ ingress: raster: enabled: true + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 10 + utilizationTarget: + memory: 65 image: name: ghcr.io/stac-utils/titiler-pgstac tag: uvicorn-0.4.1 @@ -131,6 +137,12 @@ raster: stac: enabled: true + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 10 + utilizationTarget: + memory: 65 image: name: ghcr.io/stac-utils/stac-fastapi-pgstac tag: 2.4.9 @@ -160,6 +172,12 @@ stac: vector: enabled: true + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 10 + utilizationTarget: + memory: 65 image: name: ghcr.io/developmentseed/tipg tag: uvicorn-0.2.0 From 84f943e082b21cacde811561a20d92b13f3e08d1 Mon Sep 17 00:00:00 2001 From: ranchodeluxe Date: Mon, 2 Oct 2023 10:10:11 -0700 Subject: [PATCH 2/4] adjust unit test limits so we don't autoscale on testing --- helm-chart/eoapi/templates/services/hpa.yaml | 9 +++++++-- helm-chart/eoapi/test-unittest-values.yaml | 18 +++++++++--------- helm-chart/eoapi/values.yaml | 8 ++++---- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/helm-chart/eoapi/templates/services/hpa.yaml b/helm-chart/eoapi/templates/services/hpa.yaml index be97d604..f1ad5fca 100644 --- a/helm-chart/eoapi/templates/services/hpa.yaml +++ b/helm-chart/eoapi/templates/services/hpa.yaml @@ -12,13 +12,18 @@ spec: name: {{ $serviceName }}-{{ $.Release.Name }} minReplicas: {{ index $v "autoscaling" "minReplicas" }} maxReplicas: {{ index $v "autoscaling" "maxReplicas" }} + behavior: + scaleDown: + stabilizationWindowSeconds: 180 + scaleUp: + stabilizationWindowSeconds: 30 metrics: - type: Resource resource: - name: memory + name: cpu target: type: Utilization - averageUtilization: {{ index $v "autoscaling" "utilizationTarget" "memory" }} + averageUtilization: {{ index $v "autoscaling" "utilizationTarget" "cpu" }} --- {{/* END: if index $v "autoscaling" "enabled" */}} {{- end }} diff --git a/helm-chart/eoapi/test-unittest-values.yaml b/helm-chart/eoapi/test-unittest-values.yaml index 15994f9f..baaf9903 100644 --- a/helm-chart/eoapi/test-unittest-values.yaml +++ b/helm-chart/eoapi/test-unittest-values.yaml @@ -19,11 +19,11 @@ raster: autoscaling: enabled: true utilizationTarget: - memory: 90 + cpu: 65 settings: resources: limits: - cpu: "512m" + cpu: "768m" memory: "4096Mi" requests: cpu: "256m" @@ -33,12 +33,12 @@ stac: autoscaling: enabled: true utilizationTarget: - memory: 90 + cpu: 65 settings: resources: limits: - cpu: "512m" - memory: "1024Mi" + cpu: "1280m" + memory: "1536Mi" requests: cpu: "512m" memory: "1024Mi" @@ -47,12 +47,12 @@ vector: autoscaling: enabled: true utilizationTarget: - memory: 90 + cpu: 65 settings: resources: limits: - cpu: "256m" - memory: "768Mi" + cpu: "768m" + memory: "1536Mi" requests: cpu: "256m" - memory: "768Mi" + memory: "1024Mi" diff --git a/helm-chart/eoapi/values.yaml b/helm-chart/eoapi/values.yaml index 9a19b7c3..80683eca 100644 --- a/helm-chart/eoapi/values.yaml +++ b/helm-chart/eoapi/values.yaml @@ -94,7 +94,7 @@ raster: minReplicas: 1 maxReplicas: 10 utilizationTarget: - memory: 65 + cpu: 50 image: name: ghcr.io/stac-utils/titiler-pgstac tag: uvicorn-0.4.1 @@ -142,7 +142,7 @@ stac: minReplicas: 1 maxReplicas: 10 utilizationTarget: - memory: 65 + cpu: 50 image: name: ghcr.io/stac-utils/stac-fastapi-pgstac tag: 2.4.9 @@ -173,11 +173,11 @@ stac: vector: enabled: true autoscaling: - enabled: false + enabled: fals minReplicas: 1 maxReplicas: 10 utilizationTarget: - memory: 65 + cpu: 50 image: name: ghcr.io/developmentseed/tipg tag: uvicorn-0.2.0 From 0f6010d171e1f4300e6d3b25dbff0a4db6fbe23d Mon Sep 17 00:00:00 2001 From: ranchodeluxe Date: Mon, 2 Oct 2023 10:11:45 -0700 Subject: [PATCH 3/4] whoops --- helm-chart/eoapi/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-chart/eoapi/values.yaml b/helm-chart/eoapi/values.yaml index 80683eca..e2599f2c 100644 --- a/helm-chart/eoapi/values.yaml +++ b/helm-chart/eoapi/values.yaml @@ -173,7 +173,7 @@ stac: vector: enabled: true autoscaling: - enabled: fals + enabled: false minReplicas: 1 maxReplicas: 10 utilizationTarget: From 9b9783324238eee8c2a71189ecad4afa2c440fa6 Mon Sep 17 00:00:00 2001 From: ranchodeluxe Date: Mon, 2 Oct 2023 10:16:16 -0700 Subject: [PATCH 4/4] remove autoscaling from unit tests --- helm-chart/eoapi/templates/services/hpa.yaml | 2 +- helm-chart/eoapi/test-unittest-values.yaml | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/helm-chart/eoapi/templates/services/hpa.yaml b/helm-chart/eoapi/templates/services/hpa.yaml index f1ad5fca..56d92792 100644 --- a/helm-chart/eoapi/templates/services/hpa.yaml +++ b/helm-chart/eoapi/templates/services/hpa.yaml @@ -16,7 +16,7 @@ spec: scaleDown: stabilizationWindowSeconds: 180 scaleUp: - stabilizationWindowSeconds: 30 + stabilizationWindowSeconds: 60 metrics: - type: Resource resource: diff --git a/helm-chart/eoapi/test-unittest-values.yaml b/helm-chart/eoapi/test-unittest-values.yaml index baaf9903..75e202b8 100644 --- a/helm-chart/eoapi/test-unittest-values.yaml +++ b/helm-chart/eoapi/test-unittest-values.yaml @@ -16,10 +16,6 @@ db: memory: "1024Mi" raster: enabled: true - autoscaling: - enabled: true - utilizationTarget: - cpu: 65 settings: resources: limits: @@ -30,10 +26,6 @@ raster: memory: "1024Mi" stac: enabled: true - autoscaling: - enabled: true - utilizationTarget: - cpu: 65 settings: resources: limits: @@ -44,10 +36,6 @@ stac: memory: "1024Mi" vector: enabled: true - autoscaling: - enabled: true - utilizationTarget: - cpu: 65 settings: resources: limits: