Skip to content

Commit 4c249d0

Browse files
committed
Implement devmachinepool
1 parent eaf086b commit 4c249d0

15 files changed

+1964
-1
lines changed
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/*
2+
Copyright 2026 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta2
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
22+
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
23+
)
24+
25+
const (
26+
// DevMachinePoolFinalizer allows ReconcileDevMachinePool to clean up resources.
27+
DevMachinePoolFinalizer = "devmachinepool.infrastructure.cluster.x-k8s.io"
28+
)
29+
30+
const (
31+
// ReplicasReadyCondition reports an aggregate of current status of the replicas controlled by the MachinePool.
32+
ReplicasReadyCondition string = "ReplicasReady"
33+
34+
// ReplicasReadyReason surfaces when the DevMachinePool ReplicasReadyConditio is met.
35+
ReplicasReadyReason string = clusterv1.ReadyReason
36+
)
37+
38+
// DevMachinePool's conditions that apply to all the supported backends.
39+
40+
// DevMachinePool's Ready condition and corresponding reasons.
41+
const (
42+
// DevMachinePoolReadyCondition is true if
43+
// - The DevMachinePool's is using a docker backend and ReplicasReadyCondition is true.
44+
DevMachinePoolReadyCondition = clusterv1.ReadyCondition
45+
46+
// DevMachinePoolReadyReason surfaces when the DevMachinePool readiness criteria is met.
47+
DevMachinePoolReadyReason = clusterv1.ReadyReason
48+
49+
// DevMachinePoolNotReadyReason surfaces when the DevMachinePool readiness criteria is not met.
50+
DevMachinePoolNotReadyReason = clusterv1.NotReadyReason
51+
52+
// DevMachinePoolReadyUnknownReason surfaces when at least one DevMachinePool readiness criteria is unknown
53+
// and no DevMachinePool readiness criteria is not met.
54+
DevMachinePoolReadyUnknownReason = clusterv1.ReadyUnknownReason
55+
)
56+
57+
// +kubebuilder:resource:path=devmachinepools,scope=Namespaced,categories=cluster-api
58+
// +kubebuilder:storageversion
59+
// +kubebuilder:object:root=true
60+
// +kubebuilder:subresource:status
61+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of DevMachinePool"
62+
63+
// DevMachinePool is the Schema for the devmachinepools API.
64+
type DevMachinePool struct {
65+
metav1.TypeMeta `json:",inline"`
66+
metav1.ObjectMeta `json:"metadata,omitempty"`
67+
68+
Spec DevMachinePoolSpec `json:"spec,omitempty"`
69+
Status DevMachinePoolStatus `json:"status,omitempty"`
70+
}
71+
72+
// +kubebuilder:object:root=true
73+
74+
// DevMachinePoolList contains a list of DevMachinePool.
75+
type DevMachinePoolList struct {
76+
metav1.TypeMeta `json:",inline"`
77+
metav1.ListMeta `json:"metadata,omitempty"`
78+
Items []DevMachinePool `json:"items"`
79+
}
80+
81+
// DevMachinePoolSpec defines the desired state of DevMachinePool.
82+
type DevMachinePoolSpec struct {
83+
// ProviderID is the identification ID of the Machine Pool
84+
// +optional
85+
ProviderID string `json:"providerID,omitempty"`
86+
87+
// ProviderIDList is the list of identification IDs of machine instances managed by this Machine Pool
88+
// +optional
89+
ProviderIDList []string `json:"providerIDList,omitempty"`
90+
91+
// Template contains the details used to build a replica machine within the Machine Pool
92+
// +optional
93+
Template DevMachinePoolBackendTemplate `json:"template"`
94+
}
95+
96+
// DevMachinePoolBackendTemplate defines backends for a DevMachinePool.
97+
type DevMachinePoolBackendTemplate struct {
98+
// docker defines a backend for a DevMachine using docker containers.
99+
// +optional
100+
Docker *DockerMachinePoolMachineTemplate `json:"docker,omitempty"`
101+
}
102+
103+
// DevMachinePoolStatus defines the observed state of DevMachinePool.
104+
type DevMachinePoolStatus struct {
105+
// conditions represents the observations of a DevMachinePool's current state.
106+
// Known condition types are Ready, ReplicasReady, Resized, ReplicasReady.
107+
// +optional
108+
// +listType=map
109+
// +listMapKey=type
110+
// +kubebuilder:validation:MaxItems=32
111+
Conditions []metav1.Condition `json:"conditions,omitempty"`
112+
113+
// Ready denotes that the machine pool is ready
114+
// +optional
115+
Ready bool `json:"ready"`
116+
117+
// Replicas is the most recently observed number of replicas.
118+
// +optional
119+
Replicas int32 `json:"replicas"`
120+
121+
// The generation observed by the deployment controller.
122+
// +optional
123+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
124+
125+
// InfrastructureMachineKind is the kind of the infrastructure resources behind MachinePool Machines.
126+
// +optional
127+
InfrastructureMachineKind string `json:"infrastructureMachineKind,omitempty"`
128+
129+
// Instances contains the status for each instance in the pool
130+
// +optional
131+
Instances []DevMachinePoolBackendInstanceStatus `json:"instances,omitempty"`
132+
}
133+
134+
// DevMachinePoolBackendInstanceStatus contains status information about a DevMachinePool instances.
135+
type DevMachinePoolBackendInstanceStatus struct {
136+
// docker define backend status for a DevMachine for a machine using docker containers.
137+
// +optional
138+
Docker *DockerMachinePoolInstanceStatus `json:"docker,omitempty"`
139+
}
140+
141+
// GetConditions returns the set of conditions for this object.
142+
func (d *DevMachinePool) GetConditions() []metav1.Condition {
143+
return d.Status.Conditions
144+
}
145+
146+
// SetConditions sets conditions for an API object.
147+
func (d *DevMachinePool) SetConditions(conditions []metav1.Condition) {
148+
d.Status.Conditions = conditions
149+
}
150+
151+
func init() {
152+
objectTypes = append(objectTypes, &DevMachinePool{}, &DevMachinePoolList{})
153+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
Copyright 2026 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta2
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
22+
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
23+
)
24+
25+
// +kubebuilder:object:root=true
26+
// +kubebuilder:resource:path=devmachinepooltemplates,scope=Namespaced,categories=cluster-api
27+
// +kubebuilder:storageversion
28+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of DevMachinePoolTemplate"
29+
30+
// DevMachinePoolTemplate is the Schema for the devmachinepooltemplates API.
31+
type DevMachinePoolTemplate struct {
32+
metav1.TypeMeta `json:",inline"`
33+
metav1.ObjectMeta `json:"metadata,omitempty"`
34+
35+
Spec DevMachinePoolTemplateSpec `json:"spec,omitempty"`
36+
}
37+
38+
// +kubebuilder:object:root=true
39+
40+
// DevMachinePoolTemplateList contains a list of DevMachinePoolTemplate.
41+
type DevMachinePoolTemplateList struct {
42+
metav1.TypeMeta `json:",inline"`
43+
metav1.ListMeta `json:"metadata,omitempty"`
44+
Items []DevMachinePoolTemplate `json:"items"`
45+
}
46+
47+
// DevMachinePoolTemplateSpec defines the desired state of DevMachinePoolTemplate.
48+
type DevMachinePoolTemplateSpec struct {
49+
Template DevMachinePoolTemplateResource `json:"template"`
50+
}
51+
52+
// DevMachinePoolTemplateResource describes the data needed to create a DevMachine from a template.
53+
type DevMachinePoolTemplateResource struct {
54+
// Standard object's metadata.
55+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
56+
// +optional
57+
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty,omitzero"`
58+
59+
Spec DevMachinePoolSpec `json:"spec"`
60+
}
61+
62+
func init() {
63+
objectTypes = append(objectTypes, &DevMachinePoolTemplate{}, &DevMachinePoolTemplateList{})
64+
}

0 commit comments

Comments
 (0)