From d27593b2ff7c97327ee85064f2d46bd45c839790 Mon Sep 17 00:00:00 2001 From: Simon Scatton Date: Thu, 26 Nov 2026 18:09:19 +0100 Subject: [PATCH 1/3] fix(helm): set control plane resource budgets Signed-off-by: Simon Scatton --- deploy/helm/openshell/README.md | 4 +- .../openshell/tests/autoscaling_test.yaml | 13 ++-- .../helm/openshell/tests/resources_test.yaml | 78 +++++++++++++++++++ .../helm/openshell/tests/supervisor_test.yaml | 9 ++- deploy/helm/openshell/values-scale-10k.yaml | 5 ++ deploy/helm/openshell/values.yaml | 34 +++++--- docs/kubernetes/high-availability.mdx | 28 +++++-- skills/debug-openshell-cluster/SKILL.md | 11 ++- 8 files changed, 152 insertions(+), 30 deletions(-) create mode 100644 deploy/helm/openshell/tests/resources_test.yaml diff --git a/deploy/helm/openshell/README.md b/deploy/helm/openshell/README.md index 3216024838..fa2f76cfa3 100644 --- a/deploy/helm/openshell/README.md +++ b/deploy/helm/openshell/README.md @@ -713,7 +713,7 @@ for peer identity policies, multi-node registrations, and authorization. | rbac.clusterScoped.create | bool | `true` | Create the cluster-scoped ClusterRole and ClusterRoleBinding. Disable for a namespace-admin install where a cluster-admin applies them separately; the gateway ServiceAccount name and namespace are unchanged, so a pre-created ClusterRoleBinding still matches. | | rbac.create | bool | `true` | Create the RBAC objects that grant the gateway ServiceAccount access. Disable to supply the namespaced sandbox and peer Role/RoleBinding and the cluster-scoped ClusterRole/ClusterRoleBinding out of band. The certgen hook and credential driver RBAC keep their own flags. | | replicaCount | int | `1` | Number of OpenShell gateway replicas. Values greater than 1 require server.externalDbSecret because the default SQLite backend is per pod. | -| resources | object | `{}` | Gateway pod resource requests and limits. | +| resources | object | `{"limits":{"cpu":"2","memory":"2Gi"},"requests":{"cpu":"500m","memory":"512Mi"}}` | Gateway container resource requests and limits for an initial deployment. Size for the number of sandboxes, retained logs, traffic, and failover; the pool's logical capacity does not determine a safe resource budget. Set resources to null to omit the budget, or limits to null to omit limits. | | sandbox.image.digest | string | `""` | Sandbox image digest. When set, this takes precedence over tag. | | sandbox.image.pullPolicy | string | `nil` | Sandbox image pull policy. Leave unset to use the Kubernetes image default. | | sandbox.image.repository | string | `"nvcr.io/nvidia/base/ubuntu"` | Default standalone sandbox image repository. | @@ -843,7 +843,7 @@ for peer identity policies, multi-node registrations, and authorization. | supervisor.pool.maxMembersPerGateway | int | `32` | Most supervisors one gateway replica serves, rendered as [openshell.gateway.supervisor_pool] max_members_per_gateway. Must be a positive integer. The pool runs at most gateway replicas times maxMembersPerGateway times maxInstancesPerMember sandboxes, never more than 131072. | | supervisor.recoveryTimeoutSeconds | int | `60` | Seconds a sandbox workload stays frozen after losing its pool member's supervision before the sandbox runtime terminates it, rendered as [openshell.gateway.supervisor_pool] recovery_timeout_secs. Must be an integer from 30 to 300. Null leaves the gateway's pool default of 60 seconds. | | supervisor.replicas | int | `1` | Shared supervisor pool members, used only when gatewayConfig selects supervisor_topology = "gateway". The gateway always coordinates the shared supervisor as a high-availability pool: when a member fails or leaves, another member takes over its sandboxes without restarting their workloads. 1 has no failover; use 2 or more to survive losing a member. Only the supervisor Deployment's replica count depends on this value, so changing it neither restarts the gateway nor replaces running members. Ignored when supervisor.autoscaling.enabled is true. Must not exceed replicaCount * supervisor.pool.maxMembersPerGateway. | -| supervisor.resources | object | `{}` | Resources of each shared supervisor container, unset by default. Memory grows with the sandboxes a supervisor runs; for the default of 128 sandboxes, request 250m CPU and 768Mi memory with a 1.5Gi memory limit. Refer to Size Sandbox Capacity in the High Availability guide. | +| supervisor.resources | object | `{"limits":{"cpu":"1","memory":"1.5Gi"},"requests":{"cpu":"250m","memory":"768Mi"}}` | Resources of each shared supervisor container, initially sized for 128 sandboxes. Increase these with pool.maxInstancesPerMember and allow for failover. Refer to Size Sandbox Capacity in the High Availability guide. Set resources to null to omit the budget, or limits to null to omit limits. | | supervisor.sandboxRuntime.boundaryPort | int | `5500` | Workload boundary TLS listener port. | | tolerations | list | `[]` | Tolerations for the gateway pod. | | topologySpreadConstraints | list | `[]` | Topology spread constraints for the gateway pod, used to spread replicas across zones or nodes. Empty = omit the field. | diff --git a/deploy/helm/openshell/tests/autoscaling_test.yaml b/deploy/helm/openshell/tests/autoscaling_test.yaml index ee3a2b7d79..ba7e4946fa 100644 --- a/deploy/helm/openshell/tests/autoscaling_test.yaml +++ b/deploy/helm/openshell/tests/autoscaling_test.yaml @@ -244,6 +244,7 @@ tests: workload.kind: deployment server.externalDbSecret: my-pg-secret autoscaling.enabled: true + resources: null asserts: - failedTemplate: errorPattern: "autoscaling.targetCPUUtilizationPercentage requires a positive resources.requests.cpu" @@ -255,6 +256,7 @@ tests: set: autoscaling.targetMemoryUtilizationPercentage: 70 resources.requests.memory: null + resources.limits.memory: null asserts: - failedTemplate: errorPattern: "autoscaling.targetMemoryUtilizationPercentage requires a positive resources.requests.memory" @@ -294,18 +296,16 @@ tests: - failedTemplate: errorPattern: "autoscaling.targetCPUUtilizationPercentage requires a positive resources.requests.cpu" - # The chart renders a null request, which Kubernetes stores as zero instead - # of copying the limit. - - it: fails when the CPU request is null even with a CPU limit - template: templates/statefulset.yaml + - it: accepts a CPU limit when null removes the default CPU request + template: templates/hpa.yaml values: - ../ci/values-autoscaling.yaml set: resources.requests.cpu: null resources.limits.cpu: "1" asserts: - - failedTemplate: - errorPattern: "autoscaling.targetCPUUtilizationPercentage requires a positive resources.requests.cpu" + - isKind: + of: HorizontalPodAutoscaler - it: fails when the CPU request is zero in exponent form template: templates/statefulset.yaml @@ -335,6 +335,7 @@ tests: server.externalDbSecret: my-pg-secret autoscaling.enabled: true autoscaling.targetMemoryUtilizationPercentage: 70 + resources.requests: null resources.limits.cpu: "1" resources.limits.memory: 1Gi asserts: diff --git a/deploy/helm/openshell/tests/resources_test.yaml b/deploy/helm/openshell/tests/resources_test.yaml new file mode 100644 index 0000000000..5241ceb612 --- /dev/null +++ b/deploy/helm/openshell/tests/resources_test.yaml @@ -0,0 +1,78 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +suite: control plane resource budgets +templates: + - templates/gateway-config.yaml + - templates/statefulset.yaml + - templates/deployment.yaml + - templates/supervisor.yaml + +tests: + - it: budgets the default gateway StatefulSet + template: templates/statefulset.yaml + asserts: + - equal: + path: spec.template.spec.containers[0].resources + value: &gatewayBudget + requests: + cpu: 500m + memory: 512Mi + limits: + cpu: "2" + memory: 2Gi + + - it: budgets the gateway Deployment + template: templates/deployment.yaml + set: + workload.kind: deployment + server.externalDbSecret: openshell-db + asserts: + - equal: + path: spec.template.spec.containers[0].resources + value: *gatewayBudget + + - it: preserves gateway overrides and explicit limit removal + template: templates/statefulset.yaml + set: + resources.requests.cpu: 750m + resources.requests.memory: 1Gi + resources.limits: null + asserts: + - equal: + path: spec.template.spec.containers[0].resources.requests + value: + cpu: 750m + memory: 1Gi + - notExists: + path: spec.template.spec.containers[0].resources.limits + + - it: allows removing the gateway budget + template: templates/statefulset.yaml + set: + resources: null + asserts: + - equal: + path: spec.template.spec.containers[0].resources + value: null + + - it: leaves the scale profile gateway ceiling to the operator + template: templates/deployment.yaml + values: + - ../values-scale-10k.yaml + set: + server.externalDbSecret: openshell-db + asserts: + - notExists: + path: spec.template.spec.containers[0].resources.limits + + - it: allows removing the shared supervisor budget + template: templates/supervisor.yaml + set: + gatewayConfig: + openshell.drivers.kubernetes: + supervisor_topology: gateway + supervisor.resources: null + asserts: + - notExists: + path: spec.template.spec.containers[0].resources diff --git a/deploy/helm/openshell/tests/supervisor_test.yaml b/deploy/helm/openshell/tests/supervisor_test.yaml index 717560836c..e3d8afbc5c 100644 --- a/deploy/helm/openshell/tests/supervisor_test.yaml +++ b/deploy/helm/openshell/tests/supervisor_test.yaml @@ -377,8 +377,15 @@ tests: path: spec.replicas value: 1 documentIndex: 0 - - notExists: + - equal: path: spec.template.spec.containers[0].resources + value: + requests: + cpu: 250m + memory: 768Mi + limits: + cpu: "1" + memory: 1.5Gi documentIndex: 0 - contains: path: spec.template.spec.containers[0].env diff --git a/deploy/helm/openshell/values-scale-10k.yaml b/deploy/helm/openshell/values-scale-10k.yaml index 55d6919ce0..f3b1530af5 100644 --- a/deploy/helm/openshell/values-scale-10k.yaml +++ b/deploy/helm/openshell/values-scale-10k.yaml @@ -18,6 +18,11 @@ replicaCount: 2 workload: kind: deployment +# Supply measured gateway requests and limits for the intended workload. +# Do not inherit the initial-deployment ceiling at this sandbox count. +resources: + limits: null + gatewayConfig: openshell.drivers.kubernetes: supervisor_topology: gateway diff --git a/deploy/helm/openshell/values.yaml b/deploy/helm/openshell/values.yaml index e1f45947f4..809f992703 100644 --- a/deploy/helm/openshell/values.yaml +++ b/deploy/helm/openshell/values.yaml @@ -95,16 +95,17 @@ supervisor: # maxMembersPerGateway times maxInstancesPerMember sandboxes, never more # than 131072. maxMembersPerGateway: 32 - # -- Resources of each shared supervisor container, unset by default. - # Memory grows with the sandboxes a supervisor runs; for the default of 128 - # sandboxes, request 250m CPU and 768Mi memory with a 1.5Gi memory limit. - # Refer to Size Sandbox Capacity in the High Availability guide. - resources: {} - # requests: - # cpu: 250m - # memory: 768Mi - # limits: - # memory: 1.5Gi + # -- Resources of each shared supervisor container, initially sized for + # 128 sandboxes. Increase these with pool.maxInstancesPerMember and allow + # for failover. Refer to Size Sandbox Capacity in the High Availability guide. + # Set resources to null to omit the budget, or limits to null to omit limits. + resources: + requests: + cpu: 250m + memory: 768Mi + limits: + cpu: "1" + memory: 1.5Gi autoscaling: # -- Enable memory-based autoscaling of the shared supervisor Deployment. # Requires supervisor_topology = "gateway" and the Kubernetes resource @@ -415,8 +416,17 @@ probes: # -- Readiness probe failure threshold before the pod is marked not ready. failureThreshold: 3 -# -- Gateway pod resource requests and limits. -resources: {} +# -- Gateway container resource requests and limits for an initial deployment. +# Size for the number of sandboxes, retained logs, traffic, and failover; the +# pool's logical capacity does not determine a safe resource budget. +# Set resources to null to omit the budget, or limits to null to omit limits. +resources: + requests: + cpu: 500m + memory: 512Mi + limits: + cpu: "2" + memory: 2Gi # -- Node selector for the gateway pod. nodeSelector: {} diff --git a/docs/kubernetes/high-availability.mdx b/docs/kubernetes/high-availability.mdx index dc70edeec2..96f8844cc6 100644 --- a/docs/kubernetes/high-availability.mdx +++ b/docs/kubernetes/high-availability.mdx @@ -303,6 +303,19 @@ lock held longer than 10 seconds. ## Scale the Gateway +The chart initially requests `500m` CPU and `512Mi` memory per gateway, with +limits of `2` CPUs and `2Gi` memory. These are starting budgets, not resources +for the pool's maximum sandbox count. Size `resources` for your traffic, +sandbox count, and the sessions a surviving replica takes over during failover. +Gateway memory also grows as per-sandbox log tails fill; a full tail can retain +about `4Mi` of heap per sandbox in addition to connections and runtime overhead. +Monitor container memory and CPU throttling when increasing load. + +Override individual requests or limits in your values file. Helm merges maps, +so `resources: {}` retains these defaults. Use `resources.limits: null` to +remove the limits, or `resources: null` to remove the whole budget. Removing +requests also requires disabling any HPA utilization targets that depend on them. + Scale the gateway by changing a fixed replica count or by letting a HorizontalPodAutoscaler choose one. In both cases, keep at least two ready replicas when availability must survive one gateway pod failure, and size @@ -703,16 +716,19 @@ helm install openshell -n openshell \ --set server.externalDbSecret= --set supervisor.replicas=80 ``` -Supervisor memory grows with the sandboxes it runs. The chart sets no -`supervisor.resources` by default. For 128 sandboxes per supervisor, request -`250m` CPU and `768Mi` memory, with a `1.5Gi` memory limit, and scale memory -with `maxInstancesPerMember`. +Supervisor memory grows with the sandboxes it runs. For the default of 128 +sandboxes per supervisor, `supervisor.resources` requests `250m` CPU and +`768Mi` memory, with limits of `1` CPU and `1.5Gi` memory. Increase the budget +with `maxInstancesPerMember`, and leave capacity for a member failure. Use +`supervisor.resources.limits: null` to remove limits or +`supervisor.resources: null` to omit the budget. The chart ships `values-scale-10k.yaml` as a starting point for about 10,000 sandboxes: 2 gateway replicas with up to 40 supervisors each, and a supervisor HPA from 10 to 80 replicas at 128 sandboxes each. It needs an external -database. Pull the chart to get the file, then install from the extracted -copy: +database. The profile removes the initial gateway limits; set measured gateway +requests and limits for your workload before production use. Pull the chart +to get the file, then install from the extracted copy: ```shell helm pull oci://quay.io/ai-openshell/charts/openshell --version --untar diff --git a/skills/debug-openshell-cluster/SKILL.md b/skills/debug-openshell-cluster/SKILL.md index 85c60b1d4d..c0cff0067c 100644 --- a/skills/debug-openshell-cluster/SKILL.md +++ b/skills/debug-openshell-cluster/SKILL.md @@ -1418,9 +1418,14 @@ member at its cap, or the pool at gateway replicas × members × instances reached"; the gateway log warns "every supervisor is at its sandbox limit" or "supervisor pool is at its sandbox limit" to say which. Raise the cap or add members. Supervisor container -resources come from `supervisor.resources` (unset by default; the chart -recommends requests 250m and 768Mi with a 1.5Gi memory limit for 128 -sandboxes per supervisor). The chart rolls one member +resources come from `supervisor.resources` (requests 250m and 768Mi, limits +1 CPU and 1.5Gi by default for 128 sandboxes per supervisor). The gateway +defaults to requests 500m and 512Mi, limits 2 CPUs and 2Gi. Check for +`OOMKilled`, CPU throttling, or unschedulable requests; increase budgets for +sandbox count, full gateway log tails, and failover. Empty maps retain chart +defaults; set the corresponding `resources` or `resources.limits` to null to +remove them. The 10,000-sandbox profile leaves gateway limits to the operator. +The chart rolls one member at a time, sets no affinity by default (set `supervisor.affinity` to control supervisor scheduling; top-level `affinity` applies only to the gateway), gives each member a 60-second grace period to leave, From 931c0372ff01096bde12dd5e41210960de83752f Mon Sep 17 00:00:00 2001 From: Simon Scatton Date: Thu, 26 Nov 2026 18:21:03 +0100 Subject: [PATCH 2/3] test(helm): align supervisor budget assertions Signed-off-by: Simon Scatton --- deploy/helm/test-supervisor-pool-scaling.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/deploy/helm/test-supervisor-pool-scaling.sh b/deploy/helm/test-supervisor-pool-scaling.sh index 55cb11c33a..7b60e9e07c 100755 --- a/deploy/helm/test-supervisor-pool-scaling.sh +++ b/deploy/helm/test-supervisor-pool-scaling.sh @@ -108,9 +108,14 @@ render defaults [[ "$(supervisor_replicas defaults)" == "1" ]] || fail "the default pool renders $(supervisor_replicas defaults) replicas" yq ea -e 'select(.kind == "HorizontalPodAutoscaler") | .metadata.name' "${work_dir}/defaults.yaml" >/dev/null 2>&1 \ && fail "the default pool renders an HPA" +yq ea -e 'select(.kind == "Deployment" and .metadata.name == "scaling-openshell-supervisor") + | .spec.template.spec.containers[0] | has("resources")' \ + "${work_dir}/defaults.yaml" >/dev/null || fail "the supervisor renders no resource budget by default" + +render no-budget --set supervisor.resources=null yq ea -e 'select(.kind == "Deployment" and .metadata.name == "scaling-openshell-supervisor") | .spec.template.spec.containers[0] | has("resources") | not' \ - "${work_dir}/defaults.yaml" >/dev/null || fail "the supervisor renders resources by default" + "${work_dir}/no-budget.yaml" >/dev/null || fail "the supervisor renders resources after explicit removal" # The pool limits reach the gateway table and every supervisor alike. render limits --set supervisor.pool.maxInstancesPerMember=16 --set supervisor.pool.maxMembersPerGateway=4 From f35ed22b9bac3a84efceba8258683a47da33395a Mon Sep 17 00:00:00 2001 From: Simon Scatton Date: Fri, 27 Nov 2026 12:09:58 +0100 Subject: [PATCH 3/3] docs(helm): explain resource upgrade risks Signed-off-by: Simon Scatton --- docs/kubernetes/high-availability.mdx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/kubernetes/high-availability.mdx b/docs/kubernetes/high-availability.mdx index 96f8844cc6..5bf5ba2a30 100644 --- a/docs/kubernetes/high-availability.mdx +++ b/docs/kubernetes/high-availability.mdx @@ -316,6 +316,13 @@ so `resources: {}` retains these defaults. Use `resources.limits: null` to remove the limits, or `resources: null` to remove the whole budget. Removing requests also requires disabling any HPA utilization targets that depend on them. +Before upgrading an existing release, check its gateway memory usage. Installs +that never set `resources` gain the `2Gi` memory limit when adopting these +defaults and can be OOM-killed if their usage exceeds it. Requests-only +overrides also retain default limits: `resources.requests.memory: 4Gi` with +the default `2Gi` limit produces an invalid Pod. Set matching limits for your +workload or remove them explicitly before upgrading. + Scale the gateway by changing a fixed replica count or by letting a HorizontalPodAutoscaler choose one. In both cases, keep at least two ready replicas when availability must survive one gateway pod failure, and size