mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 20:17:41 +00:00
Use existing subnetwork of forwarding rule
This commit is contained in:
parent
7fb2d5432d
commit
64c20676ac
@ -82,10 +82,18 @@ func (gce *GCECloud) ensureInternalLoadBalancer(clusterName, clusterID string, s
|
|||||||
requestedIP := determineRequestedIP(svc, existingFwdRule)
|
requestedIP := determineRequestedIP(svc, existingFwdRule)
|
||||||
ipToUse := requestedIP
|
ipToUse := requestedIP
|
||||||
|
|
||||||
|
// If the ILB already exists, continue using the subnet that it's already using.
|
||||||
|
// This is to support existing ILBs that were setup using the wrong subnet.
|
||||||
|
subnetworkURL := gce.SubnetworkURL()
|
||||||
|
if existingFwdRule != nil && existingFwdRule.Subnetwork != "" {
|
||||||
|
// external LBs have an empty Subnetwork field.
|
||||||
|
subnetworkURL = existingFwdRule.Subnetwork
|
||||||
|
}
|
||||||
|
|
||||||
var addrMgr *addressManager
|
var addrMgr *addressManager
|
||||||
// If the network is not a legacy network, use the address manager
|
// If the network is not a legacy network, use the address manager
|
||||||
if !gce.IsLegacyNetwork() {
|
if !gce.IsLegacyNetwork() {
|
||||||
addrMgr = newAddressManager(gce, nm.String(), gce.Region(), gce.SubnetworkURL(), loadBalancerName, requestedIP, schemeInternal)
|
addrMgr = newAddressManager(gce, nm.String(), gce.Region(), subnetworkURL, loadBalancerName, requestedIP, schemeInternal)
|
||||||
ipToUse, err = addrMgr.HoldAddress()
|
ipToUse, err = addrMgr.HoldAddress()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -108,9 +116,10 @@ func (gce *GCECloud) ensureInternalLoadBalancer(clusterName, clusterID string, s
|
|||||||
LoadBalancingScheme: string(scheme),
|
LoadBalancingScheme: string(scheme),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specify subnetwork if known
|
// Given that CreateGCECloud will attempt to determine the subnet based off the network,
|
||||||
if len(gce.subnetworkURL) > 0 {
|
// the subnetwork should rarely be unknown.
|
||||||
expectedFwdRule.Subnetwork = gce.subnetworkURL
|
if subnetworkURL != "" {
|
||||||
|
expectedFwdRule.Subnetwork = subnetworkURL
|
||||||
} else {
|
} else {
|
||||||
expectedFwdRule.Network = gce.networkURL
|
expectedFwdRule.Network = gce.networkURL
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user