Skip to content

Commit eed0fca

Browse files
committed
add scale from zero to contract docs
this change updates the infra machine contract docs to include a section on how to add the scale from zero fields.
1 parent 21be9a2 commit eed0fca

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

docs/book/src/developer/providers/contracts/infra-machine.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ repo or add an item to the agenda in the [Cluster API community meeting](https:/
6060
| [Multi tenancy] | No | Mandatory for clusterctl CLI support |
6161
| [Clusterctl support] | No | Mandatory for clusterctl CLI support |
6262
| [InfraMachine: pausing] | No | |
63+
| [InfraMachineTemplate: support cluster autoscaling from zero] | No | |
6364

6465
Note:
6566
- `All resources` refers to all the provider's resources "core" Cluster API interacts with;
@@ -491,6 +492,44 @@ Providers SHOULD implement the pause behaviour for every object with a reconcili
491492

492493
If implementing the pause behavior, providers SHOULD surface the paused status of an object using the Paused condition: `Status.Conditions[Paused]`.
493494

495+
### InfraMachineTemplate: support cluster autoscaling from zero
496+
497+
As described in the enhancement [Opt-in Autoscaling from Zero][Opt-in Autoscaling from Zero], providers may implement a capacity field in machine templates to inform the cluster autoscaler about the resources available on that machine type.
498+
499+
Building on the `FooMachineTemplate` example from above, this shows the addition of a status and capacity field:
500+
501+
```
502+
import corev1 "k8s.io/api/core/v1"
503+
504+
// FooMachineTemplate is the Schema for the foomachinetemplates API.
505+
type FooMachineTemplate struct {
506+
metav1.TypeMeta `json:",inline"`
507+
metav1.ObjectMeta `json:"metadata,omitempty"`
508+
509+
Spec FooMachineTemplateSpec `json:"spec,omitempty"`
510+
Status FooMachineTemplateStatus `json:"status,omitempty"`
511+
}
512+
513+
// FooMachineTemplateStatus defines the observed state of FooMachineTemplate.
514+
type FooMachineTemplateStatus struct {
515+
// Capacity defines the resource capacity for this machine.
516+
// This value is used for autoscaling from zero operations as defined in:
517+
// https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20210310-opt-in-autoscaling-from-zero.md
518+
// +optional
519+
Capacity corev1.ResourceList `json:"capacity,omitempty"`
520+
}
521+
```
522+
523+
When rendered to a manifest, the machine template status capacity field representing an instance with 500 megabytes of RAM, 1 CPU core, and 1 NVidia GPU would look like this:
524+
525+
```
526+
status:
527+
capacity:
528+
memory: 500mb
529+
cpu: "1"
530+
nvidia.com/gpu: "1"
531+
```
532+
494533
## Typical InfraMachine reconciliation workflow
495534

496535
A machine infrastructure provider must respond to changes to its InfraMachine resources. This process is
@@ -556,5 +595,7 @@ is implemented in InfraMachine controllers:
556595
[infrastructure Provider Security Guidance]: ../security-guidelines.md
557596
[Server Side Apply]: https://kubernetes.io/docs/reference/using-api/server-side-apply/
558597
[the DockerMachineTemplate webhook]: https://github.com/kubernetes-sigs/cluster-api/blob/main/test/infrastructure/docker/internal/webhooks/dockermachinetemplate_webhook.go
559-
[InfraMachine: pausing] #inframachine-pausing
560598
[Cluster API v1.11 migration notes]: ../migrations/v1.10-to-v1.11.md
599+
[Opt-in Autoscaling from Zero]: https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20210310-opt-in-autoscaling-from-zero.md
600+
[InfraMachine: pausing]: #inframachine-pausing
601+
[InfraMachineTemplate: support cluster autoscaling from zero]: #inframachinetemplate-support-cluster-autoscaling-from-zero

0 commit comments

Comments
 (0)