Skip to content

Commit

Permalink
Remove MetalLB endpoint type and use instead override for rabbitmq
Browse files Browse the repository at this point in the history
  • Loading branch information
stuggi committed Aug 17, 2023
1 parent 3acccd7 commit e579698
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 200 deletions.
24 changes: 0 additions & 24 deletions apis/bases/core.openstack.org_openstackcontrolplanes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9018,30 +9018,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:
Expand Down
40 changes: 0 additions & 40 deletions apis/core/v1beta1/openstackcontrolplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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"
Expand Down Expand Up @@ -326,45 +325,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
Expand Down
25 changes: 0 additions & 25 deletions apis/core/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 0 additions & 24 deletions config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9018,30 +9018,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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,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: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,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: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,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: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,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: {}
Expand Down
14 changes: 0 additions & 14 deletions pkg/openstack/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,6 @@ func EnsureDeleted(ctx context.Context, helper *helper.Helper, obj client.Object

}

// GetExternalEnpointDetailsForEndpoint - returns the MetalLBData for the endpoint, if not specified nil.
func GetExternalEnpointDetailsForEndpoint(
externalEndpoints []corev1.MetalLBConfig,
endpt service.Endpoint,
) *corev1.MetalLBConfig {
for _, metallbcfg := range externalEndpoints {
if metallbcfg.Endpoint == endpt {
return metallbcfg.DeepCopy()
}
}

return nil
}

// ServiceDetails - service details to create service.Service with overrides
type ServiceDetails struct {
ServiceName string
Expand Down
33 changes: 0 additions & 33 deletions pkg/openstack/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e579698

Please sign in to comment.