From 86b465422f935b3587e64aaa68d2cec7149b27a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?= Date: Sat, 6 Sep 2025 12:04:32 +0200 Subject: [PATCH] Add initial K8s web HPA. --- config/deploy/production/web-hpa.yaml.erb | 1 + config/deploy/staging/web-hpa.yaml.erb | 1 + config/deploy/web-hpa.yaml.erb | 38 +++++++++++++++++++++++ config/deploy/web.yaml.erb | 1 + 4 files changed, 41 insertions(+) create mode 120000 config/deploy/production/web-hpa.yaml.erb create mode 120000 config/deploy/staging/web-hpa.yaml.erb create mode 100644 config/deploy/web-hpa.yaml.erb diff --git a/config/deploy/production/web-hpa.yaml.erb b/config/deploy/production/web-hpa.yaml.erb new file mode 120000 index 00000000000..f5f3c200bcf --- /dev/null +++ b/config/deploy/production/web-hpa.yaml.erb @@ -0,0 +1 @@ +../web-hpa.yaml.erb \ No newline at end of file diff --git a/config/deploy/staging/web-hpa.yaml.erb b/config/deploy/staging/web-hpa.yaml.erb new file mode 120000 index 00000000000..f5f3c200bcf --- /dev/null +++ b/config/deploy/staging/web-hpa.yaml.erb @@ -0,0 +1 @@ +../web-hpa.yaml.erb \ No newline at end of file diff --git a/config/deploy/web-hpa.yaml.erb b/config/deploy/web-hpa.yaml.erb new file mode 100644 index 00000000000..d9def7fc6f8 --- /dev/null +++ b/config/deploy/web-hpa.yaml.erb @@ -0,0 +1,38 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: web-hpa + labels: + app: web + environment: <%= environment %> +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: web + minReplicas: <%= environment == 'production' ? 3 : 2 %> + maxReplicas: <%= environment == 'production' ? 10 : 5 %> + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 75 + behavior: + scaleDown: + stabilizationWindowSeconds: 300 + policies: + - type: Percent + value: 50 + periodSeconds: 60 + scaleUp: + stabilizationWindowSeconds: 60 + policies: + - type: Percent + value: 100 + periodSeconds: 60 + - type: Pods + value: 2 + periodSeconds: 60 + selectPolicy: Max diff --git a/config/deploy/web.yaml.erb b/config/deploy/web.yaml.erb index 3c81247120f..3c839a790d2 100644 --- a/config/deploy/web.yaml.erb +++ b/config/deploy/web.yaml.erb @@ -5,6 +5,7 @@ metadata: annotations: shipit.shopify.io/restart: 'true' spec: + replicas: <%= environment == 'production' ? 3 : 2 %> strategy: type: RollingUpdate rollingUpdate: