Skip to content

Commit d0cb4af

Browse files
committed
Update autoscaling from zero enhancement proposal with support for platform-aware autoscale from zero
This commit updates the contract between the cluster-autoscaler Cluster API provider and the infrastructure provider's controllers that reconcile the Infrastructure Machine Template to support platform-aware autoscale from 0 in clusters consisting of nodes heterogeneous in CPU architecture and OS. With this commit, the infrastructure providers implementing controllers to reconcile the status of their Infrastructure Machine Templates for supporting autoscale from 0 will be able to fill the status.nodeInfo stanza with additional information about the nodes. The status.nodeInfo stanza has type corev1.NodeSystemInfo to reflect the same content, the rendered nodes' objects would store in their status field. The cluster-autoscaler can use that information to build the node template labels `kubernetes.io/arch` and `kubernetes.io/os` if that information is present. Suppose the pending pods that trigger the cluster autoscaler have a node selector or a requiredDuringSchedulingIgnoredDuringExecution node affinity concerning the architecture or operating system of the node where they can execute. In that case, the autoscaler will be able to filter the nodes groups options according to the architecture or operating system requested by the pod. The users could already provide this information to the cluster autoscaler through the labels capacity annotation. However, there is no similar capability to support future labels/taints through information set by the reconcilers of the status of Infrastructure Machine Templates.
1 parent ccaea78 commit d0cb4af

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

docs/proposals/20210310-opt-in-autoscaling-from-zero.md

+54-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ node group. But, during a scale from zero situation (ie when a node group has ze
107107
autoscaler needs to acquire this information from the infrastructure provider.
108108

109109
An optional status field is proposed on the Infrastructure Machine Template which will be populated
110-
by infrastructure providers to contain the CPU, memory, and GPU capacities for machines described by that
111-
template. The cluster autoscaler will then utilize this information by reading the appropriate
110+
by infrastructure providers to contain the CPU, CPU architecture, memory, and GPU capacities for machines
111+
described by that template. The cluster autoscaler will then utilize this information by reading the appropriate
112112
infrastructure reference from the resource it is scaling (MachineSet or MachineDeployment).
113113

114114
A user may override the field in the associated infrastructure template by applying annotations to the
@@ -160,6 +160,10 @@ the template. Internally, this field will be represented by a Go `map` type uti
160160
for the keys and `k8s.io/apimachinery/pkg/api/resource.Quantity` as the values (similar to how resource
161161
limits and requests are handled for pods).
162162

163+
Additionally, the status field could contain information about the node, such as the architecture and
164+
operating system. This information is not required for the autoscaler to function, but it can be useful in
165+
scenarios where the autoscaler needs to make decisions for clusters with heterogeneous node groups in architecture, OS, or both.
166+
163167
It is worth mentioning that the Infrastructure Machine Templates are not usually reconciled by themselves.
164168
Each infrastructure provider will be responsible for determining the best implementation for adding the
165169
status field based on the information available on their platform.
@@ -175,6 +179,9 @@ const (
175179
// DockerMachineTemplateStatus defines the observed state of a DockerMachineTemplate
176180
type DockerMachineTemplateStatus struct {
177181
Capacity corev1.ResourceList `json:"capacity,omitempty"`
182+
183+
// +optional
184+
NodeInfo *platform.NodeInfo `json:"nodeInfo,omitempty"`
178185
}
179186
180187
// DockerMachineTemplate is the Schema for the dockermachinetemplates API.
@@ -188,6 +195,40 @@ type DockerMachineTemplate struct {
188195
```
189196
_Note: the `ResourceList` and `ResourceName` referenced are from k8s.io/api/core/v1`_
190197

198+
`platform.NodeInfo` is a struct that contains the architecture and operating system information of the node, to implement
199+
in the providers integration code.
200+
Its definition would look like this:
201+
202+
```go
203+
package platform
204+
205+
// Architecture represents the CPU architecture of the node. Its underlying type is a string.
206+
// Its underlying type is a string and its value can be any of amd64, arm64, s390x, ppc64le.
207+
// +kubebuilder:validation:Enum=amd64;arm64;s390x;ppc64le
208+
// +enum
209+
type Architecture string
210+
211+
// Architecture constants defined for clarity.
212+
const (
213+
ArchitectureAmd64 Architecture = "amd64"
214+
ArchitectureArm64 Architecture = "arm64"
215+
ArchitectureS390x Architecture = "s390x"
216+
ArchitecturePpc64le Architecture = "ppc64le"
217+
)
218+
219+
// NodeInfo contains information about the node's architecture and operating system.
220+
type NodeInfo struct {
221+
// architecture is the CPU architecture of the node.
222+
// Its underlying type is a string and its value can be any of amd64, arm64, s390x, ppc64le.
223+
// +optional
224+
Architecture Architecture `json:"architecture,omitempty"`
225+
// operatingSystem is a string representing the operating system of the node.
226+
// This may be a string like 'linux' or 'windows'.
227+
// +optional
228+
OperatingSystem string `json:"operatingSystem,omitempty"`
229+
}
230+
```
231+
191232
When used as a manifest, it would look like this:
192233

193234
```
@@ -204,8 +245,13 @@ status:
204245
memory: 500mb
205246
cpu: "1"
206247
nvidia.com/gpu: "1"
248+
nodeInfo:
249+
architecture: arm64
250+
operatingSystem: linux
207251
```
208252

253+
The information stored in the `status.nodeInfo` field will be used by the cluster autoscaler's scheduler simulator to determine the simulated node's labels `kubernetes.io/arch` and `kubernetes.io/os`. This logic will be implemented in the cluster autoscaler's ClusterAPI cloud provider code.
254+
209255
#### MachineSet and MachineDeployment Annotations
210256

211257
In cases where a user needs to provide specific resource information for a
@@ -229,6 +275,8 @@ metadata:
229275
capacity.cluster-autoscaler.kubernetes.io/memory: "500mb"
230276
capacity.cluster-autoscaler.kubernetes.io/cpu: "1"
231277
capacity.cluster-autoscaler.kubernetes.io/ephemeral-disk: "100Gi"
278+
node-info.cluster-autoscaler.kubernetes.io/architecture: "arm64"
279+
node-info.cluster-autoscaler.kubernetes.io/operating-system: "linux"
232280
```
233281
_Note: the annotations will be defined in the cluster autoscaler, not in cluster-api._
234282

@@ -246,6 +294,9 @@ metadata:
246294
capacity.cluster-autoscaler.kubernetes.io/taints: "key1=value1:NoSchedule,key2=value2:NoExecute"
247295
```
248296

297+
The `capacity.cluster-autoscaler.kubernetes.io/labels` annotation takes precedence over other sources when conflicts occur.
298+
For instance, if the `kubernetes.io/arch` label is specified in `capacity.cluster-autoscaler.kubernetes.io/labels`, its value supersedes that specified by `node-info.cluster-autoscaler.kubernetes.io/architecture`.
299+
249300
### Security Model
250301

251302
This feature will require the service account associated with the cluster autoscaler to have
@@ -318,6 +369,7 @@ office hours meeting:
318369

319370
## Implementation History
320371

372+
- [X] 05/08/2025: Updated proposal to enable architecture- and OS- aware auto-scale from 0
321373
- [X] 09/12/2024: Added section on Implementation Status
322374
- [X] 01/31/2023: Updated proposal to include annotation changes
323375
- [X] 06/10/2021: Proposed idea in an issue or [community meeting]

0 commit comments

Comments
 (0)