From 74db9564891ea168cca16e95890d3ec1009787bc Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Thu, 17 Aug 2023 09:42:29 +0200 Subject: [PATCH] Remove MetalLB endpoint type and use instead override for rabbitmq --- ....openstack.org_openstackcontrolplanes.yaml | 24 ----------- .../v1beta1/openstackcontrolplane_types.go | 40 ------------------- apis/core/v1beta1/zz_generated.deepcopy.go | 25 ------------ ....openstack.org_openstackcontrolplanes.yaml | 24 ----------- ...controlplane_galera_network_isolation.yaml | 26 +++++++----- ...ne_galera_network_isolation_3replicas.yaml | 26 +++++++----- ...enstackcontrolplane_network_isolation.yaml | 26 +++++++----- ...ckcontrolplane_network_isolation_ceph.yaml | 26 +++++++----- pkg/openstack/rabbitmq.go | 33 --------------- 9 files changed, 64 insertions(+), 186 deletions(-) diff --git a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml index 5ea08fdc6..9f12e6b1c 100644 --- a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -9024,30 +9024,6 @@ spec: type: array type: object type: object - externalEndpoint: - properties: - endpoint: - default: internal - enum: - - internal - - public - type: string - ipAddressPool: - minLength: 1 - type: string - loadBalancerIPs: - items: - type: string - type: array - sharedIP: - default: true - type: boolean - sharedIPKey: - default: "" - type: string - required: - - ipAddressPool - type: object image: type: string imagePullSecrets: diff --git a/apis/core/v1beta1/openstackcontrolplane_types.go b/apis/core/v1beta1/openstackcontrolplane_types.go index c463e9e5e..abd5e795d 100644 --- a/apis/core/v1beta1/openstackcontrolplane_types.go +++ b/apis/core/v1beta1/openstackcontrolplane_types.go @@ -27,7 +27,6 @@ import ( keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1" condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" "github.com/openstack-k8s-operators/lib-common/modules/common/route" - "github.com/openstack-k8s-operators/lib-common/modules/common/service" "github.com/openstack-k8s-operators/lib-common/modules/common/util" "github.com/openstack-k8s-operators/lib-common/modules/storage" manilav1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1" @@ -324,45 +323,6 @@ type RabbitmqTemplate struct { //+operator-sdk:csv:customresourcedefinitions:type=spec // Overrides to use when creating the Rabbitmq clusters rabbitmqv1.RabbitmqClusterSpec `json:",inline"` - - // +kubebuilder:validation:Optional - //+operator-sdk:csv:customresourcedefinitions:type=spec - // ExternalEndpoint, expose a VIP via MetalLB on the pre-created address pool - ExternalEndpoint *MetalLBConfig `json:"externalEndpoint,omitempty"` -} - -// MetalLBConfig to configure the MetalLB loadbalancer service -type MetalLBConfig struct { - // +kubebuilder:validation:Optional - // +kubebuilder:validation:Enum=internal;public - // +kubebuilder:default=internal - // Endpoint, OpenStack endpoint this service maps to - Endpoint service.Endpoint `json:"endpoint"` - - // +kubebuilder:validation:Required - // +kubebuilder:validation:MinLength=1 - //+operator-sdk:csv:customresourcedefinitions:type=spec - // IPAddressPool expose VIP via MetalLB on the IPAddressPool - IPAddressPool string `json:"ipAddressPool"` - - // +kubebuilder:validation:Optional - // +kubebuilder:default=true - // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"} - // SharedIP if true, VIP/VIPs get shared with multiple services - SharedIP bool `json:"sharedIP"` - - // +kubebuilder:validation:Optional - // +kubebuilder:default="" - //+operator-sdk:csv:customresourcedefinitions:type=spec - // SharedIPKey specifies the sharing key which gets set as the annotation on the LoadBalancer service. - // Services which share the same VIP must have the same SharedIPKey. Defaults to the IPAddressPool if - // SharedIP is true, but no SharedIPKey specified. - SharedIPKey string `json:"sharedIPKey"` - - // +kubebuilder:validation:Optional - //+operator-sdk:csv:customresourcedefinitions:type=spec - // LoadBalancerIPs, request given IPs from the pool if available. Using a list to allow dual stack (IPv4/IPv6) support - LoadBalancerIPs []string `json:"loadBalancerIPs"` } // OvnSection defines the desired state of OVN services diff --git a/apis/core/v1beta1/zz_generated.deepcopy.go b/apis/core/v1beta1/zz_generated.deepcopy.go index c9916ee53..9e669f2a2 100644 --- a/apis/core/v1beta1/zz_generated.deepcopy.go +++ b/apis/core/v1beta1/zz_generated.deepcopy.go @@ -268,26 +268,6 @@ func (in *MemcachedSection) DeepCopy() *MemcachedSection { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MetalLBConfig) DeepCopyInto(out *MetalLBConfig) { - *out = *in - if in.LoadBalancerIPs != nil { - in, out := &in.LoadBalancerIPs, &out.LoadBalancerIPs - *out = make([]string, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetalLBConfig. -func (in *MetalLBConfig) DeepCopy() *MetalLBConfig { - if in == nil { - return nil - } - out := new(MetalLBConfig) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NeutronSection) DeepCopyInto(out *NeutronSection) { *out = *in @@ -630,11 +610,6 @@ func (in *RabbitmqSection) DeepCopy() *RabbitmqSection { func (in *RabbitmqTemplate) DeepCopyInto(out *RabbitmqTemplate) { *out = *in in.RabbitmqClusterSpec.DeepCopyInto(&out.RabbitmqClusterSpec) - if in.ExternalEndpoint != nil { - in, out := &in.ExternalEndpoint, &out.ExternalEndpoint - *out = new(MetalLBConfig) - (*in).DeepCopyInto(*out) - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RabbitmqTemplate. diff --git a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml index 5ea08fdc6..9f12e6b1c 100644 --- a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -9024,30 +9024,6 @@ spec: type: array type: object type: object - externalEndpoint: - properties: - endpoint: - default: internal - enum: - - internal - - public - type: string - ipAddressPool: - minLength: 1 - type: string - loadBalancerIPs: - items: - type: string - type: array - sharedIP: - default: true - type: boolean - sharedIPKey: - default: "" - type: string - required: - - ipAddressPool - type: object image: type: string imagePullSecrets: diff --git a/config/samples/core_v1beta1_openstackcontrolplane_galera_network_isolation.yaml b/config/samples/core_v1beta1_openstackcontrolplane_galera_network_isolation.yaml index 5b231b843..1673391d9 100644 --- a/config/samples/core_v1beta1_openstackcontrolplane_galera_network_isolation.yaml +++ b/config/samples/core_v1beta1_openstackcontrolplane_galera_network_isolation.yaml @@ -218,17 +218,23 @@ spec: rabbitmq: templates: rabbitmq: - externalEndpoint: - loadBalancerIPs: - - 172.17.0.85 - ipAddressPool: internalapi - sharedIP: false + override: + service: + metadata: + annotations: + metallb.universe.tf/address-pool: internalapi + metallb.universe.tf/loadBalancerIPs: 172.17.0.85 + spec: + type: LoadBalancer rabbitmq-cell1: - externalEndpoint: - loadBalancerIPs: - - 172.17.0.86 - ipAddressPool: internalapi - sharedIP: false + override: + service: + metadata: + annotations: + metallb.universe.tf/address-pool: internalapi + metallb.universe.tf/loadBalancerIPs: 172.17.0.86 + spec: + type: LoadBalancer heat: apiOverride: route: {} diff --git a/config/samples/core_v1beta1_openstackcontrolplane_galera_network_isolation_3replicas.yaml b/config/samples/core_v1beta1_openstackcontrolplane_galera_network_isolation_3replicas.yaml index a27a51419..68b8fdf58 100644 --- a/config/samples/core_v1beta1_openstackcontrolplane_galera_network_isolation_3replicas.yaml +++ b/config/samples/core_v1beta1_openstackcontrolplane_galera_network_isolation_3replicas.yaml @@ -218,17 +218,23 @@ spec: rabbitmq: templates: rabbitmq: - externalEndpoint: - loadBalancerIPs: - - 172.17.0.85 - ipAddressPool: internalapi - sharedIP: false + override: + service: + metadata: + annotations: + metallb.universe.tf/address-pool: internalapi + metallb.universe.tf/loadBalancerIPs: 172.17.0.85 + spec: + type: LoadBalancer rabbitmq-cell1: - externalEndpoint: - loadBalancerIPs: - - 172.17.0.86 - ipAddressPool: internalapi - sharedIP: false + override: + service: + metadata: + annotations: + metallb.universe.tf/address-pool: internalapi + metallb.universe.tf/loadBalancerIPs: 172.17.0.86 + spec: + type: LoadBalancer heat: apiOverride: route: {} diff --git a/config/samples/core_v1beta1_openstackcontrolplane_network_isolation.yaml b/config/samples/core_v1beta1_openstackcontrolplane_network_isolation.yaml index f26b23651..5a31ed287 100644 --- a/config/samples/core_v1beta1_openstackcontrolplane_network_isolation.yaml +++ b/config/samples/core_v1beta1_openstackcontrolplane_network_isolation.yaml @@ -206,17 +206,23 @@ spec: rabbitmq: templates: rabbitmq: - externalEndpoint: - loadBalancerIPs: - - 172.17.0.85 - ipAddressPool: internalapi - sharedIP: false + override: + service: + metadata: + annotations: + metallb.universe.tf/address-pool: internalapi + metallb.universe.tf/loadBalancerIPs: 172.17.0.85 + spec: + type: LoadBalancer rabbitmq-cell1: - externalEndpoint: - loadBalancerIPs: - - 172.17.0.86 - ipAddressPool: internalapi - sharedIP: false + override: + service: + metadata: + annotations: + metallb.universe.tf/address-pool: internalapi + metallb.universe.tf/loadBalancerIPs: 172.17.0.86 + spec: + type: LoadBalancer heat: apiOverride: route: {} diff --git a/config/samples/core_v1beta1_openstackcontrolplane_network_isolation_ceph.yaml b/config/samples/core_v1beta1_openstackcontrolplane_network_isolation_ceph.yaml index a835ef24b..0ab04e18b 100644 --- a/config/samples/core_v1beta1_openstackcontrolplane_network_isolation_ceph.yaml +++ b/config/samples/core_v1beta1_openstackcontrolplane_network_isolation_ceph.yaml @@ -264,17 +264,23 @@ spec: rabbitmq: templates: rabbitmq: - externalEndpoint: - loadBalancerIPs: - - 172.17.0.85 - ipAddressPool: internalapi - sharedIP: false + override: + service: + metadata: + annotations: + metallb.universe.tf/address-pool: internalapi + metallb.universe.tf/loadBalancerIPs: 172.17.0.85 + spec: + type: LoadBalancer rabbitmq-cell1: - externalEndpoint: - loadBalancerIPs: - - 172.17.0.86 - ipAddressPool: internalapi - sharedIP: false + override: + service: + metadata: + annotations: + metallb.universe.tf/address-pool: internalapi + metallb.universe.tf/loadBalancerIPs: 172.17.0.86 + spec: + type: LoadBalancer heat: apiOverride: route: {} diff --git a/pkg/openstack/rabbitmq.go b/pkg/openstack/rabbitmq.go index b7f7a0295..df1bf0d60 100644 --- a/pkg/openstack/rabbitmq.go +++ b/pkg/openstack/rabbitmq.go @@ -5,10 +5,8 @@ import ( "fmt" "strings" - networkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1" condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" "github.com/openstack-k8s-operators/lib-common/modules/common/helper" - "github.com/openstack-k8s-operators/lib-common/modules/common/service" rabbitmqv1 "github.com/rabbitmq/cluster-operator/api/v1beta1" // Cannot use the following import due to linting error: @@ -186,37 +184,6 @@ func reconcileRabbitMQ( rabbitmq.Spec.Override.StatefulSet = &defaultStatefulSet } - if rabbitmq.Spec.Override.Service == nil && spec.ExternalEndpoint != nil { - helper.GetLogger().Info("Setting MetalLB Service") - - metalLBSvcAnnotations := map[string]string{ - service.MetalLBAddressPoolAnnotation: spec.ExternalEndpoint.IPAddressPool, - networkv1.AnnotationHostnameKey: fmt.Sprintf("%s.%s.svc", name, instance.Namespace), - } - if len(spec.ExternalEndpoint.LoadBalancerIPs) > 0 { - metalLBSvcAnnotations[service.MetalLBLoadBalancerIPs] = strings.Join(spec.ExternalEndpoint.LoadBalancerIPs, ",") - } - if spec.ExternalEndpoint.SharedIP { - if spec.ExternalEndpoint.SharedIPKey == "" { - metalLBSvcAnnotations[service.MetalLBAllowSharedIPAnnotation] = spec.ExternalEndpoint.IPAddressPool - } else { - metalLBSvcAnnotations[service.MetalLBAllowSharedIPAnnotation] = spec.ExternalEndpoint.SharedIPKey - } - } - - //service.MetalLBService{} - metalLBSvc := rabbitmqv1.Service{ - EmbeddedLabelsAnnotations: &rabbitmqv1.EmbeddedLabelsAnnotations{ - Annotations: metalLBSvcAnnotations, - }, - Spec: &corev1.ServiceSpec{ - Type: corev1.ServiceTypeLoadBalancer, - }, - } - - rabbitmq.Spec.Override.Service = &metalLBSvc - } - if rabbitmq.Spec.Rabbitmq.AdditionalConfig == "" { helper.GetLogger().Info("Setting AdditionalConfig") // This is the same situation as RABBITMQ_UPGRADE_LOG above,