Skip to content

Commit c68214e

Browse files
committed
Add FailureDomain to M3Cluster and Machine
Signed-off-by: Steven Fitzpatrick <[email protected]>
1 parent 496bfb4 commit c68214e

8 files changed

+84
-7
lines changed

api/v1alpha5/zz_generated.conversion.go

Lines changed: 24 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/metal3cluster_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ type Metal3ClusterStatus struct {
7676
// +optional
7777
FailureMessage *string `json:"failureMessage,omitempty"`
7878

79+
// FailureDomains specifies the failure domains available in the cluster.
80+
// This will be used by Cluster API to try and spread the machines across failure domains
81+
// +optional
82+
FailureDomains clusterv1.FailureDomains `json:"failureDomains,omitempty"`
83+
7984
// Ready denotes that the Metal3 cluster (infrastructure) is ready. In
8085
// Baremetal case, it does not mean anything for now as no infrastructure
8186
// steps need to be performed. Required by Cluster API. Set to True by the

api/v1beta1/metal3machine_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ type Metal3MachineSpec struct {
7676
// +kubebuilder:validation:Enum:=metadata;disabled
7777
// +optional
7878
AutomatedCleaningMode *string `json:"automatedCleaningMode,omitempty"`
79+
80+
// FailureDomain is the failure domain the machine will be created in.
81+
// +optional
82+
FailureDomain *string `json:"failureDomain,omitempty"`
7983
}
8084

8185
// Metal3MachineStatus defines the observed state of Metal3Machine.

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

baremetal/metal3machine_manager.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ const (
7171
ProviderIDPrefix = "metal3://"
7272
// ProviderLabelPrefix is a label prefix for ProviderID.
7373
ProviderLabelPrefix = "metal3.io/uuid"
74+
// FailureDomainLabelPrefix is a label prefix for FailureDomains
75+
FailureDomainLabelPrefix = "infrastructure.cluster.x-k8s.io/failure-domain"
7476
)
7577

7678
var (
@@ -889,6 +891,14 @@ func (m *MachineManager) chooseHost(ctx context.Context) (*bmov1alpha1.BareMetal
889891
}
890892
reqs = append(reqs, *r)
891893
}
894+
if m.Metal3Machine.Spec.FailureDomain != nil {
895+
r, err := labels.NewRequirement(FailureDomainLabelPrefix, selection.Equals, []string{*m.Metal3Machine.Spec.FailureDomain})
896+
if err != nil {
897+
m.Log.Error(err, "Failed to create FailureDomain MatchLabel requirement, not choosing host")
898+
return nil, nil, err
899+
}
900+
reqs = append(reqs, *r)
901+
}
892902
labelSelector = labelSelector.Add(reqs...)
893903

894904
availableHosts := []*bmov1alpha1.BareMetalHost{}

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,27 @@ spec:
229229
- type
230230
type: object
231231
type: array
232+
failureDomains:
233+
additionalProperties:
234+
description: FailureDomainSpec is the Schema for Cluster API failure
235+
domains. It allows controllers to understand how many failure
236+
domains a cluster can optionally span across.
237+
properties:
238+
attributes:
239+
additionalProperties:
240+
type: string
241+
description: Attributes is a free form map of attributes an
242+
infrastructure provider might use or require.
243+
type: object
244+
controlPlane:
245+
description: ControlPlane determines if this failure domain
246+
is suitable for use by control plane machines.
247+
type: boolean
248+
type: object
249+
description: FailureDomains specifies the failure domains available
250+
in the cluster. This will be used by Cluster API to try and spread
251+
the machines across failure domains
252+
type: object
232253
failureMessage:
233254
description: FailureMessage indicates that there is a fatal problem
234255
reconciling the state, and will be set to a descriptive error message.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,10 @@ spec:
468468
type: string
469469
type: object
470470
x-kubernetes-map-type: atomic
471+
failureDomain:
472+
description: FailureDomain is the failure domain the machine will
473+
be created in.
474+
type: string
471475
hostSelector:
472476
description: HostSelector specifies matching criteria for labels on
473477
BareMetalHosts. This is used to limit the set of BareMetalHost objects

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ spec:
323323
type: string
324324
type: object
325325
x-kubernetes-map-type: atomic
326+
failureDomain:
327+
description: FailureDomain is the failure domain the machine
328+
will be created in.
329+
type: string
326330
hostSelector:
327331
description: HostSelector specifies matching criteria for
328332
labels on BareMetalHosts. This is used to limit the set

0 commit comments

Comments
 (0)