From a6225214977c310bf35b0f4232101dd59c5d1494 Mon Sep 17 00:00:00 2001 From: marcopiraccini Date: Mon, 31 Aug 2026 15:32:43 +0200 Subject: [PATCH] chart: expose configurable autoscaler unit Signed-off-by: marcopiraccini --- .github/workflows/ci.yml | 3 ++ MIGRATING-v3-to-v4.md | 2 +- README-ENTERPRISE.md | 1 + README.md | 1 + chart/Chart.yaml | 2 +- chart/templates/deployment/_icc.yaml | 2 ++ chart/values.yaml | 3 ++ test/autoscaler-unit.sh | 42 ++++++++++++++++++++++++++++ 8 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 test/autoscaler-unit.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 39d1963..16ec245 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,6 +52,9 @@ jobs: - name: 'Database URL compatibility' run: bash test/database-urls.sh + - name: 'Autoscaler unit configuration' + run: bash test/autoscaler-unit.sh + - name: 'Install kubeconform' run: | curl -sSL -o /tmp/kubeconform.tar.gz \ diff --git a/MIGRATING-v3-to-v4.md b/MIGRATING-v3-to-v4.md index 48760e5..faba778 100644 --- a/MIGRATING-v3-to-v4.md +++ b/MIGRATING-v3-to-v4.md @@ -306,7 +306,7 @@ Use the same Helm release name and release namespace as v3. Pin the exact v4 chart version that you tested. ```sh -CHART_VERSION=4.2.0 +CHART_VERSION=4.3.0 helm upgrade "$RELEASE" oci://ghcr.io/platformatic/helm \ --version "$CHART_VERSION" \ diff --git a/README-ENTERPRISE.md b/README-ENTERPRISE.md index daadf58..ea9af70 100644 --- a/README-ENTERPRISE.md +++ b/README-ENTERPRISE.md @@ -93,6 +93,7 @@ production-ready set of values except for the `secrets` portion. | `services.icc.image.pullPolicy` | When to pull an image update | IfNotPresent | No | | `services.icc.log_level` | The level to log ICC services | warn | No | | `services.icc.public_url` | The URL to access Intelligent Command Center (Note: ingress and domain must be configured by the user | "" | Yes | +| `services.icc.autoscaler_unit` | Singular word used by the UI for the autoscaler unit | pod | No | | `services.icc.database_url` | Base database connection string used when an exact URL is not set | "" | Conditional | | `services.icc.database_urls` | Exact connection strings keyed by ICC database service | {} | Conditional | | `services.icc.valkey.apps_url` | Valkey connection string | "" | Yes | diff --git a/README.md b/README.md index e9f3f7d..22c890a 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ production-ready set of values except for the `secrets` portion. | `services.icc.image.pullPolicy` | When to pull an image update | IfNotPresent | No | | `services.icc.log_level` | The level to log ICC services | warn | No | | `services.icc.public_url` | The URL to access Intelligent Command Center (Note: ingress and domain must be configured by the user | "" | Yes | +| `services.icc.autoscaler_unit` | Singular word used by the UI for the autoscaler unit | pod | No | | `services.icc.database_url` | Base database connection string used when an exact URL is not set | "" | Conditional | | `services.icc.database_urls` | Exact connection strings keyed by ICC database service | {} | Conditional | | `services.icc.valkey.apps_url` | Valkey connection string | "" | Yes | diff --git a/chart/Chart.yaml b/chart/Chart.yaml index ffbc747..a084187 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: helm -version: 4.2.0 +version: 4.3.0 kubeVersion: ">= 1.30.0-0" description: Platformatic microservices type: application diff --git a/chart/templates/deployment/_icc.yaml b/chart/templates/deployment/_icc.yaml index db2b3fe..1fb94be 100644 --- a/chart/templates/deployment/_icc.yaml +++ b/chart/templates/deployment/_icc.yaml @@ -159,6 +159,8 @@ spec: value: "{{ .public_url }}" - name: VITE_TERMS_VERSION value: "1" + - name: VITE_AUTOSCALER_UNIT + value: "{{ dig "autoscaler_unit" "pod" . | toString }}" # User manager - name: PLT_USER_MANAGER_SESSION_SECRET_KEY diff --git a/chart/values.yaml b/chart/values.yaml index 33106c2..c0e11b8 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -137,6 +137,9 @@ services: # https://example.com/icc #public_url: "" + # The word the UI uses for the autoscaler unit (e.g. "pod", "task") + #autoscaler_unit: "pod" + # Base URL used to derive all ICC database URLs. Do not include a database # name or trailing slash. Required unless all required exact URLs are set. database_url: "" diff --git a/test/autoscaler-unit.sh b/test/autoscaler-unit.sh new file mode 100644 index 0000000..6b323cb --- /dev/null +++ b/test/autoscaler-unit.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +set -euo pipefail + +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) +CHART_DIR="$ROOT_DIR/chart" + +fail() { + echo "FAIL: $*" >&2 + exit 1 +} + +autoscaler_unit() { + awk ' + $1 == "-" && $2 == "name:" && $3 == "VITE_AUTOSCALER_UNIT" { found = 1; next } + found && $1 == "value:" { gsub(/"/, "", $2); print $2; exit } + ' +} + +required_values=( + --set-string services.icc.database_url=postgres://user:pass@db:5432 + --set-string services.icc.valkey.apps_url=redis://valkey:6379/0 + --set-string services.icc.valkey.icc_url=redis://valkey:6379/1 + --set-string services.icc.prometheus.url=http://prometheus:9090 +) + +default_value=$(helm template autoscaler-unit "$CHART_DIR" \ + --kube-version 1.30.0 \ + "${required_values[@]}" | autoscaler_unit) + +[[ "$default_value" == 'pod' ]] || \ + fail "default autoscaler unit is $default_value, expected pod" + +custom_value=$(helm template autoscaler-unit "$CHART_DIR" \ + --kube-version 1.30.0 \ + "${required_values[@]}" \ + --set-string services.icc.autoscaler_unit=task | autoscaler_unit) + +[[ "$custom_value" == 'task' ]] || \ + fail "custom autoscaler unit is $custom_value, expected task" + +echo 'Autoscaler unit tests passed'