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 Sep 12, 2023
1 parent a47d78f commit 7d4d8cf
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 186 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 @@ -9050,30 +9050,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 @@ -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"
Expand Down Expand Up @@ -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
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 @@ -9050,30 +9050,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 @@ -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: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
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 7d4d8cf

Please sign in to comment.