From a71a77e162cfa028f840ae3a87cfdd02f674a109 Mon Sep 17 00:00:00 2001 From: Matt Pryor Date: Mon, 1 Aug 2022 17:26:33 +0100 Subject: [PATCH] Allow for omiting AZ from control plane nodes --- api/v1alpha6/openstackcluster_types.go | 4 ++++ ...ture.cluster.x-k8s.io_openstackclusters.yaml | 5 +++++ ...ster.x-k8s.io_openstackclustertemplates.yaml | 5 +++++ controllers/openstackcluster_controller.go | 17 ++++++----------- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/api/v1alpha6/openstackcluster_types.go b/api/v1alpha6/openstackcluster_types.go index 189544ab38..907602e66a 100644 --- a/api/v1alpha6/openstackcluster_types.go +++ b/api/v1alpha6/openstackcluster_types.go @@ -126,6 +126,10 @@ type OpenStackClusterSpec struct { // ControlPlaneAvailabilityZones is the az to deploy control plane to ControlPlaneAvailabilityZones []string `json:"controlPlaneAvailabilityZones,omitempty"` + // Indicates whether to omit the az for control plane nodes, allowing the Nova scheduler + // to make a decision on which az to use based on other scheduling constraints + ControlPlaneOmitAvailabilityZone bool `json:"controlPlaneOmitAvailabilityZone,omitempty"` + // Bastion is the OpenStack instance to login the nodes // // As a rolling update is not ideal during a bastion host session, we diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml index 07f1d45f78..fef03fe59d 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml @@ -4724,6 +4724,11 @@ spec: - host - port type: object + controlPlaneOmitAvailabilityZone: + description: Indicates whether to omit the az for control plane nodes, + allowing the Nova scheduler to make a decision on which az to use + based on other scheduling constraints + type: boolean disableAPIServerFloatingIP: description: DisableAPIServerFloatingIP determines whether or not to attempt to attach a floating IP to the API server. This allows diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml index 14cea0ef6e..4be92420fe 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml @@ -1962,6 +1962,11 @@ spec: - host - port type: object + controlPlaneOmitAvailabilityZone: + description: Indicates whether to omit the az for control + plane nodes, allowing the Nova scheduler to make a decision + on which az to use based on other scheduling constraints + type: boolean disableAPIServerFloatingIP: description: DisableAPIServerFloatingIP determines whether or not to attempt to attach a floating IP to the API server. diff --git a/controllers/openstackcluster_controller.go b/controllers/openstackcluster_controller.go index f3ed104b14..e8bbec977c 100644 --- a/controllers/openstackcluster_controller.go +++ b/controllers/openstackcluster_controller.go @@ -280,21 +280,16 @@ func reconcileNormal(ctx context.Context, scope *scope.Scope, patchHelper *patch return ctrl.Result{}, err } - // Create a new list to remove any Availability - // Zones that have been removed from OpenStack + // Create a new list in case any AZs have been removed from OpenStack openStackCluster.Status.FailureDomains = make(clusterv1.FailureDomains) for _, az := range availabilityZones { - found := true - // If Az given, then check whether it's in the allow list - // If no Az given, then by default put into allow list + // By default, the AZ is used or not used for control plane nodes depending on the flag + found := !openStackCluster.Spec.ControlPlaneOmitAvailabilityZone + // If explicit AZs for control plane nodes are given, they override the value if len(openStackCluster.Spec.ControlPlaneAvailabilityZones) > 0 { - if contains(openStackCluster.Spec.ControlPlaneAvailabilityZones, az.ZoneName) { - found = true - } else { - found = false - } + found = contains(openStackCluster.Spec.ControlPlaneAvailabilityZones, az.ZoneName) } - + // Add the AZ object to the failure domains for the cluster openStackCluster.Status.FailureDomains[az.ZoneName] = clusterv1.FailureDomainSpec{ ControlPlane: found, }