Skip to content

Commit 7f7a168

Browse files
Deprecate NoCloudProvider and add CloudProviderEnabled
Signed-off-by: Muhammad Adil Ghaffar <[email protected]>
1 parent 476b7e1 commit 7f7a168

File tree

13 files changed

+51
-14
lines changed

13 files changed

+51
-14
lines changed

api/v1beta1/metal3cluster_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,16 @@ type Metal3ClusterSpec struct {
3737
// Determines if the cluster is not to be deployed with an external cloud provider.
3838
// If set to true, CAPM3 will use node labels to set providerID on the kubernetes nodes.
3939
// If set to false, providerID is set on nodes by other entities and CAPM3 uses the value of the providerID on the m3m resource.
40+
//
41+
// Deprecated: This field is deprecated use cloudProviderEnabled instead
42+
//
4043
// +optional
4144
NoCloudProvider bool `json:"noCloudProvider,omitempty"`
45+
// Determines if the cluster is to be deployed with an external cloud provider.
46+
// If set to false, CAPM3 will use node labels to set providerID on the kubernetes nodes.
47+
// If set to true, providerID is set on nodes by other entities and CAPM3 uses the value of the providerID on the m3m resource.
48+
// +optional
49+
CloudProviderEnabled bool `json:"cloudProviderEnabled,omitempty"`
4250
}
4351

4452
// IsValid returns an error if the object is not valid, otherwise nil. The

