Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Deprecate NoCloudProvider and add CloudProviderEnabled #2108

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api/v1beta1/metal3cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,16 @@ type Metal3ClusterSpec struct {
// Determines if the cluster is not to be deployed with an external cloud provider.
// If set to true, CAPM3 will use node labels to set providerID on the kubernetes nodes.
// If set to false, providerID is set on nodes by other entities and CAPM3 uses the value of the providerID on the m3m resource.
//
// Deprecated: This field is deprecated use cloudProviderEnabled instead
//
// +optional
NoCloudProvider bool `json:"noCloudProvider,omitempty"`
// Determines if the cluster is to be deployed with an external cloud provider.
// If set to false, CAPM3 will use node labels to set providerID on the kubernetes nodes.
// If set to true, providerID is set on nodes by other entities and CAPM3 uses the value of the providerID on the m3m resource.
// +optional
CloudProviderEnabled bool `json:"cloudProviderEnabled,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add to the description that the default value is false, and that this takes precedence over NoCloudProvider?

}

// IsValid returns an error if the object is not valid, otherwise nil. The
Expand Down
2 changes: 1 addition & 1 deletion baremetal/metal3machine_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ func (m *MachineManager) SetNodeProviderID(ctx context.Context, providerIDOnM3M
m.Log.Info(errMessage)
return WithTransientError(errors.New(errMessage), requeueAfter)
}
if !m.Metal3Cluster.Spec.NoCloudProvider && matchingNodesCount == 0 {
if (!m.Metal3Cluster.Spec.NoCloudProvider || m.Metal3Cluster.Spec.CloudProviderEnabled) && matchingNodesCount == 0 {
// The node could either be still running cloud-init or
// kubernetes has not set the node.spec.ProviderID field yet.
errMessage := "Some target nodes do not have spec.providerID field set yet, requeuing"
Expand Down
8 changes: 4 additions & 4 deletions baremetal/metal3machine_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2627,14 +2627,14 @@ var _ = Describe("Metal3Machine manager", func() {

machineMgr, err := NewMachineManager(fakeClient, newCluster(clusterName),
newMetal3Cluster(metal3ClusterName, bmcOwnerRef,
&infrav1.Metal3ClusterSpec{NoCloudProvider: true}, nil,
&infrav1.Metal3ClusterSpec{NoCloudProvider: true, CloudProviderEnabled: false}, nil,
),
&clusterv1.Machine{}, &infrav1.Metal3Machine{}, logr.Discard(),
)
if tc.M3MHasHostAnnotation {
machineMgr, err = NewMachineManager(fakeClient, newCluster(clusterName),
newMetal3Cluster(metal3ClusterName, bmcOwnerRef,
&infrav1.Metal3ClusterSpec{NoCloudProvider: true}, nil,
&infrav1.Metal3ClusterSpec{NoCloudProvider: true, CloudProviderEnabled: false}, nil,
),
&clusterv1.Machine{}, &infrav1.Metal3Machine{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -2731,7 +2731,7 @@ var _ = Describe("Metal3Machine manager", func() {
M3MHasHostAnnotation: true,
}),
)
DescribeTable("Test SetNodeProviderID with noCloudProvider set to false",
DescribeTable("Test SetNodeProviderID with CloudProviderEnabled set to true",
func(tc testCaseSetNodePoviderID) {
BMHHost := newBareMetalHost(baremetalhostName, nil, bmov1alpha1.StateNone, nil, false, "metadata", false, tc.HostID)
fakeClient := fake.NewClientBuilder().WithScheme(s).WithObjects(BMHHost).Build()
Expand All @@ -2744,7 +2744,7 @@ var _ = Describe("Metal3Machine manager", func() {

machineMgr, err := NewMachineManager(fakeClient, newCluster(clusterName),
newMetal3Cluster(metal3ClusterName, bmcOwnerRef,
&infrav1.Metal3ClusterSpec{NoCloudProvider: false}, nil,
&infrav1.Metal3ClusterSpec{NoCloudProvider: false, CloudProviderEnabled: true}, nil,
),
&clusterv1.Machine{}, &infrav1.Metal3Machine{
ObjectMeta: metav1.ObjectMeta{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ spec:
spec:
description: Metal3ClusterSpec defines the desired state of Metal3Cluster.
properties:
cloudProviderEnabled:
description: |-
Determines if the cluster is to be deployed with an external cloud provider.
If set to false, CAPM3 will use node labels to set providerID on the kubernetes nodes.
If set to true, providerID is set on nodes by other entities and CAPM3 uses the value of the providerID on the m3m resource.
type: boolean
controlPlaneEndpoint:
description: ControlPlaneEndpoint represents the endpoint used to
communicate with the control plane.
Expand All @@ -87,6 +93,8 @@ spec:
Determines if the cluster is not to be deployed with an external cloud provider.
If set to true, CAPM3 will use node labels to set providerID on the kubernetes nodes.
If set to false, providerID is set on nodes by other entities and CAPM3 uses the value of the providerID on the m3m resource.

Deprecated: This field is deprecated use cloudProviderEnabled instead
type: boolean
type: object
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ spec:
spec:
description: Metal3ClusterSpec defines the desired state of Metal3Cluster.
properties:
cloudProviderEnabled:
description: |-
Determines if the cluster is to be deployed with an external cloud provider.
If set to false, CAPM3 will use node labels to set providerID on the kubernetes nodes.
If set to true, providerID is set on nodes by other entities and CAPM3 uses the value of the providerID on the m3m resource.
type: boolean
controlPlaneEndpoint:
description: ControlPlaneEndpoint represents the endpoint
used to communicate with the control plane.
Expand All @@ -72,6 +78,8 @@ spec:
Determines if the cluster is not to be deployed with an external cloud provider.
If set to true, CAPM3 will use node labels to set providerID on the kubernetes nodes.
If set to false, providerID is set on nodes by other entities and CAPM3 uses the value of the providerID on the m3m resource.

Deprecated: This field is deprecated use cloudProviderEnabled instead
type: boolean
type: object
required:
Expand Down
3 changes: 2 additions & 1 deletion controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ func bmcSpec() *infrav1.Metal3ClusterSpec {
Host: "192.168.111.249",
Port: 6443,
},
NoCloudProvider: true,
NoCloudProvider: true,
CloudProviderEnabled: false,
}
}

Expand Down
12 changes: 9 additions & 3 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,13 @@ cluster on Baremetal. It currently has two specification fields :

- **controlPlaneEndpoint**: contains the target cluster API server address and
port
- **noCloudProvider**: (true/false) Whether the cluster will not be deployed
with an external cloud provider. If set to true, CAPM3 will patch the target
- **noCloudProvider(Deprecated use CloudProviderEnabled)**: (true/false) Whether
the cluster will not be deployed with an external cloud provider. If set to
true, CAPM3 will patch the target cluster node objects to add a providerID.
This will allow the CAPI process to continue even if the cluster is deployed
without cloud provider.
- **CloudProviderEnabled**: (true/false) Whether the cluster will be deployed
with an external cloud provider. If set to false, CAPM3 will patch the target
cluster node objects to add a providerID. This will allow the CAPI process to
continue even if the cluster is deployed without cloud provider.

Expand All @@ -97,7 +102,8 @@ spec:
controlPlaneEndpoint:
host: 192.168.111.249
port: 6443
noCloudProvider: true
noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead
cloudProviderEnabled: false
```

## KubeadmControlPlane
Expand Down
6 changes: 4 additions & 2 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ metadata:
name: test1
spec:
apiEndpoint: https://192.168.111.249:6443
noCloudProvider: true
noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead
cloudProviderEnabled: false
```

Metal3Cluster, after reconciliation
Expand All @@ -142,7 +143,8 @@ metadata:
|----------------------------------------------------------------------------|
spec:
apiEndpoint: https://192.168.111.249:6443
noCloudProvider: true
noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead
cloudProviderEnabled: false
status:
apiEndpoints:
- host: 192.168.111.249
Expand Down
3 changes: 2 additions & 1 deletion examples/cluster/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ spec:
controlPlaneEndpoint:
host: ${CLUSTER_APIENDPOINT_HOST}
port: ${CLUSTER_APIENDPOINT_PORT}
noCloudProvider: true
noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead
cloudProviderEnabled: false
3 changes: 2 additions & 1 deletion examples/clusterctl-templates/clusterctl-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ spec:
controlPlaneEndpoint:
host: ${CLUSTER_APIENDPOINT_HOST}
port: ${CLUSTER_APIENDPOINT_PORT}
noCloudProvider: true
noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead
cloudProviderEnabled: false
---
kind: KubeadmControlPlane
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
Expand Down
3 changes: 2 additions & 1 deletion examples/templates/clusterclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ spec:
controlPlaneEndpoint:
host: 127.0.0.1
port: 6443
noCloudProvider: true
noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead
cloudProviderEnabled: false
---
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlaneTemplate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ spec:
controlPlaneEndpoint:
host: ${CLUSTER_APIENDPOINT_HOST}
port: ${CLUSTER_APIENDPOINT_PORT}
noCloudProvider: true
noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead
cloudProviderEnabled: false
---
apiVersion: controlplane.cluster.x-k8s.io/${CAPI_VERSION}
kind: KubeadmControlPlane
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ spec:
controlPlaneEndpoint:
host: ${CLUSTER_APIENDPOINT_HOST}
port: ${CLUSTER_APIENDPOINT_PORT}
noCloudProvider: true
noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead
cloudProviderEnabled: false
---
apiVersion: infrastructure.cluster.x-k8s.io/${CAPM3_VERSION}
kind: Metal3MachineTemplate
Expand Down