Skip to content

Commit 0241cb3

Browse files
committed
feat: machine controller draft #3
1 parent dc188ec commit 0241cb3

8 files changed

+445
-19
lines changed

api/v1alpha1/metalstackcluster_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ type Firewall struct {
8888

8989
// MetalStackClusterStatus defines the observed state of MetalStackCluster.
9090
type MetalStackClusterStatus struct {
91+
// Ready denotes that the cluster is ready.
92+
Ready bool `json:"ready"`
93+
9194
// FailureReason indicates that there is a fatal problem reconciling the
9295
// state, and will be set to a token value suitable for
9396
// programmatic interpretation.
@@ -99,10 +102,7 @@ type MetalStackClusterStatus struct {
99102
// +optional
100103
FailureMessage *string `json:"failureMessage,omitempty"`
101104

102-
// Ready denotes that the cluster is ready.
103-
Ready bool `json:"ready"`
104-
105-
// Conditions defines current service state of the Metal3Cluster.
105+
// Conditions defines current service state of the MetalStackCluster.
106106
// +optional
107107
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
108108
}

api/v1alpha1/metalstackmachine_types.go

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,21 @@ package v1alpha1
1818

1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
22+
capierrors "sigs.k8s.io/cluster-api/errors"
2123
)
2224

2325
const (
2426
// MachineFinalizer allows to clean up resources associated with before removing it from the apiserver.
2527
MachineFinalizer = "metal-stack.infrastructure.cluster.x-k8s.io/machine"
2628
)
2729

28-
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
29-
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
30-
3130
// MetalStackMachineSpec defines the desired state of MetalStackMachine.
3231
type MetalStackMachineSpec struct {
32+
// ProviderID points to the metal-stack machine ID.
33+
// +optional
34+
ProviderID string `json:"providerID"`
35+
3336
// Image is the operating system to deploy on the machine
3437
Image string `json:"image"`
3538

@@ -39,8 +42,26 @@ type MetalStackMachineSpec struct {
3942

4043
// MetalStackMachineStatus defines the observed state of MetalStackMachine.
4144
type MetalStackMachineStatus struct {
42-
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
43-
// Important: Run "make" to regenerate code after modifying this file
45+
// Ready denotes that the cluster is ready.
46+
Ready bool `json:"ready"`
47+
48+
// FailureReason indicates that there is a fatal problem reconciling the
49+
// state, and will be set to a token value suitable for
50+
// programmatic interpretation.
51+
// +optional
52+
FailureReason *capierrors.ClusterStatusError `json:"failureReason,omitempty"`
53+
54+
// FailureMessage indicates that there is a fatal problem reconciling the
55+
// state, and will be set to a descriptive error message.
56+
// +optional
57+
FailureMessage *string `json:"failureMessage,omitempty"`
58+
59+
// Conditions defines current service state of the MetalStackCluster.
60+
// +optional
61+
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
62+
63+
// MachineAddresses contains all host names, external or internal IP addresses and external or internal DNS names.
64+
Addresses clusterv1.MachineAddresses `json:"addresses,omitempty"`
4465
}
4566

4667
// +kubebuilder:object:root=true

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ func main() {
167167
os.Exit(1)
168168
}
169169
if err = (&controller.MetalStackMachineReconciler{
170-
Client: mgr.GetClient(),
171-
Scheme: mgr.GetScheme(),
170+
MetalClient: metalClient,
171+
Client: mgr.GetClient(),
172+
Scheme: mgr.GetScheme(),
172173
}).SetupWithManager(mgr); err != nil {
173174
setupLog.Error(err, "unable to create controller", "controller", "MetalStackMachine")
174175
os.Exit(1)

config/crd/bases/infrastructure.cluster.x-k8s.io_inframachinetemplates.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ spec:
7474
description: Image is the operating system to deploy on the
7575
machine
7676
type: string
77+
providerID:
78+
description: ProviderID points to the metal-stack machine
79+
ID.
80+
type: string
7781
size:
7882
description: Size is the size of the machine
7983
type: string
@@ -84,6 +88,89 @@ spec:
8488
status:
8589
description: MetalStackMachineStatus defines the observed state
8690
of MetalStackMachine.
91+
properties:
92+
addresses:
93+
description: MachineAddresses contains all host names, external
94+
or internal IP addresses and external or internal DNS names.
95+
items:
96+
description: MachineAddress contains information for the
97+
node's address.
98+
properties:
99+
address:
100+
description: The machine address.
101+
type: string
102+
type:
103+
description: Machine address type, one of Hostname,
104+
ExternalIP, InternalIP, ExternalDNS or InternalDNS.
105+
type: string
106+
required:
107+
- address
108+
- type
109+
type: object
110+
type: array
111+
conditions:
112+
description: Conditions defines current service state of the
113+
MetalStackCluster.
114+
items:
115+
description: Condition defines an observation of a Cluster
116+
API resource operational state.
117+
properties:
118+
lastTransitionTime:
119+
description: |-
120+
Last time the condition transitioned from one status to another.
121+
This should be when the underlying condition changed. If that is not known, then using the time when
122+
the API field changed is acceptable.
123+
format: date-time
124+
type: string
125+
message:
126+
description: |-
127+
A human readable message indicating details about the transition.
128+
This field may be empty.
129+
type: string
130+
reason:
131+
description: |-
132+
The reason for the condition's last transition in CamelCase.
133+
The specific API may choose whether or not this field is considered a guaranteed API.
134+
This field may not be empty.
135+
type: string
136+
severity:
137+
description: |-
138+
Severity provides an explicit classification of Reason code, so the users or machines can immediately
139+
understand the current situation and act accordingly.
140+
The Severity field MUST be set only when Status=False.
141+
type: string
142+
status:
143+
description: Status of the condition, one of True, False,
144+
Unknown.
145+
type: string
146+
type:
147+
description: |-
148+
Type of condition in CamelCase or in foo.example.com/CamelCase.
149+
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
150+
can be useful (see .node.status.conditions), the ability to deconflict is important.
151+
type: string
152+
required:
153+
- lastTransitionTime
154+
- status
155+
- type
156+
type: object
157+
type: array
158+
failureMessage:
159+
description: |-
160+
FailureMessage indicates that there is a fatal problem reconciling the
161+
state, and will be set to a descriptive error message.
162+
type: string
163+
failureReason:
164+
description: |-
165+
FailureReason indicates that there is a fatal problem reconciling the
166+
state, and will be set to a token value suitable for
167+
programmatic interpretation.
168+
type: string
169+
ready:
170+
description: Ready denotes that the cluster is ready.
171+
type: boolean
172+
required:
173+
- ready
87174
type: object
88175
type: object
89176
required:

config/crd/bases/infrastructure.cluster.x-k8s.io_metalstackclusters.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ spec:
138138
description: MetalStackClusterStatus defines the observed state of MetalStackCluster.
139139
properties:
140140
conditions:
141-
description: Conditions defines current service state of the Metal3Cluster.
141+
description: Conditions defines current service state of the MetalStackCluster.
142142
items:
143143
description: Condition defines an observation of a Cluster API resource
144144
operational state.

config/crd/bases/infrastructure.cluster.x-k8s.io_metalstackmachines.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ spec:
4242
image:
4343
description: Image is the operating system to deploy on the machine
4444
type: string
45+
providerID:
46+
description: ProviderID points to the metal-stack machine ID.
47+
type: string
4548
size:
4649
description: Size is the size of the machine
4750
type: string
@@ -51,6 +54,87 @@ spec:
5154
type: object
5255
status:
5356
description: MetalStackMachineStatus defines the observed state of MetalStackMachine.
57+
properties:
58+
addresses:
59+
description: MachineAddresses contains all host names, external or
60+
internal IP addresses and external or internal DNS names.
61+
items:
62+
description: MachineAddress contains information for the node's
63+
address.
64+
properties:
65+
address:
66+
description: The machine address.
67+
type: string
68+
type:
69+
description: Machine address type, one of Hostname, ExternalIP,
70+
InternalIP, ExternalDNS or InternalDNS.
71+
type: string
72+
required:
73+
- address
74+
- type
75+
type: object
76+
type: array
77+
conditions:
78+
description: Conditions defines current service state of the MetalStackCluster.
79+
items:
80+
description: Condition defines an observation of a Cluster API resource
81+
operational state.
82+
properties:
83+
lastTransitionTime:
84+
description: |-
85+
Last time the condition transitioned from one status to another.
86+
This should be when the underlying condition changed. If that is not known, then using the time when
87+
the API field changed is acceptable.
88+
format: date-time
89+
type: string
90+
message:
91+
description: |-
92+
A human readable message indicating details about the transition.
93+
This field may be empty.
94+
type: string
95+
reason:
96+
description: |-
97+
The reason for the condition's last transition in CamelCase.
98+
The specific API may choose whether or not this field is considered a guaranteed API.
99+
This field may not be empty.
100+
type: string
101+
severity:
102+
description: |-
103+
Severity provides an explicit classification of Reason code, so the users or machines can immediately
104+
understand the current situation and act accordingly.
105+
The Severity field MUST be set only when Status=False.
106+
type: string
107+
status:
108+
description: Status of the condition, one of True, False, Unknown.
109+
type: string
110+
type:
111+
description: |-
112+
Type of condition in CamelCase or in foo.example.com/CamelCase.
113+
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
114+
can be useful (see .node.status.conditions), the ability to deconflict is important.
115+
type: string
116+
required:
117+
- lastTransitionTime
118+
- status
119+
- type
120+
type: object
121+
type: array
122+
failureMessage:
123+
description: |-
124+
FailureMessage indicates that there is a fatal problem reconciling the
125+
state, and will be set to a descriptive error message.
126+
type: string
127+
failureReason:
128+
description: |-
129+
FailureReason indicates that there is a fatal problem reconciling the
130+
state, and will be set to a token value suitable for
131+
programmatic interpretation.
132+
type: string
133+
ready:
134+
description: Ready denotes that the cluster is ready.
135+
type: boolean
136+
required:
137+
- ready
54138
type: object
55139
type: object
56140
served: true

0 commit comments

Comments
 (0)