fix(kubernetes-nodes): scale a pool capped at zero down to zero (#5539)

## What this PR does

Setting `maxReplicas: 0` on a pool didn't stop its workers. The chart
leaves `spec.replicas` out and expects CAPI to clamp it into `[min,
max]`, but on a real cluster the MachineDeployment stayed at `replicas:
1` with min 0 / max 0, and the autoscaler only removes nodes it
considers unneeded. We hit this when a managed cluster was suspended for
lack of funds, and with Stop group in the console.

Now a pool with `maxReplicas: 0` renders `replicas: 0`. When
`maxReplicas` goes back up the field is dropped again, CAPI keeps the
live 0 and the autoscaler scales the pool back to its minimum. Pools
with a non-zero cap render as before.

### Screenshots

No UI changes.

### Downstream repositories

Only the `maxReplicas` description changed in the generated docs. I did
not walk the website sync for it, so the boxes are left for a human.

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
fix(kubernetes-nodes): a worker pool set to maxReplicas 0 now scales its workers down to zero instead of keeping the running ones.
```



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Setting a worker pool’s maximum replicas to `0` now pauses the pool
and scales its workers down to zero. The pool can resume when the limit
is raised.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Aleksei Sviridkin authored and GitHub committed 2026-12-03 08:13:26 +03:00
commit 2d487d2bfa
7 files changed
+29 -5

No files matched your search

+1 -1
View File
@@ -37,7 +37,7 @@ type ConfigSpec struct {
// Minimum number of replicas in this pool. Used as the cluster-autoscaler floor.
// +kubebuilder:default:=0
MinReplicas int `json:"minReplicas"`
// Maximum number of replicas in this pool. Used as the cluster-autoscaler ceiling.
// Maximum number of replicas in this pool. Used as the cluster-autoscaler ceiling. 0 pauses the pool: its workers are scaled down to zero.
// +kubebuilder:default:=10
MaxReplicas int `json:"maxReplicas"`
// KubeVirt instance type that sizes each worker VM when `resources` is not set. Ignored when `resources.cpu` and `resources.memory` are both set, and therefore on `substrate: proxmox`, which requires them.