Skip to content

Commit

Permalink
openstack: support setting LB IP
Browse files Browse the repository at this point in the history
Add support for setting the (deprecated) Service field: `loadBalancerIP`
on platform OpenStack when the LB is not internal.
  • Loading branch information
EmilienM committed Oct 2, 2024
1 parent 4aba07b commit 233a444
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
44 changes: 44 additions & 0 deletions manifests/00-custom-resource-definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,24 @@ spec:
- PROXY
type: string
type: object
openstack:
description: "openstack provides configuration settings
that are specific to OpenStack load balancers. \n If
empty, defaults will be applied. See specific openstack
fields for details about their defaults."
properties:
loadBalancerIP:
description: loadBalancerIP specifies the floating
IP address that the load balancer will use. When
not specified, an IP address will be assigned randomly
by the OpenStack cloud provider. This value must
be a valid IPv4 or IPv6 address.
type: string
x-kubernetes-validations:
- message: loadBalancerIP must be a valid IPv4 or
IPv6 address
rule: isIP(self)
type: object
type:
description: type is the underlying infrastructure provider
for the load balancer. Allowed values are "AWS", "Azure",
Expand All @@ -592,6 +610,10 @@ spec:
required:
- type
type: object
x-kubernetes-validations:
- message: openstack is not permitted when type is not OpenStack
rule: 'has(self.type) && self.type == ''OpenStack'' ? true
: !has(self.openstack)'
scope:
description: scope indicates the scope at which the load balancer
is exposed. Possible values are "External" and "Internal".
Expand Down Expand Up @@ -2440,6 +2462,24 @@ spec:
- PROXY
type: string
type: object
openstack:
description: "openstack provides configuration settings
that are specific to OpenStack load balancers. \n If
empty, defaults will be applied. See specific openstack
fields for details about their defaults."
properties:
loadBalancerIP:
description: loadBalancerIP specifies the floating
IP address that the load balancer will use. When
not specified, an IP address will be assigned randomly
by the OpenStack cloud provider. This value must
be a valid IPv4 or IPv6 address.
type: string
x-kubernetes-validations:
- message: loadBalancerIP must be a valid IPv4 or
IPv6 address
rule: isIP(self)
type: object
type:
description: type is the underlying infrastructure provider
for the load balancer. Allowed values are "AWS", "Azure",
Expand All @@ -2458,6 +2498,10 @@ spec:
required:
- type
type: object
x-kubernetes-validations:
- message: openstack is not permitted when type is not OpenStack
rule: 'has(self.type) && self.type == ''OpenStack'' ? true
: !has(self.openstack)'
scope:
description: scope indicates the scope at which the load balancer
is exposed. Possible values are "External" and "Internal".
Expand Down
29 changes: 29 additions & 0 deletions pkg/operator/controller/ingress/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,27 @@ func setDefaultPublishingStrategy(ic *operatorv1.IngressController, platformStat
statusLB.ProviderParameters.IBM.Protocol = specProtocol
changed = true
}
case operatorv1.OpenStackLoadBalancerProvider:
// The only provider parameter that is supported
// for OpenStack is the LoadBalancerIP parameter.
var statusLoadBalancerIP string
specLoadBalancerIP := specLB.ProviderParameters.OpenStack.LoadBalancerIP
if statusLB.ProviderParameters != nil && statusLB.ProviderParameters.OpenStack != nil {
statusLoadBalancerIP = statusLB.ProviderParameters.OpenStack.LoadBalancerIP
}
if specLoadBalancerIP != statusLoadBalancerIP {
if statusLB.ProviderParameters == nil {
statusLB.ProviderParameters = &operatorv1.ProviderLoadBalancerParameters{}
}
if len(statusLB.ProviderParameters.Type) == 0 {
statusLB.ProviderParameters.Type = operatorv1.OpenStackLoadBalancerProvider
}
if statusLB.ProviderParameters.OpenStack == nil {
statusLB.ProviderParameters.OpenStack = &operatorv1.OpenStackLoadBalancerParameters{}
}
statusLB.ProviderParameters.OpenStack.LoadBalancerIP = specLoadBalancerIP
changed = true
}
}
return changed
}
Expand Down Expand Up @@ -739,6 +760,14 @@ func setDefaultProviderParameters(lbs *operatorv1.LoadBalancerStrategy, ingressC
if lbs.ProviderParameters.IBM == nil {
lbs.ProviderParameters.IBM = &operatorv1.IBMLoadBalancerParameters{}
}
case operatorv1.OpenStackLoadBalancerProvider:
if lbs.ProviderParameters == nil {
lbs.ProviderParameters = &operatorv1.ProviderLoadBalancerParameters{}
}
lbs.ProviderParameters.Type = provider
if lbs.ProviderParameters.OpenStack == nil {
lbs.ProviderParameters.OpenStack = &operatorv1.OpenStackLoadBalancerParameters{}
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/operator/controller/ingress/load_balancer_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,15 @@ func desiredLoadBalancerService(ci *operatorv1.IngressController, deploymentRef
if !isInternal {
service.Annotations[alibabaCloudLBAddressTypeAnnotation] = alibabaCloudLBAddressTypeInternet
}
case configv1.OpenStackPlatformType:
// Set a floating IP only if the load balancer is external.
if !isInternal {
if lb != nil && lb.ProviderParameters != nil &&
lb.ProviderParameters.Type == operatorv1.OpenStackLoadBalancerProvider &&
lb.ProviderParameters.OpenStack != nil {
service.Spec.LoadBalancerIP = lb.ProviderParameters.OpenStack.LoadBalancerIP
}
}
}
// Azure load balancers are not customizable and are set to (2 fail @ 5s interval, 2 healthy)
// GCP load balancers are not customizable and are set to (3 fail @ 8s interval, 1 healthy)
Expand Down

0 comments on commit 233a444

Please sign in to comment.