From f7a8c236096844be3d66854de5a2dff533a8c33f Mon Sep 17 00:00:00 2001 From: Felix Delattre Date: Tue, 21 Jul 2026 20:45:37 +0200 Subject: [PATCH] fix: improved autoscaling based on database config. --- .../montandon-eoapi/application.yaml | 34 +++++++++++++++++-- .../montandon-eoapi/application.yaml | 34 +++++++++++++++++-- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/applications/argocd/production/applications/montandon-eoapi/application.yaml b/applications/argocd/production/applications/montandon-eoapi/application.yaml index 806f199..16cef3e 100644 --- a/applications/argocd/production/applications/montandon-eoapi/application.yaml +++ b/applications/argocd/production/applications/montandon-eoapi/application.yaml @@ -54,17 +54,36 @@ spec: image: tag: 6.1.2 overrideRootPath: "" + # External Azure PG + HPA: keep concurrency/pools capped. + # Ceiling: maxReplicas × WEB_CONCURRENCY × pools(2 w/ transactions) × DB_MAX_CONN_SIZE + # See https://github.com/developmentseed/eoapi-k8s/blob/main/docs/autoscaling.md#external--shared-postgresql + autoscaling: + enabled: true + minReplicas: 1 + maxReplicas: 3 + type: "cpu" + targets: + cpu: 70 + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + scaleUp: + stabilizationWindowSeconds: 60 settings: labels: azure.workload.identity/use: "true" resources: requests: memory: "2048Mi" - cpu: "10m" + # HPA CPU% is relative to requests; keep this meaningful (not near-zero). + cpu: "500m" limits: memory: "4096Mi" cpu: "1000m" envVars: + WEB_CONCURRENCY: "4" + DB_MIN_CONN_SIZE: "1" + DB_MAX_CONN_SIZE: "1" ENABLE_TRANSACTIONS_EXTENSIONS: "TRUE" FORWARDED_ALLOW_IPS: "*" PROXY_HEADERS: True @@ -144,7 +163,18 @@ spec: tls: enabled: true secretName: "montandon-eoapi-helm-secret-cert" - replicaCount: 1 + autoscaling: + enabled: true + minReplicas: 1 + maxReplicas: 3 + targetCPUUtilizationPercentage: 75 + resources: + limits: + cpu: 500m + memory: "2048Mi" + requests: + cpu: 200m + memory: "1024Mi" extraVolumes: - name: filters configMap: diff --git a/applications/argocd/staging/applications/montandon-eoapi/application.yaml b/applications/argocd/staging/applications/montandon-eoapi/application.yaml index 6a0d7a0..1af510e 100644 --- a/applications/argocd/staging/applications/montandon-eoapi/application.yaml +++ b/applications/argocd/staging/applications/montandon-eoapi/application.yaml @@ -54,17 +54,36 @@ spec: image: tag: 6.1.2 overrideRootPath: "" + # External Azure PG + HPA: keep concurrency/pools capped. + # Ceiling: maxReplicas × WEB_CONCURRENCY × pools(2 w/ transactions) × DB_MAX_CONN_SIZE + # See https://github.com/developmentseed/eoapi-k8s/blob/main/docs/autoscaling.md#external--shared-postgresql + autoscaling: + enabled: true + minReplicas: 1 + maxReplicas: 3 + type: "cpu" + targets: + cpu: 70 + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + scaleUp: + stabilizationWindowSeconds: 60 settings: labels: azure.workload.identity/use: "true" resources: requests: memory: "2048Mi" - cpu: "10m" + # HPA CPU% is relative to requests; keep this meaningful (not near-zero). + cpu: "500m" limits: memory: "4096Mi" cpu: "1000m" envVars: + WEB_CONCURRENCY: "4" + DB_MIN_CONN_SIZE: "1" + DB_MAX_CONN_SIZE: "1" ENABLE_TRANSACTIONS_EXTENSIONS: "TRUE" FORWARDED_ALLOW_IPS: "*" PROXY_HEADERS: True @@ -144,7 +163,18 @@ spec: tls: enabled: true secretName: "montandon-eoapi-helm-secret-cert" - replicaCount: 1 + autoscaling: + enabled: true + minReplicas: 1 + maxReplicas: 3 + targetCPUUtilizationPercentage: 75 + resources: + limits: + cpu: 500m + memory: "2048Mi" + requests: + cpu: 200m + memory: "1024Mi" extraVolumes: - name: filters configMap: