mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 15:58:37 +00:00
Ensure that only IPs are used as node addresses in OpenStack LBs
This commit is contained in:
parent
481b2dc7cf
commit
7b5f3a1dc5
@ -487,21 +487,27 @@ func (lbaas *LbaasV2) GetLoadBalancer(ctx context.Context, clusterName string, s
|
|||||||
|
|
||||||
// The LB needs to be configured with instance addresses on the same
|
// The LB needs to be configured with instance addresses on the same
|
||||||
// subnet as the LB (aka opts.SubnetID). Currently we're just
|
// subnet as the LB (aka opts.SubnetID). Currently we're just
|
||||||
// guessing that the node's InternalIP is the right address - and that
|
// guessing that the node's InternalIP is the right address.
|
||||||
// should be sufficient for all "normal" cases.
|
// In case no InternalIP can be found, ExternalIP is tried.
|
||||||
|
// If neither InternalIP nor ExternalIP can be found an error is
|
||||||
|
// returned.
|
||||||
func nodeAddressForLB(node *v1.Node) (string, error) {
|
func nodeAddressForLB(node *v1.Node) (string, error) {
|
||||||
addrs := node.Status.Addresses
|
addrs := node.Status.Addresses
|
||||||
if len(addrs) == 0 {
|
if len(addrs) == 0 {
|
||||||
return "", ErrNoAddressFound
|
return "", ErrNoAddressFound
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, addr := range addrs {
|
allowedAddrTypes := []v1.NodeAddressType{v1.NodeInternalIP, v1.NodeExternalIP}
|
||||||
if addr.Type == v1.NodeInternalIP {
|
|
||||||
return addr.Address, nil
|
for _, allowedAddrType := range allowedAddrTypes {
|
||||||
|
for _, addr := range addrs {
|
||||||
|
if addr.Type == allowedAddrType {
|
||||||
|
return addr.Address, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return addrs[0].Address, nil
|
return "", ErrNoAddressFound
|
||||||
}
|
}
|
||||||
|
|
||||||
//getStringFromServiceAnnotation searches a given v1.Service for a specific annotationKey and either returns the annotation's value or a specified defaultSetting
|
//getStringFromServiceAnnotation searches a given v1.Service for a specific annotationKey and either returns the annotation's value or a specified defaultSetting
|
||||||
|
Loading…
Reference in New Issue
Block a user