fix(kubernetes-nodes): surge one worker at a time during a pool rollout

A worker pool rolled out with maxSurge set to its maxReplicas, so CAPI
could create up to maxReplicas replacement VMs before draining any old
one. A pool running 8 workers under a ceiling of 10 could reach 18 VMs
at the peak of an instance type, image or version change.

Those extra VMs run in the tenant's namespace. Today the namespace
ResourceQuota counts them, so a tenant near its quota sees replacement
launchers refused and the rollout stall. Under quotas as reservation
limits, where a pool reserves maxReplicas workers and the namespace
quota goes away, the surge is capacity the platform lends for the
length of a rollout: rollouts are mostly platform-driven, and counting
them against the tenant would block a platform upgrade for any tenant
whose pool sits at its ceiling. That loan has to be bounded, and with
a surge tied to maxReplicas it was as large as the pool itself.

The surge is now one Machine whatever the pool's size. It stays out of
the values: tenants write them, and would then size the platform's
margin. maxUnavailable is unchanged, so a node is still only drained
once its replacement is up; a large pool now rolls one worker at a
time.

Tested with helm unittest on kubernetes-nodes, with the golden renders
updated for the new surge.

Refs: cozystack/community#48
Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
This commit is contained in:
Mattia Eleuteri committed 2026-11-23 13:27:57 +01:00
1 parent 2af1e21299
commit fffbb97ac9
3 files changed
+17 -8

No files matched your search

@@ -1044,15 +1044,21 @@ spec:
joined. A pool with passed-through GPUs keeps 1: its replacement VM
may need the very GPU the old node holds, and would wait for it
forever. A Proxmox template's GPU is invisible here, hence the
maxUnavailable override. CAPI refuses maxSurge and maxUnavailable both
at 0, and maxReplicas may be 0, hence the floor of 1. */}}
maxUnavailable override.
maxSurge is one Machine whatever the pool's size. A tenant's quota
reserves maxReplicas workers, and the surge runs on top of whatever
the pool runs, so it is capacity the platform lends during a rollout;
a fixed surge bounds that loan to one worker per pool. It is not a
value because tenants write the values, and would then size the
platform's margin themselves. CAPI refuses maxSurge and
maxUnavailable both at 0, so it cannot be 0 either. */}}
{{- $maxUnavailable := ternary 1 0 (not (empty $group.gpus)) }}
{{- if not (kindIs "invalid" $.Values.maxUnavailable) }}
{{- $maxUnavailable = $.Values.maxUnavailable | int }}
{{- end }}
strategy:
rollingUpdate:
maxSurge: {{ max 1 ($group.maxReplicas | int) }}
maxSurge: 1
maxUnavailable: {{ $maxUnavailable }}
type: RollingUpdate
selector:
@@ -96,7 +96,7 @@ matches the golden render of a GPU pool:
cluster.x-k8s.io/deployment-name: kubernetes-myk8s-md0
strategy:
rollingUpdate:
maxSurge: 3
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
@@ -249,7 +249,7 @@ matches the golden render of a kubelet-override pool:
cluster.x-k8s.io/deployment-name: kubernetes-myk8s-md0
strategy:
rollingUpdate:
maxSurge: 3
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
@@ -404,7 +404,7 @@ matches the golden render of the pool objects:
cluster.x-k8s.io/deployment-name: kubernetes-myk8s-md0
strategy:
rollingUpdate:
maxSurge: 3
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
@@ -36,8 +36,11 @@ tests:
path: spec.strategy.rollingUpdate.maxSurge
value: 1
- it: surges up to the pool ceiling
# The tenant's quota reserves maxReplicas workers; the surge runs on top
# of them, so it is bounded to one worker whatever the pool's size.
- it: surges one worker at a time whatever the pool ceiling
set:
minReplicas: 5
maxReplicas: 5
documentSelector:
path: kind
@@ -45,7 +48,7 @@ tests:
asserts:
- equal:
path: spec.strategy.rollingUpdate.maxSurge
value: 5
value: 1
- equal:
path: spec.strategy.rollingUpdate.maxUnavailable
value: 0