diff --git a/api/v1beta1/metal3cluster_types.go b/api/v1beta1/metal3cluster_types.go index e91db43b8c..63c02c37c9 100644 --- a/api/v1beta1/metal3cluster_types.go +++ b/api/v1beta1/metal3cluster_types.go @@ -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"` } // IsValid returns an error if the object is not valid, otherwise nil. The diff --git a/baremetal/metal3machine_manager.go b/baremetal/metal3machine_manager.go index 72cd44a9f4..53c53d1e4e 100644 --- a/baremetal/metal3machine_manager.go +++ b/baremetal/metal3machine_manager.go @@ -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" diff --git a/baremetal/metal3machine_manager_test.go b/baremetal/metal3machine_manager_test.go index 9228b0ec46..90870c0367 100644 --- a/baremetal/metal3machine_manager_test.go +++ b/baremetal/metal3machine_manager_test.go @@ -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{ @@ -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() @@ -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{ diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_metal3clusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_metal3clusters.yaml index 6f7d8e7f92..890aadeb18 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_metal3clusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_metal3clusters.yaml @@ -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. @@ -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: diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_metal3clustertemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_metal3clustertemplates.yaml index 405b81984e..14c0c7caf4 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_metal3clustertemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_metal3clustertemplates.yaml @@ -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. @@ -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: diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 2bf3a0eba5..a1e9252eed 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -169,6 +169,7 @@ func bmcSpec() *infrav1.Metal3ClusterSpec { Port: 6443, }, NoCloudProvider: true, + CloudProviderEnabled: false, } } diff --git a/docs/api.md b/docs/api.md index 7f4c57d59d..5d5c7ba58d 100644 --- a/docs/api.md +++ b/docs/api.md @@ -80,10 +80,14 @@ 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 +- **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. Example metal3cluster : @@ -97,7 +101,8 @@ spec: controlPlaneEndpoint: host: 192.168.111.249 port: 6443 - noCloudProvider: true + noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead + cloudProviderEnabled: false ``` ## KubeadmControlPlane diff --git a/docs/architecture.md b/docs/architecture.md index 3b52d3f3f2..1d1d677c61 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -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 @@ -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 diff --git a/examples/cluster/cluster.yaml b/examples/cluster/cluster.yaml index fbd991681e..bc920e1cf4 100644 --- a/examples/cluster/cluster.yaml +++ b/examples/cluster/cluster.yaml @@ -30,7 +30,8 @@ metadata: name: ${CLUSTER_NAME} namespace: ${NAMESPACE} spec: +noCloudProvider: true # This field is deprecated use cloudProviderEnabled instead +cloudProviderEnabled: false controlPlaneEndpoint: host: ${CLUSTER_APIENDPOINT_HOST} port: ${CLUSTER_APIENDPOINT_PORT} - noCloudProvider: true \ No newline at end of file diff --git a/examples/clusterctl-templates/clusterctl-cluster.yaml b/examples/clusterctl-templates/clusterctl-cluster.yaml index 8381c30def..89904ca601 100644 --- a/examples/clusterctl-templates/clusterctl-cluster.yaml +++ b/examples/clusterctl-templates/clusterctl-cluster.yaml @@ -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 diff --git a/examples/templates/clusterclass.yaml b/examples/templates/clusterclass.yaml index 5c52be1eb9..1afce0eaf6 100644 --- a/examples/templates/clusterclass.yaml +++ b/examples/templates/clusterclass.yaml @@ -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 diff --git a/test/e2e/data/infrastructure-metal3/bases/cluster/cluster-with-kcp.yaml b/test/e2e/data/infrastructure-metal3/bases/cluster/cluster-with-kcp.yaml index 50fb65f226..5906da5902 100644 --- a/test/e2e/data/infrastructure-metal3/bases/cluster/cluster-with-kcp.yaml +++ b/test/e2e/data/infrastructure-metal3/bases/cluster/cluster-with-kcp.yaml @@ -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 diff --git a/test/e2e/data/infrastructure-metal3/bases/clusterclass-cluster/cluster-with-kcp.yaml b/test/e2e/data/infrastructure-metal3/bases/clusterclass-cluster/cluster-with-kcp.yaml index 620ffef6a3..8ff5e740c5 100644 --- a/test/e2e/data/infrastructure-metal3/bases/clusterclass-cluster/cluster-with-kcp.yaml +++ b/test/e2e/data/infrastructure-metal3/bases/clusterclass-cluster/cluster-with-kcp.yaml @@ -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