baremetal/metal3machine_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ func (m *MachineManager) SetNodeProviderID(ctx context.Context, providerIDOnM3M
12951295
m.Log.Info(errMessage)
12961296
return WithTransientError(errors.New(errMessage), requeueAfter)
12971297
}
1298-
if !m.Metal3Cluster.Spec.NoCloudProvider && matchingNodesCount == 0 {
1298+
if (!m.Metal3Cluster.Spec.NoCloudProvider || m.Metal3Cluster.Spec.CloudProviderEnabled) && matchingNodesCount == 0 {
12991299
// The node could either be still running cloud-init or
13001300
// kubernetes has not set the node.spec.ProviderID field yet.
13011301
errMessage := "Some target nodes do not have spec.providerID field set yet, requeuing"

baremetal/metal3machine_manager_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,14 +2627,14 @@ var _ = Describe("Metal3Machine manager", func() {
26272627

26282628
machineMgr, err := NewMachineManager(fakeClient, newCluster(clusterName),
26292629
newMetal3Cluster(metal3ClusterName, bmcOwnerRef,
2630-
&infrav1.Metal3ClusterSpec{NoCloudProvider: true}, nil,
2630+
&infrav1.Metal3ClusterSpec{NoCloudProvider: true, CloudProviderEnabled: false}, nil,
26312631
),
26322632
&clusterv1.Machine{}, &infrav1.Metal3Machine{}, logr.Discard(),
26332633
)
26342634
if tc.M3MHasHostAnnotation {
26352635
machineMgr, err = NewMachineManager(fakeClient, newCluster(clusterName),
26362636
newMetal3Cluster(metal3ClusterName, bmcOwnerRef,
2637-
&infrav1.Metal3ClusterSpec{NoCloudProvider: true}, nil,
2637+
&infrav1.Metal3ClusterSpec{NoCloudProvider: true, CloudProviderEnabled: false}, nil,
26382638
),
26392639
&clusterv1.Machine{}, &infrav1.Metal3Machine{
26402640
ObjectMeta: metav1.ObjectMeta{
@@ -2731,7 +2731,7 @@ var _ = Describe("Metal3Machine manager", func() {
27312731
M3MHasHostAnnotation: true,
27322732
}),
27332733
)
2734-
DescribeTable("Test SetNodeProviderID with noCloudProvider set to false",
2734+
DescribeTable("Test SetNodeProviderID with CloudProviderEnabled set to true",
27352735
func(tc testCaseSetNodePoviderID) {
27362736
BMHHost := newBareMetalHost(baremetalhostName, nil, bmov1alpha1.StateNone, nil, false, "metadata", false, tc.HostID)
27372737
fakeClient := fake.NewClientBuilder().WithScheme(s).WithObjects(BMHHost).Build()
@@ -2744,7 +2744,7 @@ var _ = Describe("Metal3Machine manager", func() {
27442744

27452745
machineMgr, err := NewMachineManager(fakeClient, newCluster(clusterName),
27462746
newMetal3Cluster(metal3ClusterName, bmcOwnerRef,
2747-
&infrav1.Metal3ClusterSpec{NoCloudProvider: false}, nil,
2747+
&infrav1.Metal3ClusterSpec{NoCloudProvider: false, CloudProviderEnabled: true}, nil,
27482748
),
27492749
&clusterv1.Machine{}, &infrav1.Metal3Machine{
27502750
ObjectMeta: metav1.ObjectMeta{

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ spec:
6868
spec:
6969
description: Metal3ClusterSpec defines the desired state of Metal3Cluster.
7070
properties:
71+
cloudProviderEnabled:
72+
description: |-
73+
Determines if the cluster is to be deployed with an external cloud provider.
74+
If set to false, CAPM3 will use node labels to set providerID on the kubernetes nodes.
75+
If set to true, providerID is set on nodes by other entities and CAPM3 uses the value of the providerID on the m3m resource.
76+
type: boolean
7177
controlPlaneEndpoint:
7278
description: ControlPlaneEndpoint represents the endpoint used to
7379
communicate with the control plane.
@@ -87,6 +93,8 @@ spec:
8793
Determines if the cluster is not to be deployed with an external cloud provider.
8894
If set to true, CAPM3 will use node labels to set providerID on the kubernetes nodes.
8995
If set to false, providerID is set on nodes by other entities and CAPM3 uses the value of the providerID on the m3m resource.
96+
97+
Deprecated: This field is deprecated use cloudProviderEnabled instead
9098
type: boolean
9199
type: object
92100
status:

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ spec:
5151
spec:
5252
description: Metal3ClusterSpec defines the desired state of Metal3Cluster.
5353
properties:
54+
cloudProviderEnabled:
55+
description: |-
56+
Determines if the cluster is to be deployed with an external cloud provider.
57+
If set to false, CAPM3 will use node labels to set providerID on the kubernetes nodes.
58+
If set to true, providerID is set on nodes by other entities and CAPM3 uses the value of the providerID on the m3m resource.
59+
type: boolean
5460
controlPlaneEndpoint:
5561
description: ControlPlaneEndpoint represents the endpoint
5662
used to communicate with the control plane.
@@ -72,6 +78,8 @@ spec:
7278
Determines if the cluster is not to be deployed with an external cloud provider.
7379
If set to true, CAPM3 will use node labels to set providerID on the kubernetes nodes.
7480
If set to false, providerID is set on nodes by other entities and CAPM3 uses the value of the providerID on the m3m resource.
81+
82+
Deprecated: This field is deprecated use cloudProviderEnabled instead
7583
type: boolean
7684
type: object
7785
required:

controllers/suite_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ func bmcSpec() *infrav1.Metal3ClusterSpec {
169169
Port: 6443,
170170
},
171171
NoCloudProvider: true,
172+
CloudProviderEnabled: false,
172173
}
173174
}
174175

docs/api.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@ cluster on Baremetal. It currently has two specification fields :
8080
8181
- **controlPlaneEndpoint**: contains the target cluster API server address and
8282
port
83-
- **noCloudProvider**: (true/false) Whether the cluster will not be deployed
83+
- **noCloudProvider(Deprecated use CloudProviderEnabled)**: (true/false) Whether the cluster will not be deployed
8484
with an external cloud provider. If set to true, CAPM3 will patch the target
8585
cluster node objects to add a providerID. This will allow the CAPI process to
8686
continue even if the cluster is deployed without cloud provider.
87+
- **CloudProviderEnabled**: (true/false) Whether the cluster will be deployed
88+
with an external cloud provider. If set to false, CAPM3 will patch the target
89+
cluster node objects to add a providerID. This will allow the CAPI process to
90+
continue even if the cluster is deployed without cloud provider.
8791
8892
Example metal3cluster :
8993
@@ -97,7 +101,8 @@ spec:
97101
controlPlaneEndpoint:
98102
host: 192.168.111.249
99103
port: 6443
100-
noCloudProvider: true
104+
noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead
105+
cloudProviderEnabled: false
101106
```
102107
103108
## KubeadmControlPlane

docs/architecture.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ metadata:
121121
name: test1
122122
spec:
123123
apiEndpoint: https://192.168.111.249:6443
124-
noCloudProvider: true
124+
noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead
125+
cloudProviderEnabled: false
125126
```
126127
127128
Metal3Cluster, after reconciliation
@@ -142,7 +143,8 @@ metadata:
142143
|----------------------------------------------------------------------------|
143144
spec:
144145
apiEndpoint: https://192.168.111.249:6443
145-
noCloudProvider: true
146+
noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead
147+
cloudProviderEnabled: false
146148
status:
147149
apiEndpoints:
148150
- host: 192.168.111.249

examples/cluster/cluster.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ metadata:
3030
name: ${CLUSTER_NAME}
3131
namespace: ${NAMESPACE}
3232
spec:
33+
noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead
34+
cloudProviderEnabled: false
3335
controlPlaneEndpoint:
3436
host: ${CLUSTER_APIENDPOINT_HOST}
3537
port: ${CLUSTER_APIENDPOINT_PORT}
36-
noCloudProvider: true

examples/clusterctl-templates/clusterctl-cluster.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ spec:
3030
controlPlaneEndpoint:
3131
host: ${CLUSTER_APIENDPOINT_HOST}
3232
port: ${CLUSTER_APIENDPOINT_PORT}
33-
noCloudProvider: true
33+
noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead
34+
cloudProviderEnabled: false
3435
---
3536
kind: KubeadmControlPlane
3637
apiVersion: controlplane.cluster.x-k8s.io/v1beta1

0 commit comments

Comments
 (0)