CAPI Integration¶
How 5-Spot integrates with Cluster API (CAPI) for machine lifecycle management.
Overview¶
5-Spot leverages CAPI's infrastructure abstraction to manage physical machines:
CAPI Resources¶
Machine¶
5-Spot creates CAPI Machine resources:
apiVersion: cluster.x-k8s.io/v1beta2
kind: Machine
metadata:
# The Machine, the bootstrap object and the infrastructure object are all
# named after the ScheduledMachine.
name: scheduled-machine
namespace: default
labels:
cluster.x-k8s.io/cluster-name: my-cluster
5spot.finos.org/scheduled-machine: scheduled-machine
ownerReferences:
- apiVersion: 5spot.finos.org/v1beta1
kind: ScheduledMachine
name: scheduled-machine
uid: 6f1c2b8e-0d4a-4c1e-9b7a-2f3e4d5c6b7a # the ScheduledMachine's own uid
controller: true
blockOwnerDeletion: true
spec:
clusterName: my-cluster
bootstrap:
configRef:
apiGroup: bootstrap.cluster.x-k8s.io
kind: KubeadmConfig
name: scheduled-machine
infrastructureRef:
apiGroup: infrastructure.cluster.x-k8s.io
kind: BareMetalMachine
name: scheduled-machine
The reference shape follows the contract version, not just the version
string. From v1beta2 on, CAPI references are
ContractVersionedObjectReference: apiGroup + kind + name, with no
version and no namespace (a reference is always namespace-local). On v1beta1
and older the same two fields are a core ObjectReference instead:
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfig
name: worker-bootstrap
namespace: default
5-Spot picks the shape from the version it is creating the Machine at, so you
never write either one by hand. See ADR
0017.
Bootstrap Configuration¶
Inline bootstrap provider spec — 5-Spot creates this resource when the schedule window opens:
bootstrapSpec:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
kind: K0sWorkerConfig
spec:
version: v1.30.0+k0s.0
Infrastructure Specification¶
Inline infrastructure provider spec — 5-Spot creates this resource when the schedule window opens:
infrastructureSpec:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: RemoteMachine
spec:
address: 192.168.1.100
port: 22
user: admin
Supported Providers¶
5-Spot works with any CAPI infrastructure provider:
| Provider | Use Case |
|---|---|
| Metal3 | Bare metal via Ironic |
| Packet/Equinix | Cloud bare metal |
| vSphere | VMware virtual machines |
| AWS | EC2 instances |
| Azure | Azure VMs |
| GCP | GCE instances |
Machine Creation Flow¶
CAPI API version (passthrough). The
Machine5-Spot creates is always in the fixedcluster.x-k8s.iogroup, but its version is not hardcoded — it follows the version component of yourbootstrapSpec.apiVersion. Declarebootstrap.cluster.x-k8s.io/v1beta1and 5-Spot creates (and deletes) av1beta1Machine; declare…/v1beta2and it usesv1beta2, so the Machine shares one CAPI contract version with your bootstrap and infrastructure objects. For watching and reading Machines the controller uses the version the cluster serves (discovered at startup) and requires Cluster API to be installed — see Configuration → CAPI Machine API version. Thecluster.x-k8s.io/v1beta2shown in the examples above is therefore one valid choice, not a fixed requirement.
Machine Deletion Flow¶
Configuration Examples¶
k0smotron / k0s¶
spec:
clusterName: k0s-cluster
bootstrapSpec:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
kind: K0sWorkerConfig
spec:
version: v1.30.0+k0s.0
infrastructureSpec:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: RemoteMachine
spec:
address: 192.168.1.100
port: 22
user: admin
Metal3¶
spec:
clusterName: metal3-cluster
bootstrapSpec:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
kind: KubeadmConfig
spec:
joinConfiguration:
# v1beta2 requires nodeRegistration to set at least one field; an
# empty object is rejected.
nodeRegistration:
name: "{{ ds.meta_data.name }}"
infrastructureSpec:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: Metal3Machine
spec:
image:
url: http://example.com/ubuntu.img
checksum: sha256:abc123
Error Handling¶
Infrastructure Provisioning Failure¶
- ScheduledMachine enters
Errorphase - Condition updated with error details
- Automatic retry with backoff
Bootstrap Failure¶
- CAPI handles bootstrap retries
- 5-Spot monitors Machine status
- Propagates errors to ScheduledMachine status
Node Join Failure¶
- Machine marked as not ready
- ScheduledMachine reflects unhealthy state
- Manual intervention may be required
Related¶
- Architecture - System design
- ScheduledMachine - CRD specification
- Troubleshooting - Common issues