mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-06 07:03:45 +09:00
fix(kubernetes-nodes): scale a pool capped at zero down to zero
The chart leaves spec.replicas out of the MachineDeployment so the autoscaler owns it, and relies on CAPI to clamp the live value into [min, max]. A pool set to maxReplicas 0 to pause it kept its running workers: the clamp did not bring the MachineDeployment down, and the autoscaler only removes nodes it finds unneeded. Seen on a managed cluster suspended for lack of funds, and with Stop group in the console, both of which set the pool to min 0 / max 0. A pool capped at zero now renders replicas: 0. Raising maxReplicas drops the field again, and the autoscaler brings the pool back to its minimum. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
This commit is contained in:
7 files changed
+29
-5
No files matched your search
@@ -36,7 +36,7 @@ The pool's Kubernetes minor (`version`) may lag the cluster's during an upgrade
|
||||
| Name | Description | Type | Value |
|
||||
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ----------- |
|
||||
| `minReplicas` | Minimum number of replicas in this pool. Used as the cluster-autoscaler floor. | `int` | `0` |
|
||||
| `maxReplicas` | Maximum number of replicas in this pool. Used as the cluster-autoscaler ceiling. | `int` | `10` |
|
||||
| `maxReplicas` | Maximum number of replicas in this pool. Used as the cluster-autoscaler ceiling. 0 pauses the pool: its workers are scaled down to zero. | `int` | `10` |
|
||||
| `instanceType` | 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. | `string` | `u1.medium` |
|
||||
| `diskSize` | System disk size for the worker VM. Carries the Talos OS image, kubelet state, containerd image cache, and any local-path PVCs. How the OS image reaches the disk follows this pool's `osImage`: the default and `osImage.factory` stream the Image Factory raw artifact in over HTTP, while `osImage.builtin` makes the disk a storage-layer CDI clone of a shared golden image, with no HTTP fetch. A `builtin` pool must keep diskSize at or above the golden's storage size (6Gi in the shipped worker image catalog), because a CDI clone target cannot be smaller than its source -- the chart rejects a smaller value at render time rather than letting the clone stall. Sizing a `builtin` pool also has to allow for transient headroom the finished disk does not show: CDI populates a larger target by cloning the golden at the source size and then growing it, so a worker being provisioned occupies a temporary clone PVC at the golden's size on top of this diskSize, and both are multiplied by the replica count of a replicated StorageClass. The golden itself is a separate one-time cost for the whole cluster, not a per-worker one. So the peak is the golden, plus `diskSize + golden storage` for each worker cloning at that moment. A pool whose storage backend cannot spare that peak does not fail: the clone waits for space, the VM never boots, and the reason is visible only in the storage layer's own events. Has no effect on `substrate: proxmox`, where the worker disk is a clone of the VM template's disk and keeps its size. | `quantity` | `20Gi` |
|
||||
| `roles` | List of node roles. Each role `r` labels nodes with `node-role.kubernetes.io/<r>`. Use `[ingress-nginx]` for a pool that hosts the tenant ingress-nginx controller. | `[]string` | `[]` |
|
||||
|
||||
@@ -1099,6 +1099,16 @@ spec:
|
||||
# action until the autoscaler notices unschedulable Pods and
|
||||
# scales back up — a real disruption window on every routine
|
||||
# platform bump.
|
||||
#
|
||||
# The one exception is a pool capped at zero: maxReplicas 0 pauses the
|
||||
# pool, the update-time clamp above did not bring a running pool down to
|
||||
# it, and the autoscaler only removes nodes it finds unneeded. So a paused
|
||||
# pool renders `replicas: 0` explicitly. Raising maxReplicas again drops
|
||||
# the field, CAPI keeps the live 0 and the autoscaler brings the pool
|
||||
# back up to min-size.
|
||||
{{- if eq (int $group.maxReplicas) 0 }}
|
||||
replicas: 0
|
||||
{{- end }}
|
||||
{{- /* maxUnavailable 0 makes a rollout (instance type, image, version)
|
||||
wait for each replacement Machine to be up before draining an old
|
||||
one; with 1, a one-node pool lost its only node until the new one
|
||||
|
||||
@@ -61,6 +61,20 @@ tests:
|
||||
- notExists:
|
||||
path: spec.replicas
|
||||
|
||||
- it: renders replicas 0 for a pool paused with maxReplicas 0
|
||||
set:
|
||||
maxReplicas: 0
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: MachineDeployment
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.replicas
|
||||
value: 0
|
||||
- equal:
|
||||
path: metadata.annotations["cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size"]
|
||||
value: "0"
|
||||
|
||||
# The TalosConfigTemplate spec is immutable, so the object can only ever be
|
||||
# created, never updated: the name carries a content hash of the machine config
|
||||
# it holds (cozystack/cozystack#3515). The Job in talos-reconcile-job.yaml
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
"default": 0
|
||||
},
|
||||
"maxReplicas": {
|
||||
"description": "Maximum number of replicas in this pool. Used as the cluster-autoscaler ceiling.",
|
||||
"description": "Maximum number of replicas in this pool. Used as the cluster-autoscaler ceiling. 0 pauses the pool: its workers are scaled down to zero.",
|
||||
"type": "integer",
|
||||
"default": 10
|
||||
},
|
||||
|
||||
@@ -67,7 +67,7 @@ storageClass: replicated
|
||||
## @param {int} minReplicas=0 - Minimum number of replicas in this pool. Used as the cluster-autoscaler floor.
|
||||
minReplicas: 0
|
||||
|
||||
## @param {int} maxReplicas=10 - Maximum number of replicas in this pool. Used as the cluster-autoscaler ceiling.
|
||||
## @param {int} maxReplicas=10 - Maximum number of replicas in this pool. Used as the cluster-autoscaler ceiling. 0 pauses the pool: its workers are scaled down to zero.
|
||||
maxReplicas: 10
|
||||
|
||||
## @param {string} instanceType="u1.medium" - 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.
|
||||
|
||||
Reference in new issue
Block a user