Skip to content

Commit 5d6f541

Browse files
committed
feat: support providers that do not require nodeports
Add a new loadBalancer option `ProviderRequiresNodeports` which by default is true to keep the existing behavior but when set to false allows user to not have to allocate nodeports in case there is support by the loadbalancer provider. Signed-off-by: Ondrej Blazek <ondrej.blazek@firma.seznam.cz>
1 parent a031201 commit 5d6f541

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

pkg/ingress/config/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,9 @@ type octaviaConfig struct {
6262
// the load balancer instead of the bulk update API call.
6363
// Default is false.
6464
ProviderRequiresSerialAPICalls bool `mapstructure:"provider-requires-serial-api-calls"`
65+
66+
// (Optional) If the provider requires nodeports for accessing the nodes or allows usage
67+
// of `allocateLoadBalancerNodePorts=false`
68+
// Default is true.
69+
ProviderRequiresNodeports bool `mapstructure:"provider-requires-nodeports"`
6570
}

pkg/openstack/loadbalancer.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,10 +1033,21 @@ func (lbaas *LbaasV2) buildBatchUpdateMemberOpts(ctx context.Context, port corev
10331033
memberSubnetID = nil
10341034
}
10351035

1036-
if port.NodePort != 0 { // It's 0 when AllocateLoadBalancerNodePorts=False
1036+
var protoPort int32
1037+
if !lbaas.opts.ProviderRequiresNodeports {
1038+
protoPort = port.TargetPort.IntVal
1039+
} else {
1040+
if port.NodePort != 0 { // It's 0 when AllocateLoadBalancerNodePorts=False
1041+
protoPort = port.NodePort
1042+
}
1043+
}
1044+
1045+
// protoPort set when provider doesn't require nodePorts (and e.g. AllocateLoadBalancerNodePorts=false)
1046+
// or when NodePort is set
1047+
if protoPort > 0 {
10371048
member := v2pools.BatchUpdateMemberOpts{
10381049
Address: addr,
1039-
ProtocolPort: int(port.NodePort),
1050+
ProtocolPort: int(protoPort),
10401051
Name: &node.Name,
10411052
SubnetID: memberSubnetID,
10421053
}

pkg/openstack/openstack.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ type LoadBalancerOpts struct {
120120
MaxSharedLB int `gcfg:"max-shared-lb"` // Number of Services in maximum can share a single load balancer. Default 2
121121
ContainerStore string `gcfg:"container-store"` // Used to specify the store of the tls-container-ref
122122
ProviderRequiresSerialAPICalls bool `gcfg:"provider-requires-serial-api-calls"` // default false, the provider supports the "bulk update" API call
123+
ProviderRequiresNodeports bool `gcfg:"provider-requires-nodeports"` // default true, the provider requires nodeports for accessing nodes
123124
// revive:disable:var-naming
124125
TlsContainerRef string `gcfg:"default-tls-container-ref"` // reference to a tls container
125126
// revive:enable:var-naming
@@ -227,6 +228,7 @@ func ReadConfig(config io.Reader) (Config, error) {
227228
cfg.LoadBalancer.ContainerStore = "barbican"
228229
cfg.LoadBalancer.MaxSharedLB = 2
229230
cfg.LoadBalancer.ProviderRequiresSerialAPICalls = false
231+
cfg.LoadBalancer.ProviderRequiresNodeports = true
230232

231233
err := gcfg.FatalOnly(gcfg.ReadInto(&cfg, config))
232234
if err != nil {

0 commit comments

Comments
 (0)