From ac845b5073e482de5de1ccc223886f4c49f7499a Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Thu, 11 Dec 2025 17:11:06 +0100 Subject: [PATCH] properly set requests and limits for the deployment --- README.md | 26 +++++++++++++++++++ .../kustomize/base/portal/deployment.yaml | 7 +++++ .../production/portal-deployment.yaml | 7 ----- .../overlays/staging/portal-deployment.yaml | 21 +++++++++++++++ 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index eaa1cdd..f435a90 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,32 @@ Then access it with http://localhost:8080/ and the Django admin with http://loca Deployment files are in the `deployment/kustomize` folder and makes use of [Kustomize](https://kustomize.io/) to account for differences between the deployment stages. Stages are configured with overlays in `deployment/kustomize/overlays/$environment`. +### Resource Requests and Limits + +Resources are configured to comply with APPUiO Cloud's memory-to-CPU ratio of 4096 MiB/core. +See [APPUiO Cloud documentation](https://docs.appuio.cloud/user/how-to/check-cpu-requests.html) for details. + +**Production:** + +| Container | CPU Request | Memory Request | CPU Limit | Memory Limit | +|-----------|-------------|----------------|-----------|--------------| +| servala | 500m | 2Gi | 2 | 4Gi | + +**Staging:** + +| Container | CPU Request | Memory Request | CPU Limit | Memory Limit | +|------------------|-------------|----------------|-----------|--------------| +| servala | 250m | 1Gi | 1 | 2Gi | +| ssh-tunnel-dev | 50m | 204Mi | 100m | 256Mi | +| ssh-tunnel-talos | 50m | 204Mi | 100m | 256Mi | + +**Ratio Calculation:** + +The ratio is calculated as: `Sum of Memory Requests / Sum of CPU Requests` + +- Production: 2048 MiB / 0.5 cores = **4096 MiB/core** ✓ +- Staging: (1024 + 204 + 204) MiB / (0.25 + 0.05 + 0.05) cores = 1432 MiB / 0.35 cores = **4091 MiB/core** ✓ + ### Staging The code is automatically built and deployed on a push to the main branch. diff --git a/deployment/kustomize/base/portal/deployment.yaml b/deployment/kustomize/base/portal/deployment.yaml index 03deb98..1b33aae 100644 --- a/deployment/kustomize/base/portal/deployment.yaml +++ b/deployment/kustomize/base/portal/deployment.yaml @@ -21,6 +21,13 @@ spec: - name: servala image: servala.app.codey.ch/servala/servala-portal:latest imagePullPolicy: Always + resources: + requests: + cpu: 500m + memory: 2Gi + limits: + cpu: 2 + memory: 4Gi ports: - name: http containerPort: 8080 diff --git a/deployment/kustomize/overlays/production/portal-deployment.yaml b/deployment/kustomize/overlays/production/portal-deployment.yaml index 47574f4..bc6050f 100644 --- a/deployment/kustomize/overlays/production/portal-deployment.yaml +++ b/deployment/kustomize/overlays/production/portal-deployment.yaml @@ -32,10 +32,3 @@ spec: secretKeyRef: name: portal-storage-creds key: AWS_SECRET_ACCESS_KEY - resources: - limits: - cpu: 2 - memory: 2Gi - requests: - cpu: 500m - memory: 512Mi diff --git a/deployment/kustomize/overlays/staging/portal-deployment.yaml b/deployment/kustomize/overlays/staging/portal-deployment.yaml index bfa36d4..e978ccd 100644 --- a/deployment/kustomize/overlays/staging/portal-deployment.yaml +++ b/deployment/kustomize/overlays/staging/portal-deployment.yaml @@ -7,6 +7,13 @@ spec: spec: containers: - name: servala + resources: + requests: + cpu: 250m + memory: 1Gi + limits: + cpu: 1 + memory: 2Gi env: - name: SERVALA_ENVIRONMENT value: staging @@ -34,6 +41,13 @@ spec: key: AWS_SECRET_ACCESS_KEY - name: ssh-tunnel-dev image: servala.app.codey.ch/servala/servala-portal:latest + resources: + requests: + cpu: 50m + memory: 204Mi + limits: + cpu: 100m + memory: 256Mi command: - "/bin/bash" - "-c" @@ -57,6 +71,13 @@ spec: key: ssh-private-key - name: ssh-tunnel-talos image: servala.app.codey.ch/servala/servala-portal:latest + resources: + requests: + cpu: 50m + memory: 204Mi + limits: + cpu: 100m + memory: 256Mi command: - "/bin/bash" - "-c"