From 97666c4e2f517c02e109407215529ecc7edb575f Mon Sep 17 00:00:00 2001 From: git_admin Date: Sun, 26 Apr 2026 20:04:39 +0300 Subject: [PATCH] Add named sizes table (tiny/small/medium/large) --- templates/_helpers.tpl | 12 ++++++ templates/odoo-deployment.yaml | 2 +- templates/postgres-statefulset.yaml | 2 +- values.yaml | 58 ++++++++++++++++++++++------- 4 files changed, 58 insertions(+), 16 deletions(-) diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 1612db5..425bd89 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -18,6 +18,18 @@ app.kubernetes.io/version: {{ .Values.odoo.tag | quote }} odoosky.io/component: instance {{- end -}} +{{/* +Resources for a given role (`odoo` | `postgres`), looked up against +the `sizes` table by `instance.size`. Falls back to "small" if the +operator picked a name that doesn't exist (defensive: a typo +shouldn't blow up the rendered chart). +*/}} +{{- define "instance.resources" -}} +{{- $size := .Values.instance.size | default "small" -}} +{{- $cfg := index .Values.sizes $size | default (index .Values.sizes "small") -}} +{{- toYaml (index $cfg .role) -}} +{{- end -}} + {{/* Postgres password. Looks up the existing Secret on upgrades; uses .Values.postgres.password if set; otherwise generates a 32-char diff --git a/templates/odoo-deployment.yaml b/templates/odoo-deployment.yaml index 8d18803..086c227 100644 --- a/templates/odoo-deployment.yaml +++ b/templates/odoo-deployment.yaml @@ -47,7 +47,7 @@ spec: - name: filestore mountPath: /var/lib/odoo resources: - {{- toYaml .Values.odoo.resources | nindent 12 }} + {{- include "instance.resources" (dict "Values" .Values "role" "odoo") | nindent 12 }} # /web/login is the most stable health endpoint across Odoo # 16/17/18/19 — /web/health is 17+. Use login HTTP 200 as # readiness signal. diff --git a/templates/postgres-statefulset.yaml b/templates/postgres-statefulset.yaml index 162ea2f..716a16f 100644 --- a/templates/postgres-statefulset.yaml +++ b/templates/postgres-statefulset.yaml @@ -37,7 +37,7 @@ spec: - name: pgdata mountPath: /var/lib/postgresql/data resources: - {{- toYaml .Values.postgres.resources | nindent 12 }} + {{- include "instance.resources" (dict "Values" .Values "role" "postgres") | nindent 12 }} readinessProbe: exec: command: ["sh", "-c", "pg_isready -U $POSTGRES_USER -d $POSTGRES_DB"] diff --git a/values.yaml b/values.yaml index 06529ee..8a8190a 100644 --- a/values.yaml +++ b/values.yaml @@ -12,19 +12,56 @@ instance: # The full HTTPS hostname this instance answers on. # Tenants live under *.tenants.odoosky.org (covered by wildcard DNS A). domain: demo.tenants.odoosky.org + # Named size — looked up against the `sizes` table below to derive + # CPU / memory limits + Odoo workers. Per-tenant overlays only need + # `instance.size: medium` (etc); they don't have to know the numbers. + size: small + +# The named-size table. Single source of truth for what each instance +# tier actually gets. Adjust here, ALL future instances pick up the +# new defaults on next reconcile. Existing instances keep their +# previously-rendered manifests until ArgoCD re-syncs. +# +# Anchored loosely on v2's tested defaults: +# tiny — dev/preview, 1 user +# small — 5–15 users, default +# medium — 15–50 users +# large — 50–150 users +sizes: + tiny: + odoo: + requests: { memory: 256Mi, cpu: 100m } + limits: { memory: 1Gi, cpu: "1" } + postgres: + requests: { memory: 128Mi, cpu: 50m } + limits: { memory: 256Mi, cpu: 500m } + small: + odoo: + requests: { memory: 512Mi, cpu: 250m } + limits: { memory: 2Gi, cpu: "2" } + postgres: + requests: { memory: 256Mi, cpu: 100m } + limits: { memory: 1Gi, cpu: "1" } + medium: + odoo: + requests: { memory: 1Gi, cpu: 500m } + limits: { memory: 4Gi, cpu: "4" } + postgres: + requests: { memory: 512Mi, cpu: 250m } + limits: { memory: 2Gi, cpu: "2" } + large: + odoo: + requests: { memory: 2Gi, cpu: "1" } + limits: { memory: 8Gi, cpu: "6" } + postgres: + requests: { memory: 1Gi, cpu: 500m } + limits: { memory: 4Gi, cpu: "3" } odoo: image: odoo tag: "18.0" # Filestore PVC size (Odoo's /var/lib/odoo). filestoreSize: 10Gi - resources: - requests: - memory: 512Mi - cpu: 250m - limits: - memory: 2Gi - cpu: "2" postgres: image: postgres @@ -35,13 +72,6 @@ postgres: # the existing Secret on subsequent upgrades (lookup pattern). password: "" storage: 10Gi - resources: - requests: - memory: 256Mi - cpu: 100m - limits: - memory: 1Gi - cpu: "1" ingress: # Traefik entrypoint name (set on the Traefik install in the