mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +00:00
Merge pull request #66589 from MorrisLaw/get_load_balancer_name_per_provider
Automatic merge from submit-queue (batch tested with PRs 67061, 66589, 67121, 67149). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Get load balancer name per provider **What this PR does / why we need it**: GetLoadBalancerName() should be implemented per cloud provider as opposed to one neutral implementation. This PR will address this by moving `cloudprovider.GetLoadBalancerName()` to the `LoadBalancer interface` and then provide an implementation for each cloud provider, while maintaining previously expected functionality. **Which issue(s) this PR fixes**: Fixes [#43173](https://github.com/kubernetes/kubernetes/issues/43173) **Special notes for your reviewer**: This is a work in progress. Looking for feedback as I work on this, from any interested parties. **Release note**: ```release-note NONE ```
This commit is contained in:
commit
dd4ab76f05
@ -64,7 +64,7 @@ type Clusters interface {
|
|||||||
|
|
||||||
// TODO(#6812): Use a shorter name that's less likely to be longer than cloud
|
// TODO(#6812): Use a shorter name that's less likely to be longer than cloud
|
||||||
// providers' name length limits.
|
// providers' name length limits.
|
||||||
func GetLoadBalancerName(service *v1.Service) string {
|
func DefaultLoadBalancerName(service *v1.Service) string {
|
||||||
//GCE requires that the name of a load balancer starts with a lower case letter.
|
//GCE requires that the name of a load balancer starts with a lower case letter.
|
||||||
ret := "a" + string(service.UID)
|
ret := "a" + string(service.UID)
|
||||||
ret = strings.Replace(ret, "-", "", -1)
|
ret = strings.Replace(ret, "-", "", -1)
|
||||||
@ -96,6 +96,9 @@ type LoadBalancer interface {
|
|||||||
// Implementations must treat the *v1.Service parameter as read-only and not modify it.
|
// Implementations must treat the *v1.Service parameter as read-only and not modify it.
|
||||||
// Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
|
// Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
|
||||||
GetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (status *v1.LoadBalancerStatus, exists bool, err error)
|
GetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (status *v1.LoadBalancerStatus, exists bool, err error)
|
||||||
|
// GetLoadBalancerName returns the name of the load balancer. Implementations must treat the
|
||||||
|
// *v1.Service parameter as read-only and not modify it.
|
||||||
|
GetLoadBalancerName(ctx context.Context, clusterName string, service *v1.Service) string
|
||||||
// EnsureLoadBalancer creates a new load balancer 'name', or updates the existing one. Returns the status of the balancer
|
// EnsureLoadBalancer creates a new load balancer 'name', or updates the existing one. Returns the status of the balancer
|
||||||
// Implementations must treat the *v1.Service and *v1.Node
|
// Implementations must treat the *v1.Service and *v1.Node
|
||||||
// parameters as read-only and not modify them.
|
// parameters as read-only and not modify them.
|
||||||
|
@ -3335,7 +3335,7 @@ func (c *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, apiS
|
|||||||
return nil, fmt.Errorf("could not find any suitable subnets for creating the ELB")
|
return nil, fmt.Errorf("could not find any suitable subnets for creating the ELB")
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(apiService)
|
loadBalancerName := c.GetLoadBalancerName(ctx, clusterName, apiService)
|
||||||
serviceName := types.NamespacedName{Namespace: apiService.Namespace, Name: apiService.Name}
|
serviceName := types.NamespacedName{Namespace: apiService.Namespace, Name: apiService.Name}
|
||||||
|
|
||||||
instanceIDs := []string{}
|
instanceIDs := []string{}
|
||||||
@ -3497,7 +3497,7 @@ func (c *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, apiS
|
|||||||
return nil, fmt.Errorf("could not find any suitable subnets for creating the ELB")
|
return nil, fmt.Errorf("could not find any suitable subnets for creating the ELB")
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(apiService)
|
loadBalancerName := c.GetLoadBalancerName(ctx, clusterName, apiService)
|
||||||
serviceName := types.NamespacedName{Namespace: apiService.Namespace, Name: apiService.Name}
|
serviceName := types.NamespacedName{Namespace: apiService.Namespace, Name: apiService.Name}
|
||||||
securityGroupIDs, err := c.buildELBSecurityGroupList(serviceName, loadBalancerName, annotations)
|
securityGroupIDs, err := c.buildELBSecurityGroupList(serviceName, loadBalancerName, annotations)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -3620,7 +3620,7 @@ func (c *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, apiS
|
|||||||
|
|
||||||
// GetLoadBalancer is an implementation of LoadBalancer.GetLoadBalancer
|
// GetLoadBalancer is an implementation of LoadBalancer.GetLoadBalancer
|
||||||
func (c *Cloud) GetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (*v1.LoadBalancerStatus, bool, error) {
|
func (c *Cloud) GetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (*v1.LoadBalancerStatus, bool, error) {
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(service)
|
loadBalancerName := c.GetLoadBalancerName(ctx, clusterName, service)
|
||||||
|
|
||||||
if isNLB(service.Annotations) {
|
if isNLB(service.Annotations) {
|
||||||
lb, err := c.describeLoadBalancerv2(loadBalancerName)
|
lb, err := c.describeLoadBalancerv2(loadBalancerName)
|
||||||
@ -3646,6 +3646,11 @@ func (c *Cloud) GetLoadBalancer(ctx context.Context, clusterName string, service
|
|||||||
return status, true, nil
|
return status, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetLoadBalancerName is an implementation of LoadBalancer.GetLoadBalancerName
|
||||||
|
func (c *Cloud) GetLoadBalancerName(ctx context.Context, clusterName string, service *v1.Service) string {
|
||||||
|
return cloudprovider.DefaultLoadBalancerName(service)
|
||||||
|
}
|
||||||
|
|
||||||
func toStatus(lb *elb.LoadBalancerDescription) *v1.LoadBalancerStatus {
|
func toStatus(lb *elb.LoadBalancerDescription) *v1.LoadBalancerStatus {
|
||||||
status := &v1.LoadBalancerStatus{}
|
status := &v1.LoadBalancerStatus{}
|
||||||
|
|
||||||
@ -3884,7 +3889,7 @@ func (c *Cloud) updateInstanceSecurityGroupsForLoadBalancer(lb *elb.LoadBalancer
|
|||||||
|
|
||||||
// EnsureLoadBalancerDeleted implements LoadBalancer.EnsureLoadBalancerDeleted.
|
// EnsureLoadBalancerDeleted implements LoadBalancer.EnsureLoadBalancerDeleted.
|
||||||
func (c *Cloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *v1.Service) error {
|
func (c *Cloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *v1.Service) error {
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(service)
|
loadBalancerName := c.GetLoadBalancerName(ctx, clusterName, service)
|
||||||
|
|
||||||
if isNLB(service.Annotations) {
|
if isNLB(service.Annotations) {
|
||||||
lb, err := c.describeLoadBalancerv2(loadBalancerName)
|
lb, err := c.describeLoadBalancerv2(loadBalancerName)
|
||||||
@ -4132,7 +4137,7 @@ func (c *Cloud) UpdateLoadBalancer(ctx context.Context, clusterName string, serv
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(service)
|
loadBalancerName := c.GetLoadBalancerName(ctx, clusterName, service)
|
||||||
if isNLB(service.Annotations) {
|
if isNLB(service.Annotations) {
|
||||||
lb, err := c.describeLoadBalancerv2(loadBalancerName)
|
lb, err := c.describeLoadBalancerv2(loadBalancerName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
serviceapi "k8s.io/kubernetes/pkg/api/v1/service"
|
serviceapi "k8s.io/kubernetes/pkg/api/v1/service"
|
||||||
|
"k8s.io/kubernetes/pkg/cloudprovider"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network"
|
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network"
|
||||||
"github.com/Azure/go-autorest/autorest/to"
|
"github.com/Azure/go-autorest/autorest/to"
|
||||||
@ -186,6 +187,11 @@ func (az *Cloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName stri
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetLoadBalancerName returns the LoadBalancer name.
|
||||||
|
func (az *Cloud) GetLoadBalancerName(ctx context.Context, clusterName string, service *v1.Service) string {
|
||||||
|
return cloudprovider.DefaultLoadBalancerName(service)
|
||||||
|
}
|
||||||
|
|
||||||
// getServiceLoadBalancer gets the loadbalancer for the service if it already exists.
|
// getServiceLoadBalancer gets the loadbalancer for the service if it already exists.
|
||||||
// If wantLb is TRUE then -it selects a new load balancer.
|
// If wantLb is TRUE then -it selects a new load balancer.
|
||||||
// In case the selected load balancer does not exist it returns network.LoadBalancer struct
|
// In case the selected load balancer does not exist it returns network.LoadBalancer struct
|
||||||
@ -195,7 +201,7 @@ func (az *Cloud) getServiceLoadBalancer(service *v1.Service, clusterName string,
|
|||||||
isInternal := requiresInternalLoadBalancer(service)
|
isInternal := requiresInternalLoadBalancer(service)
|
||||||
var defaultLB *network.LoadBalancer
|
var defaultLB *network.LoadBalancer
|
||||||
primaryVMSetName := az.vmSet.GetPrimaryVMSetName()
|
primaryVMSetName := az.vmSet.GetPrimaryVMSetName()
|
||||||
defaultLBName := az.getLoadBalancerName(clusterName, primaryVMSetName, isInternal)
|
defaultLBName := az.getAzureLoadBalancerName(clusterName, primaryVMSetName, isInternal)
|
||||||
|
|
||||||
existingLBs, err := az.ListLBWithRetry()
|
existingLBs, err := az.ListLBWithRetry()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -280,7 +286,7 @@ func (az *Cloud) selectLoadBalancer(clusterName string, service *v1.Service, exi
|
|||||||
}
|
}
|
||||||
selectedLBRuleCount := math.MaxInt32
|
selectedLBRuleCount := math.MaxInt32
|
||||||
for _, currASName := range *vmSetNames {
|
for _, currASName := range *vmSetNames {
|
||||||
currLBName := az.getLoadBalancerName(clusterName, currASName, isInternal)
|
currLBName := az.getAzureLoadBalancerName(clusterName, currASName, isInternal)
|
||||||
lb, exists := mapExistingLBs[currLBName]
|
lb, exists := mapExistingLBs[currLBName]
|
||||||
if !exists {
|
if !exists {
|
||||||
// select this LB as this is a new LB and will have minimum rules
|
// select this LB as this is a new LB and will have minimum rules
|
||||||
@ -330,7 +336,7 @@ func (az *Cloud) getServiceLoadBalancerStatus(service *v1.Service, lb *network.L
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
isInternal := requiresInternalLoadBalancer(service)
|
isInternal := requiresInternalLoadBalancer(service)
|
||||||
lbFrontendIPConfigName := getFrontendIPConfigName(service, subnet(service))
|
lbFrontendIPConfigName := az.getFrontendIPConfigName(service, subnet(service))
|
||||||
serviceName := getServiceName(service)
|
serviceName := getServiceName(service)
|
||||||
for _, ipConfiguration := range *lb.FrontendIPConfigurations {
|
for _, ipConfiguration := range *lb.FrontendIPConfigurations {
|
||||||
if lbFrontendIPConfigName == *ipConfiguration.Name {
|
if lbFrontendIPConfigName == *ipConfiguration.Name {
|
||||||
@ -369,7 +375,7 @@ func (az *Cloud) getServiceLoadBalancerStatus(service *v1.Service, lb *network.L
|
|||||||
func (az *Cloud) determinePublicIPName(clusterName string, service *v1.Service) (string, error) {
|
func (az *Cloud) determinePublicIPName(clusterName string, service *v1.Service) (string, error) {
|
||||||
loadBalancerIP := service.Spec.LoadBalancerIP
|
loadBalancerIP := service.Spec.LoadBalancerIP
|
||||||
if len(loadBalancerIP) == 0 {
|
if len(loadBalancerIP) == 0 {
|
||||||
return getPublicIPName(clusterName, service), nil
|
return az.getPublicIPName(clusterName, service), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
pipResourceGroup := az.getPublicIPAddressResourceGroup(service)
|
pipResourceGroup := az.getPublicIPAddressResourceGroup(service)
|
||||||
@ -511,7 +517,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
|
|||||||
}
|
}
|
||||||
lbName := *lb.Name
|
lbName := *lb.Name
|
||||||
glog.V(2).Infof("reconcileLoadBalancer for service(%s): lb(%s) wantLb(%t) resolved load balancer name", serviceName, lbName, wantLb)
|
glog.V(2).Infof("reconcileLoadBalancer for service(%s): lb(%s) wantLb(%t) resolved load balancer name", serviceName, lbName, wantLb)
|
||||||
lbFrontendIPConfigName := getFrontendIPConfigName(service, subnet(service))
|
lbFrontendIPConfigName := az.getFrontendIPConfigName(service, subnet(service))
|
||||||
lbFrontendIPConfigID := az.getFrontendIPConfigID(lbName, lbFrontendIPConfigName)
|
lbFrontendIPConfigID := az.getFrontendIPConfigID(lbName, lbFrontendIPConfigName)
|
||||||
lbBackendPoolName := getBackendPoolName(clusterName)
|
lbBackendPoolName := getBackendPoolName(clusterName)
|
||||||
lbBackendPoolID := az.getBackendPoolID(lbName, lbBackendPoolName)
|
lbBackendPoolID := az.getBackendPoolID(lbName, lbBackendPoolName)
|
||||||
@ -561,7 +567,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
|
|||||||
if !wantLb {
|
if !wantLb {
|
||||||
for i := len(newConfigs) - 1; i >= 0; i-- {
|
for i := len(newConfigs) - 1; i >= 0; i-- {
|
||||||
config := newConfigs[i]
|
config := newConfigs[i]
|
||||||
if serviceOwnsFrontendIP(config, service) {
|
if az.serviceOwnsFrontendIP(config, service) {
|
||||||
glog.V(2).Infof("reconcileLoadBalancer for service (%s)(%t): lb frontendconfig(%s) - dropping", serviceName, wantLb, lbFrontendIPConfigName)
|
glog.V(2).Infof("reconcileLoadBalancer for service (%s)(%t): lb frontendconfig(%s) - dropping", serviceName, wantLb, lbFrontendIPConfigName)
|
||||||
newConfigs = append(newConfigs[:i], newConfigs[i+1:]...)
|
newConfigs = append(newConfigs[:i], newConfigs[i+1:]...)
|
||||||
dirtyConfigs = true
|
dirtyConfigs = true
|
||||||
@ -571,7 +577,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
|
|||||||
if isInternal {
|
if isInternal {
|
||||||
for i := len(newConfigs) - 1; i >= 0; i-- {
|
for i := len(newConfigs) - 1; i >= 0; i-- {
|
||||||
config := newConfigs[i]
|
config := newConfigs[i]
|
||||||
if serviceOwnsFrontendIP(config, service) && !strings.EqualFold(*config.Name, lbFrontendIPConfigName) {
|
if az.serviceOwnsFrontendIP(config, service) && !strings.EqualFold(*config.Name, lbFrontendIPConfigName) {
|
||||||
glog.V(2).Infof("reconcileLoadBalancer for service (%s)(%t): lb frontendconfig(%s) - dropping", serviceName, wantLb, *config.Name)
|
glog.V(2).Infof("reconcileLoadBalancer for service (%s)(%t): lb frontendconfig(%s) - dropping", serviceName, wantLb, *config.Name)
|
||||||
newConfigs = append(newConfigs[:i], newConfigs[i+1:]...)
|
newConfigs = append(newConfigs[:i], newConfigs[i+1:]...)
|
||||||
dirtyConfigs = true
|
dirtyConfigs = true
|
||||||
@ -656,7 +662,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
|
|||||||
var expectedProbes []network.Probe
|
var expectedProbes []network.Probe
|
||||||
var expectedRules []network.LoadBalancingRule
|
var expectedRules []network.LoadBalancingRule
|
||||||
for _, port := range ports {
|
for _, port := range ports {
|
||||||
lbRuleName := getLoadBalancerRuleName(service, port, subnet(service))
|
lbRuleName := az.getLoadBalancerRuleName(service, port, subnet(service))
|
||||||
|
|
||||||
transportProto, _, probeProto, err := getProtocolsFromKubernetesProtocol(port.Protocol)
|
transportProto, _, probeProto, err := getProtocolsFromKubernetesProtocol(port.Protocol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -739,7 +745,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
|
|||||||
}
|
}
|
||||||
for i := len(updatedProbes) - 1; i >= 0; i-- {
|
for i := len(updatedProbes) - 1; i >= 0; i-- {
|
||||||
existingProbe := updatedProbes[i]
|
existingProbe := updatedProbes[i]
|
||||||
if serviceOwnsRule(service, *existingProbe.Name) {
|
if az.serviceOwnsRule(service, *existingProbe.Name) {
|
||||||
glog.V(10).Infof("reconcileLoadBalancer for service (%s)(%t): lb probe(%s) - considering evicting", serviceName, wantLb, *existingProbe.Name)
|
glog.V(10).Infof("reconcileLoadBalancer for service (%s)(%t): lb probe(%s) - considering evicting", serviceName, wantLb, *existingProbe.Name)
|
||||||
keepProbe := false
|
keepProbe := false
|
||||||
if findProbe(expectedProbes, existingProbe) {
|
if findProbe(expectedProbes, existingProbe) {
|
||||||
@ -780,7 +786,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
|
|||||||
// update rules: remove unwanted
|
// update rules: remove unwanted
|
||||||
for i := len(updatedRules) - 1; i >= 0; i-- {
|
for i := len(updatedRules) - 1; i >= 0; i-- {
|
||||||
existingRule := updatedRules[i]
|
existingRule := updatedRules[i]
|
||||||
if serviceOwnsRule(service, *existingRule.Name) {
|
if az.serviceOwnsRule(service, *existingRule.Name) {
|
||||||
keepRule := false
|
keepRule := false
|
||||||
glog.V(10).Infof("reconcileLoadBalancer for service (%s)(%t): lb rule(%s) - considering evicting", serviceName, wantLb, *existingRule.Name)
|
glog.V(10).Infof("reconcileLoadBalancer for service (%s)(%t): lb rule(%s) - considering evicting", serviceName, wantLb, *existingRule.Name)
|
||||||
if findRule(expectedRules, existingRule) {
|
if findRule(expectedRules, existingRule) {
|
||||||
@ -939,7 +945,7 @@ func (az *Cloud) reconcileSecurityGroup(clusterName string, service *v1.Service,
|
|||||||
}
|
}
|
||||||
for j := range sourceAddressPrefixes {
|
for j := range sourceAddressPrefixes {
|
||||||
ix := i*len(sourceAddressPrefixes) + j
|
ix := i*len(sourceAddressPrefixes) + j
|
||||||
securityRuleName := getSecurityRuleName(service, port, sourceAddressPrefixes[j])
|
securityRuleName := az.getSecurityRuleName(service, port, sourceAddressPrefixes[j])
|
||||||
expectedSecurityRules[ix] = network.SecurityRule{
|
expectedSecurityRules[ix] = network.SecurityRule{
|
||||||
Name: to.StringPtr(securityRuleName),
|
Name: to.StringPtr(securityRuleName),
|
||||||
SecurityRulePropertiesFormat: &network.SecurityRulePropertiesFormat{
|
SecurityRulePropertiesFormat: &network.SecurityRulePropertiesFormat{
|
||||||
@ -975,7 +981,7 @@ func (az *Cloud) reconcileSecurityGroup(clusterName string, service *v1.Service,
|
|||||||
// to this service
|
// to this service
|
||||||
for i := len(updatedRules) - 1; i >= 0; i-- {
|
for i := len(updatedRules) - 1; i >= 0; i-- {
|
||||||
existingRule := updatedRules[i]
|
existingRule := updatedRules[i]
|
||||||
if serviceOwnsRule(service, *existingRule.Name) {
|
if az.serviceOwnsRule(service, *existingRule.Name) {
|
||||||
glog.V(10).Infof("reconcile(%s)(%t): sg rule(%s) - considering evicting", serviceName, wantLb, *existingRule.Name)
|
glog.V(10).Infof("reconcile(%s)(%t): sg rule(%s) - considering evicting", serviceName, wantLb, *existingRule.Name)
|
||||||
keepRule := false
|
keepRule := false
|
||||||
if findSecurityRule(expectedSecurityRules, existingRule) {
|
if findSecurityRule(expectedSecurityRules, existingRule) {
|
||||||
@ -994,7 +1000,7 @@ func (az *Cloud) reconcileSecurityGroup(clusterName string, service *v1.Service,
|
|||||||
if useSharedSecurityRule(service) && !wantLb {
|
if useSharedSecurityRule(service) && !wantLb {
|
||||||
for _, port := range ports {
|
for _, port := range ports {
|
||||||
for _, sourceAddressPrefix := range sourceAddressPrefixes {
|
for _, sourceAddressPrefix := range sourceAddressPrefixes {
|
||||||
sharedRuleName := getSecurityRuleName(service, port, sourceAddressPrefix)
|
sharedRuleName := az.getSecurityRuleName(service, port, sourceAddressPrefix)
|
||||||
sharedIndex, sharedRule, sharedRuleFound := findSecurityRuleByName(updatedRules, sharedRuleName)
|
sharedIndex, sharedRule, sharedRuleFound := findSecurityRuleByName(updatedRules, sharedRuleName)
|
||||||
if !sharedRuleFound {
|
if !sharedRuleFound {
|
||||||
glog.V(4).Infof("Expected to find shared rule %s for service %s being deleted, but did not", sharedRuleName, service.Name)
|
glog.V(4).Infof("Expected to find shared rule %s for service %s being deleted, but did not", sharedRuleName, service.Name)
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package azure
|
package azure
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash/crc32"
|
"hash/crc32"
|
||||||
@ -123,7 +124,7 @@ func (az *Cloud) mapLoadBalancerNameToVMSet(lbName string, clusterName string) (
|
|||||||
// Thus Azure do not allow mixed type (public and internal) load balancer.
|
// Thus Azure do not allow mixed type (public and internal) load balancer.
|
||||||
// So we'd have a separate name for internal load balancer.
|
// So we'd have a separate name for internal load balancer.
|
||||||
// This would be the name for Azure LoadBalancer resource.
|
// This would be the name for Azure LoadBalancer resource.
|
||||||
func (az *Cloud) getLoadBalancerName(clusterName string, vmSetName string, isInternal bool) string {
|
func (az *Cloud) getAzureLoadBalancerName(clusterName string, vmSetName string, isInternal bool) string {
|
||||||
lbNamePrefix := vmSetName
|
lbNamePrefix := vmSetName
|
||||||
if strings.EqualFold(vmSetName, az.vmSet.GetPrimaryVMSetName()) || az.useStandardLoadBalancer() {
|
if strings.EqualFold(vmSetName, az.vmSet.GetPrimaryVMSetName()) || az.useStandardLoadBalancer() {
|
||||||
lbNamePrefix = clusterName
|
lbNamePrefix = clusterName
|
||||||
@ -220,20 +221,22 @@ func getBackendPoolName(clusterName string) string {
|
|||||||
return clusterName
|
return clusterName
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLoadBalancerRuleName(service *v1.Service, port v1.ServicePort, subnetName *string) string {
|
func (az *Cloud) getLoadBalancerRuleName(service *v1.Service, port v1.ServicePort, subnetName *string) string {
|
||||||
|
prefix := az.getRulePrefix(service)
|
||||||
if subnetName == nil {
|
if subnetName == nil {
|
||||||
return fmt.Sprintf("%s-%s-%d", getRulePrefix(service), port.Protocol, port.Port)
|
return fmt.Sprintf("%s-%s-%d", prefix, port.Protocol, port.Port)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s-%s-%s-%d", getRulePrefix(service), *subnetName, port.Protocol, port.Port)
|
return fmt.Sprintf("%s-%s-%s-%d", prefix, *subnetName, port.Protocol, port.Port)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSecurityRuleName(service *v1.Service, port v1.ServicePort, sourceAddrPrefix string) string {
|
func (az *Cloud) getSecurityRuleName(service *v1.Service, port v1.ServicePort, sourceAddrPrefix string) string {
|
||||||
if useSharedSecurityRule(service) {
|
if useSharedSecurityRule(service) {
|
||||||
safePrefix := strings.Replace(sourceAddrPrefix, "/", "_", -1)
|
safePrefix := strings.Replace(sourceAddrPrefix, "/", "_", -1)
|
||||||
return fmt.Sprintf("shared-%s-%d-%s", port.Protocol, port.Port, safePrefix)
|
return fmt.Sprintf("shared-%s-%d-%s", port.Protocol, port.Port, safePrefix)
|
||||||
}
|
}
|
||||||
safePrefix := strings.Replace(sourceAddrPrefix, "/", "_", -1)
|
safePrefix := strings.Replace(sourceAddrPrefix, "/", "_", -1)
|
||||||
return fmt.Sprintf("%s-%s-%d-%s", getRulePrefix(service), port.Protocol, port.Port, safePrefix)
|
rulePrefix := az.getRulePrefix(service)
|
||||||
|
return fmt.Sprintf("%s-%s-%d-%s", rulePrefix, port.Protocol, port.Port, safePrefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This returns a human-readable version of the Service used to tag some resources.
|
// This returns a human-readable version of the Service used to tag some resources.
|
||||||
@ -243,26 +246,26 @@ func getServiceName(service *v1.Service) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This returns a prefix for loadbalancer/security rules.
|
// This returns a prefix for loadbalancer/security rules.
|
||||||
func getRulePrefix(service *v1.Service) string {
|
func (az *Cloud) getRulePrefix(service *v1.Service) string {
|
||||||
return cloudprovider.GetLoadBalancerName(service)
|
return az.GetLoadBalancerName(context.TODO(), "", service)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPublicIPName(clusterName string, service *v1.Service) string {
|
func (az *Cloud) getPublicIPName(clusterName string, service *v1.Service) string {
|
||||||
return fmt.Sprintf("%s-%s", clusterName, cloudprovider.GetLoadBalancerName(service))
|
return fmt.Sprintf("%s-%s", clusterName, az.GetLoadBalancerName(context.TODO(), clusterName, service))
|
||||||
}
|
}
|
||||||
|
|
||||||
func serviceOwnsRule(service *v1.Service, rule string) bool {
|
func (az *Cloud) serviceOwnsRule(service *v1.Service, rule string) bool {
|
||||||
prefix := getRulePrefix(service)
|
prefix := az.getRulePrefix(service)
|
||||||
return strings.HasPrefix(strings.ToUpper(rule), strings.ToUpper(prefix))
|
return strings.HasPrefix(strings.ToUpper(rule), strings.ToUpper(prefix))
|
||||||
}
|
}
|
||||||
|
|
||||||
func serviceOwnsFrontendIP(fip network.FrontendIPConfiguration, service *v1.Service) bool {
|
func (az *Cloud) serviceOwnsFrontendIP(fip network.FrontendIPConfiguration, service *v1.Service) bool {
|
||||||
baseName := cloudprovider.GetLoadBalancerName(service)
|
baseName := az.GetLoadBalancerName(context.TODO(), "", service)
|
||||||
return strings.HasPrefix(*fip.Name, baseName)
|
return strings.HasPrefix(*fip.Name, baseName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFrontendIPConfigName(service *v1.Service, subnetName *string) string {
|
func (az *Cloud) getFrontendIPConfigName(service *v1.Service, subnetName *string) string {
|
||||||
baseName := cloudprovider.GetLoadBalancerName(service)
|
baseName := az.GetLoadBalancerName(context.TODO(), "", service)
|
||||||
if subnetName != nil {
|
if subnetName != nil {
|
||||||
return fmt.Sprintf("%s-%s", baseName, *subnetName)
|
return fmt.Sprintf("%s-%s", baseName, *subnetName)
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ func TestMapLoadBalancerNameToVMSet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetLoadBalancerName(t *testing.T) {
|
func TestGetAzureLoadBalancerName(t *testing.T) {
|
||||||
az := getTestCloud()
|
az := getTestCloud()
|
||||||
az.PrimaryAvailabilitySetName = "primary"
|
az.PrimaryAvailabilitySetName = "primary"
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ func TestGetLoadBalancerName(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
az.Config.LoadBalancerSku = loadBalancerSkuBasic
|
az.Config.LoadBalancerSku = loadBalancerSkuBasic
|
||||||
}
|
}
|
||||||
loadbalancerName := az.getLoadBalancerName(c.clusterName, c.vmSet, c.isInternal)
|
loadbalancerName := az.getAzureLoadBalancerName(c.clusterName, c.vmSet, c.isInternal)
|
||||||
assert.Equal(t, c.expected, loadbalancerName, c.description)
|
assert.Equal(t, c.expected, loadbalancerName, c.description)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1163,7 +1163,7 @@ func getTestSecurityGroup(az *Cloud, services ...v1.Service) *network.SecurityGr
|
|||||||
for _, port := range service.Spec.Ports {
|
for _, port := range service.Spec.Ports {
|
||||||
sources := getServiceSourceRanges(&service)
|
sources := getServiceSourceRanges(&service)
|
||||||
for _, src := range sources {
|
for _, src := range sources {
|
||||||
ruleName := getSecurityRuleName(&service, port, src)
|
ruleName := az.getSecurityRuleName(&service, port, src)
|
||||||
rules = append(rules, network.SecurityRule{
|
rules = append(rules, network.SecurityRule{
|
||||||
Name: to.StringPtr(ruleName),
|
Name: to.StringPtr(ruleName),
|
||||||
SecurityRulePropertiesFormat: &network.SecurityRulePropertiesFormat{
|
SecurityRulePropertiesFormat: &network.SecurityRulePropertiesFormat{
|
||||||
@ -1194,6 +1194,7 @@ func getTestSecurityGroup(az *Cloud, services ...v1.Service) *network.SecurityGr
|
|||||||
}
|
}
|
||||||
|
|
||||||
func validateLoadBalancer(t *testing.T, loadBalancer *network.LoadBalancer, services ...v1.Service) {
|
func validateLoadBalancer(t *testing.T, loadBalancer *network.LoadBalancer, services ...v1.Service) {
|
||||||
|
az := getTestCloud()
|
||||||
expectedRuleCount := 0
|
expectedRuleCount := 0
|
||||||
expectedFrontendIPCount := 0
|
expectedFrontendIPCount := 0
|
||||||
expectedProbeCount := 0
|
expectedProbeCount := 0
|
||||||
@ -1202,14 +1203,14 @@ func validateLoadBalancer(t *testing.T, loadBalancer *network.LoadBalancer, serv
|
|||||||
if len(svc.Spec.Ports) > 0 {
|
if len(svc.Spec.Ports) > 0 {
|
||||||
expectedFrontendIPCount++
|
expectedFrontendIPCount++
|
||||||
expectedFrontendIP := ExpectedFrontendIPInfo{
|
expectedFrontendIP := ExpectedFrontendIPInfo{
|
||||||
Name: getFrontendIPConfigName(&svc, subnet(&svc)),
|
Name: az.getFrontendIPConfigName(&svc, subnet(&svc)),
|
||||||
Subnet: subnet(&svc),
|
Subnet: subnet(&svc),
|
||||||
}
|
}
|
||||||
expectedFrontendIPs = append(expectedFrontendIPs, expectedFrontendIP)
|
expectedFrontendIPs = append(expectedFrontendIPs, expectedFrontendIP)
|
||||||
}
|
}
|
||||||
for _, wantedRule := range svc.Spec.Ports {
|
for _, wantedRule := range svc.Spec.Ports {
|
||||||
expectedRuleCount++
|
expectedRuleCount++
|
||||||
wantedRuleName := getLoadBalancerRuleName(&svc, wantedRule, subnet(&svc))
|
wantedRuleName := az.getLoadBalancerRuleName(&svc, wantedRule, subnet(&svc))
|
||||||
foundRule := false
|
foundRule := false
|
||||||
for _, actualRule := range *loadBalancer.LoadBalancingRules {
|
for _, actualRule := range *loadBalancer.LoadBalancingRules {
|
||||||
if strings.EqualFold(*actualRule.Name, wantedRuleName) &&
|
if strings.EqualFold(*actualRule.Name, wantedRuleName) &&
|
||||||
@ -1400,12 +1401,13 @@ func securityRuleMatches(serviceSourceRange string, servicePort v1.ServicePort,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func validateSecurityGroup(t *testing.T, securityGroup *network.SecurityGroup, services ...v1.Service) {
|
func validateSecurityGroup(t *testing.T, securityGroup *network.SecurityGroup, services ...v1.Service) {
|
||||||
|
az := getTestCloud()
|
||||||
seenRules := make(map[string]string)
|
seenRules := make(map[string]string)
|
||||||
for _, svc := range services {
|
for _, svc := range services {
|
||||||
for _, wantedRule := range svc.Spec.Ports {
|
for _, wantedRule := range svc.Spec.Ports {
|
||||||
sources := getServiceSourceRanges(&svc)
|
sources := getServiceSourceRanges(&svc)
|
||||||
for _, source := range sources {
|
for _, source := range sources {
|
||||||
wantedRuleName := getSecurityRuleName(&svc, wantedRule, source)
|
wantedRuleName := az.getSecurityRuleName(&svc, wantedRule, source)
|
||||||
seenRules[wantedRuleName] = wantedRuleName
|
seenRules[wantedRuleName] = wantedRuleName
|
||||||
foundRule := false
|
foundRule := false
|
||||||
for _, actualRule := range *securityGroup.SecurityRules {
|
for _, actualRule := range *securityGroup.SecurityRules {
|
||||||
@ -2571,8 +2573,8 @@ func TestCanCombineSharedAndPrivateRulesInSameGroup(t *testing.T) {
|
|||||||
|
|
||||||
expectedRuleName13 := "shared-TCP-4444-Internet"
|
expectedRuleName13 := "shared-TCP-4444-Internet"
|
||||||
expectedRuleName2 := "shared-TCP-8888-Internet"
|
expectedRuleName2 := "shared-TCP-8888-Internet"
|
||||||
expectedRuleName4 := getSecurityRuleName(&svc4, v1.ServicePort{Port: 4444, Protocol: v1.ProtocolTCP}, "Internet")
|
expectedRuleName4 := az.getSecurityRuleName(&svc4, v1.ServicePort{Port: 4444, Protocol: v1.ProtocolTCP}, "Internet")
|
||||||
expectedRuleName5 := getSecurityRuleName(&svc5, v1.ServicePort{Port: 8888, Protocol: v1.ProtocolTCP}, "Internet")
|
expectedRuleName5 := az.getSecurityRuleName(&svc5, v1.ServicePort{Port: 8888, Protocol: v1.ProtocolTCP}, "Internet")
|
||||||
|
|
||||||
sg := getTestSecurityGroup(az)
|
sg := getTestSecurityGroup(az)
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/xanzy/go-cloudstack/cloudstack"
|
"github.com/xanzy/go-cloudstack/cloudstack"
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type loadBalancer struct {
|
type loadBalancer struct {
|
||||||
@ -238,11 +237,16 @@ func (cs *CSCloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName st
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetLoadBalancerName retrieves the name of the LoadBalancer.
|
||||||
|
func (cs *CSCloud) GetLoadBalancerName(ctx context.Context, clusterName string, service *v1.Service) string {
|
||||||
|
return cs.GetLoadBalancerName(ctx, clusterName, service)
|
||||||
|
}
|
||||||
|
|
||||||
// getLoadBalancer retrieves the IP address and ID and all the existing rules it can find.
|
// getLoadBalancer retrieves the IP address and ID and all the existing rules it can find.
|
||||||
func (cs *CSCloud) getLoadBalancer(service *v1.Service) (*loadBalancer, error) {
|
func (cs *CSCloud) getLoadBalancer(service *v1.Service) (*loadBalancer, error) {
|
||||||
lb := &loadBalancer{
|
lb := &loadBalancer{
|
||||||
CloudStackClient: cs.client,
|
CloudStackClient: cs.client,
|
||||||
name: cloudprovider.GetLoadBalancerName(service),
|
name: cs.GetLoadBalancerName(context.TODO(), "", service),
|
||||||
projectID: cs.projectID,
|
projectID: cs.projectID,
|
||||||
rules: make(map[string]*cloudstack.LoadBalancerRule),
|
rules: make(map[string]*cloudstack.LoadBalancerRule),
|
||||||
}
|
}
|
||||||
|
@ -154,6 +154,11 @@ func (f *FakeCloud) GetLoadBalancer(ctx context.Context, clusterName string, ser
|
|||||||
return status, f.Exists, f.Err
|
return status, f.Exists, f.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetLoadBalancerName is a stub implementation of LoadBalancer.GetLoadBalancerName.
|
||||||
|
func (f *FakeCloud) GetLoadBalancerName(ctx context.Context, clusterName string, service *v1.Service) string {
|
||||||
|
return cloudprovider.DefaultLoadBalancerName(service)
|
||||||
|
}
|
||||||
|
|
||||||
// EnsureLoadBalancer is a test-spy implementation of LoadBalancer.EnsureLoadBalancer.
|
// EnsureLoadBalancer is a test-spy implementation of LoadBalancer.EnsureLoadBalancer.
|
||||||
// It adds an entry "create" into the internal method call record.
|
// It adds an entry "create" into the internal method call record.
|
||||||
func (f *FakeCloud) EnsureLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) {
|
func (f *FakeCloud) EnsureLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) {
|
||||||
@ -162,7 +167,7 @@ func (f *FakeCloud) EnsureLoadBalancer(ctx context.Context, clusterName string,
|
|||||||
f.Balancers = make(map[string]FakeBalancer)
|
f.Balancers = make(map[string]FakeBalancer)
|
||||||
}
|
}
|
||||||
|
|
||||||
name := cloudprovider.GetLoadBalancerName(service)
|
name := f.GetLoadBalancerName(ctx, clusterName, service)
|
||||||
spec := service.Spec
|
spec := service.Spec
|
||||||
|
|
||||||
zone, err := f.GetZone(context.TODO())
|
zone, err := f.GetZone(context.TODO())
|
||||||
|
@ -92,7 +92,7 @@ func LoadBalancerSrcRanges() []string {
|
|||||||
|
|
||||||
// GetLoadBalancer is an implementation of LoadBalancer.GetLoadBalancer
|
// GetLoadBalancer is an implementation of LoadBalancer.GetLoadBalancer
|
||||||
func (gce *GCECloud) GetLoadBalancer(ctx context.Context, clusterName string, svc *v1.Service) (*v1.LoadBalancerStatus, bool, error) {
|
func (gce *GCECloud) GetLoadBalancer(ctx context.Context, clusterName string, svc *v1.Service) (*v1.LoadBalancerStatus, bool, error) {
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(svc)
|
loadBalancerName := gce.GetLoadBalancerName(ctx, clusterName, svc)
|
||||||
fwd, err := gce.GetRegionForwardingRule(loadBalancerName, gce.region)
|
fwd, err := gce.GetRegionForwardingRule(loadBalancerName, gce.region)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
status := &v1.LoadBalancerStatus{}
|
status := &v1.LoadBalancerStatus{}
|
||||||
@ -103,9 +103,14 @@ func (gce *GCECloud) GetLoadBalancer(ctx context.Context, clusterName string, sv
|
|||||||
return nil, false, ignoreNotFound(err)
|
return nil, false, ignoreNotFound(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetLoadBalancerName is an implementation of LoadBalancer.GetLoadBalancerName.
|
||||||
|
func (gce *GCECloud) GetLoadBalancerName(ctx context.Context, clusterName string, svc *v1.Service) string {
|
||||||
|
return cloudprovider.DefaultLoadBalancerName(svc)
|
||||||
|
}
|
||||||
|
|
||||||
// EnsureLoadBalancer is an implementation of LoadBalancer.EnsureLoadBalancer.
|
// EnsureLoadBalancer is an implementation of LoadBalancer.EnsureLoadBalancer.
|
||||||
func (gce *GCECloud) EnsureLoadBalancer(ctx context.Context, clusterName string, svc *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) {
|
func (gce *GCECloud) EnsureLoadBalancer(ctx context.Context, clusterName string, svc *v1.Service, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) {
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(svc)
|
loadBalancerName := gce.GetLoadBalancerName(ctx, clusterName, svc)
|
||||||
desiredScheme := getSvcScheme(svc)
|
desiredScheme := getSvcScheme(svc)
|
||||||
clusterID, err := gce.ClusterID.GetID()
|
clusterID, err := gce.ClusterID.GetID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -154,7 +159,7 @@ func (gce *GCECloud) EnsureLoadBalancer(ctx context.Context, clusterName string,
|
|||||||
|
|
||||||
// UpdateLoadBalancer is an implementation of LoadBalancer.UpdateLoadBalancer.
|
// UpdateLoadBalancer is an implementation of LoadBalancer.UpdateLoadBalancer.
|
||||||
func (gce *GCECloud) UpdateLoadBalancer(ctx context.Context, clusterName string, svc *v1.Service, nodes []*v1.Node) error {
|
func (gce *GCECloud) UpdateLoadBalancer(ctx context.Context, clusterName string, svc *v1.Service, nodes []*v1.Node) error {
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(svc)
|
loadBalancerName := gce.GetLoadBalancerName(ctx, clusterName, svc)
|
||||||
scheme := getSvcScheme(svc)
|
scheme := getSvcScheme(svc)
|
||||||
clusterID, err := gce.ClusterID.GetID()
|
clusterID, err := gce.ClusterID.GetID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -175,7 +180,7 @@ func (gce *GCECloud) UpdateLoadBalancer(ctx context.Context, clusterName string,
|
|||||||
|
|
||||||
// EnsureLoadBalancerDeleted is an implementation of LoadBalancer.EnsureLoadBalancerDeleted.
|
// EnsureLoadBalancerDeleted is an implementation of LoadBalancer.EnsureLoadBalancerDeleted.
|
||||||
func (gce *GCECloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, svc *v1.Service) error {
|
func (gce *GCECloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, svc *v1.Service) error {
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(svc)
|
loadBalancerName := gce.GetLoadBalancerName(ctx, clusterName, svc)
|
||||||
scheme := getSvcScheme(svc)
|
scheme := getSvcScheme(svc)
|
||||||
clusterID, err := gce.ClusterID.GetID()
|
clusterID, err := gce.ClusterID.GetID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package gce
|
package gce
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -27,7 +28,6 @@ import (
|
|||||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
apiservice "k8s.io/kubernetes/pkg/api/v1/service"
|
apiservice "k8s.io/kubernetes/pkg/api/v1/service"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider"
|
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud"
|
||||||
netsets "k8s.io/kubernetes/pkg/util/net/sets"
|
netsets "k8s.io/kubernetes/pkg/util/net/sets"
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ import (
|
|||||||
// Due to an interesting series of design decisions, this handles both creating
|
// Due to an interesting series of design decisions, this handles both creating
|
||||||
// new load balancers and updating existing load balancers, recognizing when
|
// new load balancers and updating existing load balancers, recognizing when
|
||||||
// each is needed.
|
// each is needed.
|
||||||
func (gce *GCECloud) ensureExternalLoadBalancer(clusterName, clusterID string, apiService *v1.Service, existingFwdRule *compute.ForwardingRule, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) {
|
func (gce *GCECloud) ensureExternalLoadBalancer(clusterName string, clusterID string, apiService *v1.Service, existingFwdRule *compute.ForwardingRule, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) {
|
||||||
if len(nodes) == 0 {
|
if len(nodes) == 0 {
|
||||||
return nil, fmt.Errorf("Cannot EnsureLoadBalancer() with no hosts")
|
return nil, fmt.Errorf("Cannot EnsureLoadBalancer() with no hosts")
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ func (gce *GCECloud) ensureExternalLoadBalancer(clusterName, clusterID string, a
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(apiService)
|
loadBalancerName := gce.GetLoadBalancerName(context.TODO(), clusterName, apiService)
|
||||||
requestedIP := apiService.Spec.LoadBalancerIP
|
requestedIP := apiService.Spec.LoadBalancerIP
|
||||||
ports := apiService.Spec.Ports
|
ports := apiService.Spec.Ports
|
||||||
portStr := []string{}
|
portStr := []string{}
|
||||||
@ -281,13 +281,13 @@ func (gce *GCECloud) updateExternalLoadBalancer(clusterName string, service *v1.
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(service)
|
loadBalancerName := gce.GetLoadBalancerName(context.TODO(), clusterName, service)
|
||||||
return gce.updateTargetPool(loadBalancerName, hosts)
|
return gce.updateTargetPool(loadBalancerName, hosts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensureExternalLoadBalancerDeleted is the external implementation of LoadBalancer.EnsureLoadBalancerDeleted
|
// ensureExternalLoadBalancerDeleted is the external implementation of LoadBalancer.EnsureLoadBalancerDeleted
|
||||||
func (gce *GCECloud) ensureExternalLoadBalancerDeleted(clusterName, clusterID string, service *v1.Service) error {
|
func (gce *GCECloud) ensureExternalLoadBalancerDeleted(clusterName, clusterID string, service *v1.Service) error {
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(service)
|
loadBalancerName := gce.GetLoadBalancerName(context.TODO(), clusterName, service)
|
||||||
serviceName := types.NamespacedName{Namespace: service.Namespace, Name: service.Name}
|
serviceName := types.NamespacedName{Namespace: service.Namespace, Name: service.Name}
|
||||||
lbRefStr := fmt.Sprintf("%v(%v)", loadBalancerName, serviceName)
|
lbRefStr := fmt.Sprintf("%v(%v)", loadBalancerName, serviceName)
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ import (
|
|||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/client-go/tools/record"
|
"k8s.io/client-go/tools/record"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider"
|
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/mock"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/mock"
|
||||||
@ -330,7 +329,7 @@ func TestUpdateExternalLoadBalancer(t *testing.T) {
|
|||||||
err = gce.updateExternalLoadBalancer("", svc, newNodes)
|
err = gce.updateExternalLoadBalancer("", svc, newNodes)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
lbName := cloudprovider.GetLoadBalancerName(svc)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
|
|
||||||
pool, err := gce.GetTargetPool(lbName, gce.region)
|
pool, err := gce.GetTargetPool(lbName, gce.region)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -401,7 +400,7 @@ func TestLoadBalancerWrongTierResourceDeletion(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, cloud.NetworkTierPremium, desiredTier)
|
assert.Equal(t, cloud.NetworkTierPremium, desiredTier)
|
||||||
|
|
||||||
lbName := cloudprovider.GetLoadBalancerName(svc)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
serviceName := types.NamespacedName{Namespace: svc.Namespace, Name: svc.Name}
|
serviceName := types.NamespacedName{Namespace: svc.Namespace, Name: svc.Name}
|
||||||
|
|
||||||
// create ForwardingRule and Address with the wrong tier
|
// create ForwardingRule and Address with the wrong tier
|
||||||
@ -484,7 +483,7 @@ func TestForwardingRuleNeedsUpdate(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
svc := fakeLoadbalancerService("")
|
svc := fakeLoadbalancerService("")
|
||||||
lbName := cloudprovider.GetLoadBalancerName(svc)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
ipAddr := status.Ingress[0].IP
|
ipAddr := status.Ingress[0].IP
|
||||||
|
|
||||||
lbIP := svc.Spec.LoadBalancerIP
|
lbIP := svc.Spec.LoadBalancerIP
|
||||||
@ -566,7 +565,7 @@ func TestTargetPoolNeedsRecreation(t *testing.T) {
|
|||||||
|
|
||||||
svc := fakeLoadbalancerService("")
|
svc := fakeLoadbalancerService("")
|
||||||
serviceName := svc.ObjectMeta.Name
|
serviceName := svc.ObjectMeta.Name
|
||||||
lbName := cloudprovider.GetLoadBalancerName(svc)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
nodes, err := createAndInsertNodes(gce, []string{"test-node-1"}, vals.ZoneName)
|
nodes, err := createAndInsertNodes(gce, []string{"test-node-1"}, vals.ZoneName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
hostNames := nodeNames(nodes)
|
hostNames := nodeNames(nodes)
|
||||||
@ -619,7 +618,7 @@ func TestFirewallNeedsUpdate(t *testing.T) {
|
|||||||
region := vals.Region
|
region := vals.Region
|
||||||
|
|
||||||
ipAddr := status.Ingress[0].IP
|
ipAddr := status.Ingress[0].IP
|
||||||
lbName := cloudprovider.GetLoadBalancerName(svc)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
|
|
||||||
ipnet, err := netsets.ParseIPNets("0.0.0.0/0")
|
ipnet, err := netsets.ParseIPNets("0.0.0.0/0")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -804,7 +803,7 @@ func TestEnsureTargetPoolAndHealthCheck(t *testing.T) {
|
|||||||
clusterID := vals.ClusterID
|
clusterID := vals.ClusterID
|
||||||
|
|
||||||
ipAddr := status.Ingress[0].IP
|
ipAddr := status.Ingress[0].IP
|
||||||
lbName := cloudprovider.GetLoadBalancerName(svc)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
region := vals.Region
|
region := vals.Region
|
||||||
|
|
||||||
hcToCreate := makeHttpHealthCheck(MakeNodesHealthCheckName(clusterID), GetNodesHealthCheckPath(), GetNodesHealthCheckPort())
|
hcToCreate := makeHttpHealthCheck(MakeNodesHealthCheckName(clusterID), GetNodesHealthCheckPath(), GetNodesHealthCheckPort())
|
||||||
@ -869,7 +868,7 @@ func TestCreateAndUpdateFirewallSucceedsOnXPN(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
gce.createFirewall(
|
gce.createFirewall(
|
||||||
svc,
|
svc,
|
||||||
cloudprovider.GetLoadBalancerName(svc),
|
gce.GetLoadBalancerName(context.TODO(), "", svc),
|
||||||
gce.region,
|
gce.region,
|
||||||
"A sad little firewall",
|
"A sad little firewall",
|
||||||
ipnet,
|
ipnet,
|
||||||
@ -882,7 +881,7 @@ func TestCreateAndUpdateFirewallSucceedsOnXPN(t *testing.T) {
|
|||||||
|
|
||||||
gce.updateFirewall(
|
gce.updateFirewall(
|
||||||
svc,
|
svc,
|
||||||
cloudprovider.GetLoadBalancerName(svc),
|
gce.GetLoadBalancerName(context.TODO(), "", svc),
|
||||||
gce.region,
|
gce.region,
|
||||||
"A sad little firewall",
|
"A sad little firewall",
|
||||||
ipnet,
|
ipnet,
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package gce
|
package gce
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -27,7 +28,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
v1_service "k8s.io/kubernetes/pkg/api/v1/service"
|
v1_service "k8s.io/kubernetes/pkg/api/v1/service"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider"
|
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ func (gce *GCECloud) ensureInternalLoadBalancer(clusterName, clusterID string, s
|
|||||||
nm := types.NamespacedName{Name: svc.Name, Namespace: svc.Namespace}
|
nm := types.NamespacedName{Name: svc.Name, Namespace: svc.Namespace}
|
||||||
ports, protocol := getPortsAndProtocol(svc.Spec.Ports)
|
ports, protocol := getPortsAndProtocol(svc.Spec.Ports)
|
||||||
scheme := cloud.SchemeInternal
|
scheme := cloud.SchemeInternal
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(svc)
|
loadBalancerName := gce.GetLoadBalancerName(context.TODO(), clusterName, svc)
|
||||||
sharedBackend := shareBackendService(svc)
|
sharedBackend := shareBackendService(svc)
|
||||||
backendServiceName := makeBackendServiceName(loadBalancerName, clusterID, sharedBackend, scheme, protocol, svc.Spec.SessionAffinity)
|
backendServiceName := makeBackendServiceName(loadBalancerName, clusterID, sharedBackend, scheme, protocol, svc.Spec.SessionAffinity)
|
||||||
backendServiceLink := gce.getBackendServiceLink(backendServiceName)
|
backendServiceLink := gce.getBackendServiceLink(backendServiceName)
|
||||||
@ -210,14 +210,14 @@ func (gce *GCECloud) updateInternalLoadBalancer(clusterName, clusterID string, s
|
|||||||
// Generate the backend service name
|
// Generate the backend service name
|
||||||
_, protocol := getPortsAndProtocol(svc.Spec.Ports)
|
_, protocol := getPortsAndProtocol(svc.Spec.Ports)
|
||||||
scheme := cloud.SchemeInternal
|
scheme := cloud.SchemeInternal
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(svc)
|
loadBalancerName := gce.GetLoadBalancerName(context.TODO(), clusterName, svc)
|
||||||
backendServiceName := makeBackendServiceName(loadBalancerName, clusterID, shareBackendService(svc), scheme, protocol, svc.Spec.SessionAffinity)
|
backendServiceName := makeBackendServiceName(loadBalancerName, clusterID, shareBackendService(svc), scheme, protocol, svc.Spec.SessionAffinity)
|
||||||
// Ensure the backend service has the proper backend/instance-group links
|
// Ensure the backend service has the proper backend/instance-group links
|
||||||
return gce.ensureInternalBackendServiceGroups(backendServiceName, igLinks)
|
return gce.ensureInternalBackendServiceGroups(backendServiceName, igLinks)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gce *GCECloud) ensureInternalLoadBalancerDeleted(clusterName, clusterID string, svc *v1.Service) error {
|
func (gce *GCECloud) ensureInternalLoadBalancerDeleted(clusterName, clusterID string, svc *v1.Service) error {
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(svc)
|
loadBalancerName := gce.GetLoadBalancerName(context.TODO(), clusterName, svc)
|
||||||
_, protocol := getPortsAndProtocol(svc.Spec.Ports)
|
_, protocol := getPortsAndProtocol(svc.Spec.Ports)
|
||||||
scheme := cloud.SchemeInternal
|
scheme := cloud.SchemeInternal
|
||||||
sharedBackend := shareBackendService(svc)
|
sharedBackend := shareBackendService(svc)
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package gce
|
package gce
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -29,7 +30,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/client-go/tools/record"
|
"k8s.io/client-go/tools/record"
|
||||||
v1_service "k8s.io/kubernetes/pkg/api/v1/service"
|
v1_service "k8s.io/kubernetes/pkg/api/v1/service"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider"
|
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/mock"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/mock"
|
||||||
)
|
)
|
||||||
@ -59,7 +59,7 @@ func TestEnsureInternalBackendServiceUpdates(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
svc := fakeLoadbalancerService(string(LBTypeInternal))
|
svc := fakeLoadbalancerService(string(LBTypeInternal))
|
||||||
lbName := cloudprovider.GetLoadBalancerName(svc)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
nodes, err := createAndInsertNodes(gce, nodeNames, vals.ZoneName)
|
nodes, err := createAndInsertNodes(gce, nodeNames, vals.ZoneName)
|
||||||
igName := makeInstanceGroupName(vals.ClusterID)
|
igName := makeInstanceGroupName(vals.ClusterID)
|
||||||
igLinks, err := gce.ensureInternalInstanceGroups(igName, nodes)
|
igLinks, err := gce.ensureInternalInstanceGroups(igName, nodes)
|
||||||
@ -105,7 +105,7 @@ func TestEnsureInternalBackendServiceGroups(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
svc := fakeLoadbalancerService(string(LBTypeInternal))
|
svc := fakeLoadbalancerService(string(LBTypeInternal))
|
||||||
lbName := cloudprovider.GetLoadBalancerName(svc)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
nodes, err := createAndInsertNodes(gce, nodeNames, vals.ZoneName)
|
nodes, err := createAndInsertNodes(gce, nodeNames, vals.ZoneName)
|
||||||
igName := makeInstanceGroupName(vals.ClusterID)
|
igName := makeInstanceGroupName(vals.ClusterID)
|
||||||
igLinks, err := gce.ensureInternalInstanceGroups(igName, nodes)
|
igLinks, err := gce.ensureInternalInstanceGroups(igName, nodes)
|
||||||
@ -167,7 +167,7 @@ func TestEnsureInternalLoadBalancerWithExistingResources(t *testing.T) {
|
|||||||
|
|
||||||
// Create the expected resources necessary for an Internal Load Balancer
|
// Create the expected resources necessary for an Internal Load Balancer
|
||||||
nm := types.NamespacedName{Name: svc.Name, Namespace: svc.Namespace}
|
nm := types.NamespacedName{Name: svc.Name, Namespace: svc.Namespace}
|
||||||
lbName := cloudprovider.GetLoadBalancerName(svc)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
|
|
||||||
sharedHealthCheck := !v1_service.RequestsOnlyLocalTraffic(svc)
|
sharedHealthCheck := !v1_service.RequestsOnlyLocalTraffic(svc)
|
||||||
hcName := makeHealthCheckName(lbName, vals.ClusterID, sharedHealthCheck)
|
hcName := makeHealthCheckName(lbName, vals.ClusterID, sharedHealthCheck)
|
||||||
@ -199,7 +199,7 @@ func TestEnsureInternalLoadBalancerClearPreviousResources(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
svc := fakeLoadbalancerService(string(LBTypeInternal))
|
svc := fakeLoadbalancerService(string(LBTypeInternal))
|
||||||
lbName := cloudprovider.GetLoadBalancerName(svc)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
|
|
||||||
// Create a ForwardingRule that's missing an IP address
|
// Create a ForwardingRule that's missing an IP address
|
||||||
existingFwdRule := &compute.ForwardingRule{
|
existingFwdRule := &compute.ForwardingRule{
|
||||||
@ -285,7 +285,7 @@ func TestUpdateInternalLoadBalancerBackendServices(t *testing.T) {
|
|||||||
// incorrect (missing) attributes.
|
// incorrect (missing) attributes.
|
||||||
// ensureInternalBackendServiceGroups is called and creates the correct
|
// ensureInternalBackendServiceGroups is called and creates the correct
|
||||||
// BackendService
|
// BackendService
|
||||||
lbName := cloudprovider.GetLoadBalancerName(svc)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
sharedBackend := shareBackendService(svc)
|
sharedBackend := shareBackendService(svc)
|
||||||
backendServiceName := makeBackendServiceName(lbName, vals.ClusterID, sharedBackend, cloud.SchemeInternal, "TCP", svc.Spec.SessionAffinity)
|
backendServiceName := makeBackendServiceName(lbName, vals.ClusterID, sharedBackend, cloud.SchemeInternal, "TCP", svc.Spec.SessionAffinity)
|
||||||
existingBS := &compute.BackendService{
|
existingBS := &compute.BackendService{
|
||||||
@ -349,7 +349,7 @@ func TestUpdateInternalLoadBalancerNodes(t *testing.T) {
|
|||||||
err = gce.updateInternalLoadBalancer(vals.ClusterName, vals.ClusterID, svc, nodes)
|
err = gce.updateInternalLoadBalancer(vals.ClusterName, vals.ClusterID, svc, nodes)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
lbName := cloudprovider.GetLoadBalancerName(svc)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
sharedBackend := shareBackendService(svc)
|
sharedBackend := shareBackendService(svc)
|
||||||
backendServiceName := makeBackendServiceName(lbName, vals.ClusterID, sharedBackend, cloud.SchemeInternal, "TCP", svc.Spec.SessionAffinity)
|
backendServiceName := makeBackendServiceName(lbName, vals.ClusterID, sharedBackend, cloud.SchemeInternal, "TCP", svc.Spec.SessionAffinity)
|
||||||
bs, err := gce.GetRegionBackendService(backendServiceName, gce.region)
|
bs, err := gce.GetRegionBackendService(backendServiceName, gce.region)
|
||||||
@ -442,7 +442,7 @@ func TestEnsureInternalLoadBalancerWithSpecialHealthCheck(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotEmpty(t, status.Ingress)
|
assert.NotEmpty(t, status.Ingress)
|
||||||
|
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(svc)
|
loadBalancerName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
hc, err := gce.GetHealthCheck(loadBalancerName)
|
hc, err := gce.GetHealthCheck(loadBalancerName)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotNil(t, hc)
|
assert.NotNil(t, hc)
|
||||||
@ -453,9 +453,9 @@ func TestClearPreviousInternalResources(t *testing.T) {
|
|||||||
// Configure testing environment.
|
// Configure testing environment.
|
||||||
vals := DefaultTestClusterValues()
|
vals := DefaultTestClusterValues()
|
||||||
svc := fakeLoadbalancerService(string(LBTypeInternal))
|
svc := fakeLoadbalancerService(string(LBTypeInternal))
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(svc)
|
|
||||||
nm := types.NamespacedName{Name: svc.Name, Namespace: svc.Namespace}
|
|
||||||
gce, err := fakeGCECloud(vals)
|
gce, err := fakeGCECloud(vals)
|
||||||
|
loadBalancerName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
|
nm := types.NamespacedName{Name: svc.Name, Namespace: svc.Namespace}
|
||||||
c := gce.c.(*cloud.MockGCE)
|
c := gce.c.(*cloud.MockGCE)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -516,7 +516,7 @@ func TestEnsureInternalFirewallSucceedsOnXPN(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
vals := DefaultTestClusterValues()
|
vals := DefaultTestClusterValues()
|
||||||
svc := fakeLoadbalancerService(string(LBTypeInternal))
|
svc := fakeLoadbalancerService(string(LBTypeInternal))
|
||||||
fwName := cloudprovider.GetLoadBalancerName(svc)
|
fwName := gce.GetLoadBalancerName(context.TODO(), "", svc)
|
||||||
|
|
||||||
c := gce.c.(*cloud.MockGCE)
|
c := gce.c.(*cloud.MockGCE)
|
||||||
c.MockFirewalls.InsertHook = mock.InsertFirewallsUnauthorizedErrHook
|
c.MockFirewalls.InsertHook = mock.InsertFirewallsUnauthorizedErrHook
|
||||||
|
@ -21,6 +21,7 @@ limitations under the License.
|
|||||||
package gce
|
package gce
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@ -37,7 +38,6 @@ import (
|
|||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/client-go/tools/record"
|
"k8s.io/client-go/tools/record"
|
||||||
v1_service "k8s.io/kubernetes/pkg/api/v1/service"
|
v1_service "k8s.io/kubernetes/pkg/api/v1/service"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider"
|
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/mock"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/mock"
|
||||||
@ -220,7 +220,7 @@ func fakeClusterID(clusterID string) ClusterID {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func assertExternalLbResources(t *testing.T, gce *GCECloud, apiService *v1.Service, vals TestClusterValues, nodeNames []string) {
|
func assertExternalLbResources(t *testing.T, gce *GCECloud, apiService *v1.Service, vals TestClusterValues, nodeNames []string) {
|
||||||
lbName := cloudprovider.GetLoadBalancerName(apiService)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", apiService)
|
||||||
hcName := MakeNodesHealthCheckName(vals.ClusterID)
|
hcName := MakeNodesHealthCheckName(vals.ClusterID)
|
||||||
|
|
||||||
// Check that Firewalls are created for the LoadBalancer and the HealthCheck
|
// Check that Firewalls are created for the LoadBalancer and the HealthCheck
|
||||||
@ -257,7 +257,7 @@ func assertExternalLbResources(t *testing.T, gce *GCECloud, apiService *v1.Servi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func assertExternalLbResourcesDeleted(t *testing.T, gce *GCECloud, apiService *v1.Service, vals TestClusterValues, firewallsDeleted bool) {
|
func assertExternalLbResourcesDeleted(t *testing.T, gce *GCECloud, apiService *v1.Service, vals TestClusterValues, firewallsDeleted bool) {
|
||||||
lbName := cloudprovider.GetLoadBalancerName(apiService)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", apiService)
|
||||||
hcName := MakeNodesHealthCheckName(vals.ClusterID)
|
hcName := MakeNodesHealthCheckName(vals.ClusterID)
|
||||||
|
|
||||||
if firewallsDeleted {
|
if firewallsDeleted {
|
||||||
@ -292,7 +292,7 @@ func assertExternalLbResourcesDeleted(t *testing.T, gce *GCECloud, apiService *v
|
|||||||
}
|
}
|
||||||
|
|
||||||
func assertInternalLbResources(t *testing.T, gce *GCECloud, apiService *v1.Service, vals TestClusterValues, nodeNames []string) {
|
func assertInternalLbResources(t *testing.T, gce *GCECloud, apiService *v1.Service, vals TestClusterValues, nodeNames []string) {
|
||||||
lbName := cloudprovider.GetLoadBalancerName(apiService)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", apiService)
|
||||||
|
|
||||||
// Check that Instance Group is created
|
// Check that Instance Group is created
|
||||||
igName := makeInstanceGroupName(vals.ClusterID)
|
igName := makeInstanceGroupName(vals.ClusterID)
|
||||||
@ -345,7 +345,7 @@ func assertInternalLbResources(t *testing.T, gce *GCECloud, apiService *v1.Servi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func assertInternalLbResourcesDeleted(t *testing.T, gce *GCECloud, apiService *v1.Service, vals TestClusterValues, firewallsDeleted bool) {
|
func assertInternalLbResourcesDeleted(t *testing.T, gce *GCECloud, apiService *v1.Service, vals TestClusterValues, firewallsDeleted bool) {
|
||||||
lbName := cloudprovider.GetLoadBalancerName(apiService)
|
lbName := gce.GetLoadBalancerName(context.TODO(), "", apiService)
|
||||||
sharedHealthCheck := !v1_service.RequestsOnlyLocalTraffic(apiService)
|
sharedHealthCheck := !v1_service.RequestsOnlyLocalTraffic(apiService)
|
||||||
hcName := makeHealthCheckName(lbName, vals.ClusterID, sharedHealthCheck)
|
hcName := makeHealthCheckName(lbName, vals.ClusterID, sharedHealthCheck)
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ func (lbaas *LbaasV2) createLoadBalancer(service *v1.Service, name string, inter
|
|||||||
|
|
||||||
// GetLoadBalancer returns whether the specified load balancer exists and its status
|
// GetLoadBalancer returns whether the specified load balancer exists and its status
|
||||||
func (lbaas *LbaasV2) GetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (*v1.LoadBalancerStatus, bool, error) {
|
func (lbaas *LbaasV2) GetLoadBalancer(ctx context.Context, clusterName string, service *v1.Service) (*v1.LoadBalancerStatus, bool, error) {
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(service)
|
loadBalancerName := lbaas.GetLoadBalancerName(ctx, clusterName, service)
|
||||||
loadbalancer, err := getLoadbalancerByName(lbaas.lb, loadBalancerName)
|
loadbalancer, err := getLoadbalancerByName(lbaas.lb, loadBalancerName)
|
||||||
if err == ErrNotFound {
|
if err == ErrNotFound {
|
||||||
return nil, false, nil
|
return nil, false, nil
|
||||||
@ -485,6 +485,11 @@ func (lbaas *LbaasV2) GetLoadBalancer(ctx context.Context, clusterName string, s
|
|||||||
return status, true, err
|
return status, true, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetLoadBalancerName is an implementation of LoadBalancer.GetLoadBalancerName.
|
||||||
|
func (lbaas *LbaasV2) GetLoadBalancerName(ctx context.Context, clusterName string, service *v1.Service) string {
|
||||||
|
return cloudprovider.DefaultLoadBalancerName(service)
|
||||||
|
}
|
||||||
|
|
||||||
// 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.
|
// guessing that the node's InternalIP is the right address.
|
||||||
@ -731,7 +736,7 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(ctx context.Context, clusterName string
|
|||||||
return nil, fmt.Errorf("unsupported load balancer affinity: %v", affinity)
|
return nil, fmt.Errorf("unsupported load balancer affinity: %v", affinity)
|
||||||
}
|
}
|
||||||
|
|
||||||
name := cloudprovider.GetLoadBalancerName(apiService)
|
name := lbaas.GetLoadBalancerName(ctx, clusterName, apiService)
|
||||||
loadbalancer, err := getLoadbalancerByName(lbaas.lb, name)
|
loadbalancer, err := getLoadbalancerByName(lbaas.lb, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != ErrNotFound {
|
if err != ErrNotFound {
|
||||||
@ -1173,7 +1178,7 @@ func (lbaas *LbaasV2) ensureSecurityGroup(clusterName string, apiService *v1.Ser
|
|||||||
|
|
||||||
// UpdateLoadBalancer updates hosts under the specified load balancer.
|
// UpdateLoadBalancer updates hosts under the specified load balancer.
|
||||||
func (lbaas *LbaasV2) UpdateLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) error {
|
func (lbaas *LbaasV2) UpdateLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) error {
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(service)
|
loadBalancerName := lbaas.GetLoadBalancerName(ctx, clusterName, service)
|
||||||
glog.V(4).Infof("UpdateLoadBalancer(%v, %v, %v)", clusterName, loadBalancerName, nodes)
|
glog.V(4).Infof("UpdateLoadBalancer(%v, %v, %v)", clusterName, loadBalancerName, nodes)
|
||||||
|
|
||||||
lbaas.opts.SubnetID = getStringFromServiceAnnotation(service, ServiceAnnotationLoadBalancerSubnetID, lbaas.opts.SubnetID)
|
lbaas.opts.SubnetID = getStringFromServiceAnnotation(service, ServiceAnnotationLoadBalancerSubnetID, lbaas.opts.SubnetID)
|
||||||
@ -1396,7 +1401,7 @@ func (lbaas *LbaasV2) updateSecurityGroup(clusterName string, apiService *v1.Ser
|
|||||||
|
|
||||||
// EnsureLoadBalancerDeleted deletes the specified load balancer
|
// EnsureLoadBalancerDeleted deletes the specified load balancer
|
||||||
func (lbaas *LbaasV2) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *v1.Service) error {
|
func (lbaas *LbaasV2) EnsureLoadBalancerDeleted(ctx context.Context, clusterName string, service *v1.Service) error {
|
||||||
loadBalancerName := cloudprovider.GetLoadBalancerName(service)
|
loadBalancerName := lbaas.GetLoadBalancerName(ctx, clusterName, service)
|
||||||
glog.V(4).Infof("EnsureLoadBalancerDeleted(%v, %v)", clusterName, loadBalancerName)
|
glog.V(4).Infof("EnsureLoadBalancerDeleted(%v, %v)", clusterName, loadBalancerName)
|
||||||
|
|
||||||
loadbalancer, err := getLoadbalancerByName(lbaas.lb, loadBalancerName)
|
loadbalancer, err := getLoadbalancerByName(lbaas.lb, loadBalancerName)
|
||||||
|
@ -497,7 +497,7 @@ func (s *ServiceController) needsUpdate(oldService *v1.Service, newService *v1.S
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServiceController) loadBalancerName(service *v1.Service) string {
|
func (s *ServiceController) loadBalancerName(service *v1.Service) string {
|
||||||
return cloudprovider.GetLoadBalancerName(service)
|
return s.balancer.GetLoadBalancerName(context.TODO(), "", service)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPortsForLB(service *v1.Service) ([]*v1.ServicePort, error) {
|
func getPortsForLB(service *v1.Service) ([]*v1.ServicePort, error) {
|
||||||
@ -686,7 +686,7 @@ func (s *ServiceController) lockedUpdateLoadBalancerHosts(service *v1.Service, h
|
|||||||
|
|
||||||
// It's only an actual error if the load balancer still exists.
|
// It's only an actual error if the load balancer still exists.
|
||||||
if _, exists, err := s.balancer.GetLoadBalancer(context.TODO(), s.clusterName, service); err != nil {
|
if _, exists, err := s.balancer.GetLoadBalancer(context.TODO(), s.clusterName, service); err != nil {
|
||||||
glog.Errorf("External error while checking if load balancer %q exists: name, %v", cloudprovider.GetLoadBalancerName(service), err)
|
glog.Errorf("External error while checking if load balancer %q exists: name, %v", s.balancer.GetLoadBalancerName(context.TODO(), s.clusterName, service), err)
|
||||||
} else if !exists {
|
} else if !exists {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ func ConstructFirewallForLBService(svc *v1.Service, nodeTag string) *compute.Fir
|
|||||||
Failf("can not construct firewall rule for non-loadbalancer type service")
|
Failf("can not construct firewall rule for non-loadbalancer type service")
|
||||||
}
|
}
|
||||||
fw := compute.Firewall{}
|
fw := compute.Firewall{}
|
||||||
fw.Name = MakeFirewallNameForLBService(cloudprovider.GetLoadBalancerName(svc))
|
fw.Name = MakeFirewallNameForLBService(cloudprovider.DefaultLoadBalancerName(svc))
|
||||||
fw.TargetTags = []string{nodeTag}
|
fw.TargetTags = []string{nodeTag}
|
||||||
if svc.Spec.LoadBalancerSourceRanges == nil {
|
if svc.Spec.LoadBalancerSourceRanges == nil {
|
||||||
fw.SourceRanges = []string{"0.0.0.0/0"}
|
fw.SourceRanges = []string{"0.0.0.0/0"}
|
||||||
@ -80,7 +80,7 @@ func ConstructHealthCheckFirewallForLBService(clusterID string, svc *v1.Service,
|
|||||||
Failf("can not construct firewall rule for non-loadbalancer type service")
|
Failf("can not construct firewall rule for non-loadbalancer type service")
|
||||||
}
|
}
|
||||||
fw := compute.Firewall{}
|
fw := compute.Firewall{}
|
||||||
fw.Name = MakeHealthCheckFirewallNameForLBService(clusterID, cloudprovider.GetLoadBalancerName(svc), isNodesHealthCheck)
|
fw.Name = MakeHealthCheckFirewallNameForLBService(clusterID, cloudprovider.DefaultLoadBalancerName(svc), isNodesHealthCheck)
|
||||||
fw.TargetTags = []string{nodeTag}
|
fw.TargetTags = []string{nodeTag}
|
||||||
fw.SourceRanges = gcecloud.LoadBalancerSrcRanges()
|
fw.SourceRanges = gcecloud.LoadBalancerSrcRanges()
|
||||||
healthCheckPort := gcecloud.GetNodesHealthCheckPort()
|
healthCheckPort := gcecloud.GetNodesHealthCheckPort()
|
||||||
|
@ -80,7 +80,7 @@ var _ = SIGDescribe("Firewall rule", func() {
|
|||||||
})
|
})
|
||||||
Expect(cs.CoreV1().Services(svc.Namespace).Delete(svc.Name, nil)).NotTo(HaveOccurred())
|
Expect(cs.CoreV1().Services(svc.Namespace).Delete(svc.Name, nil)).NotTo(HaveOccurred())
|
||||||
By("Waiting for the local traffic health check firewall rule to be deleted")
|
By("Waiting for the local traffic health check firewall rule to be deleted")
|
||||||
localHCFwName := framework.MakeHealthCheckFirewallNameForLBService(clusterID, cloudprovider.GetLoadBalancerName(svc), false)
|
localHCFwName := framework.MakeHealthCheckFirewallNameForLBService(clusterID, cloudprovider.DefaultLoadBalancerName(svc), false)
|
||||||
_, err := framework.WaitForFirewallRule(gceCloud, localHCFwName, false, framework.LoadBalancerCleanupTimeout)
|
_, err := framework.WaitForFirewallRule(gceCloud, localHCFwName, false, framework.LoadBalancerCleanupTimeout)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
}()
|
}()
|
||||||
|
@ -80,7 +80,7 @@ var _ = SIGDescribe("Services [Feature:GCEAlphaFeature][Slow]", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(svcTier).To(Equal(cloud.NetworkTierStandard))
|
Expect(svcTier).To(Equal(cloud.NetworkTierStandard))
|
||||||
// Record the LB name for test cleanup.
|
// Record the LB name for test cleanup.
|
||||||
serviceLBNames = append(serviceLBNames, cloudprovider.GetLoadBalancerName(svc))
|
serviceLBNames = append(serviceLBNames, cloudprovider.DefaultLoadBalancerName(svc))
|
||||||
|
|
||||||
// Wait and verify the LB.
|
// Wait and verify the LB.
|
||||||
ingressIP := waitAndVerifyLBWithTier(jig, ns, svcName, "", createTimeout, lagTimeout)
|
ingressIP := waitAndVerifyLBWithTier(jig, ns, svcName, "", createTimeout, lagTimeout)
|
||||||
|
@ -621,9 +621,9 @@ var _ = SIGDescribe("Services", func() {
|
|||||||
s.Spec.Type = v1.ServiceTypeLoadBalancer
|
s.Spec.Type = v1.ServiceTypeLoadBalancer
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
serviceLBNames = append(serviceLBNames, cloudprovider.GetLoadBalancerName(tcpService))
|
serviceLBNames = append(serviceLBNames, cloudprovider.DefaultLoadBalancerName(tcpService))
|
||||||
if loadBalancerSupportsUDP {
|
if loadBalancerSupportsUDP {
|
||||||
serviceLBNames = append(serviceLBNames, cloudprovider.GetLoadBalancerName(udpService))
|
serviceLBNames = append(serviceLBNames, cloudprovider.DefaultLoadBalancerName(udpService))
|
||||||
}
|
}
|
||||||
|
|
||||||
By("waiting for the TCP service to have a load balancer")
|
By("waiting for the TCP service to have a load balancer")
|
||||||
@ -1638,7 +1638,7 @@ var _ = SIGDescribe("ESIPP [Slow] [DisabledForLargeClusters]", func() {
|
|||||||
jig := framework.NewServiceTestJig(cs, serviceName)
|
jig := framework.NewServiceTestJig(cs, serviceName)
|
||||||
|
|
||||||
svc := jig.CreateOnlyLocalLoadBalancerService(namespace, serviceName, loadBalancerCreateTimeout, true, nil)
|
svc := jig.CreateOnlyLocalLoadBalancerService(namespace, serviceName, loadBalancerCreateTimeout, true, nil)
|
||||||
serviceLBNames = append(serviceLBNames, cloudprovider.GetLoadBalancerName(svc))
|
serviceLBNames = append(serviceLBNames, cloudprovider.DefaultLoadBalancerName(svc))
|
||||||
healthCheckNodePort := int(svc.Spec.HealthCheckNodePort)
|
healthCheckNodePort := int(svc.Spec.HealthCheckNodePort)
|
||||||
if healthCheckNodePort == 0 {
|
if healthCheckNodePort == 0 {
|
||||||
framework.Failf("Service HealthCheck NodePort was not allocated")
|
framework.Failf("Service HealthCheck NodePort was not allocated")
|
||||||
@ -1710,7 +1710,7 @@ var _ = SIGDescribe("ESIPP [Slow] [DisabledForLargeClusters]", func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
serviceLBNames = append(serviceLBNames, cloudprovider.GetLoadBalancerName(svc))
|
serviceLBNames = append(serviceLBNames, cloudprovider.DefaultLoadBalancerName(svc))
|
||||||
defer func() {
|
defer func() {
|
||||||
jig.ChangeServiceType(svc.Namespace, svc.Name, v1.ServiceTypeClusterIP, loadBalancerCreateTimeout)
|
jig.ChangeServiceType(svc.Namespace, svc.Name, v1.ServiceTypeClusterIP, loadBalancerCreateTimeout)
|
||||||
Expect(cs.CoreV1().Services(svc.Namespace).Delete(svc.Name, nil)).NotTo(HaveOccurred())
|
Expect(cs.CoreV1().Services(svc.Namespace).Delete(svc.Name, nil)).NotTo(HaveOccurred())
|
||||||
@ -1765,7 +1765,7 @@ var _ = SIGDescribe("ESIPP [Slow] [DisabledForLargeClusters]", func() {
|
|||||||
nodes := jig.GetNodes(framework.MaxNodesForEndpointsTests)
|
nodes := jig.GetNodes(framework.MaxNodesForEndpointsTests)
|
||||||
|
|
||||||
svc := jig.CreateOnlyLocalLoadBalancerService(namespace, serviceName, loadBalancerCreateTimeout, true, nil)
|
svc := jig.CreateOnlyLocalLoadBalancerService(namespace, serviceName, loadBalancerCreateTimeout, true, nil)
|
||||||
serviceLBNames = append(serviceLBNames, cloudprovider.GetLoadBalancerName(svc))
|
serviceLBNames = append(serviceLBNames, cloudprovider.DefaultLoadBalancerName(svc))
|
||||||
defer func() {
|
defer func() {
|
||||||
jig.ChangeServiceType(svc.Namespace, svc.Name, v1.ServiceTypeClusterIP, loadBalancerCreateTimeout)
|
jig.ChangeServiceType(svc.Namespace, svc.Name, v1.ServiceTypeClusterIP, loadBalancerCreateTimeout)
|
||||||
Expect(cs.CoreV1().Services(svc.Namespace).Delete(svc.Name, nil)).NotTo(HaveOccurred())
|
Expect(cs.CoreV1().Services(svc.Namespace).Delete(svc.Name, nil)).NotTo(HaveOccurred())
|
||||||
@ -1818,7 +1818,7 @@ var _ = SIGDescribe("ESIPP [Slow] [DisabledForLargeClusters]", func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
svc := jig.CreateOnlyLocalLoadBalancerService(namespace, serviceName, loadBalancerCreateTimeout, true, nil)
|
svc := jig.CreateOnlyLocalLoadBalancerService(namespace, serviceName, loadBalancerCreateTimeout, true, nil)
|
||||||
serviceLBNames = append(serviceLBNames, cloudprovider.GetLoadBalancerName(svc))
|
serviceLBNames = append(serviceLBNames, cloudprovider.DefaultLoadBalancerName(svc))
|
||||||
defer func() {
|
defer func() {
|
||||||
jig.ChangeServiceType(svc.Namespace, svc.Name, v1.ServiceTypeClusterIP, loadBalancerCreateTimeout)
|
jig.ChangeServiceType(svc.Namespace, svc.Name, v1.ServiceTypeClusterIP, loadBalancerCreateTimeout)
|
||||||
Expect(cs.CoreV1().Services(svc.Namespace).Delete(svc.Name, nil)).NotTo(HaveOccurred())
|
Expect(cs.CoreV1().Services(svc.Namespace).Delete(svc.Name, nil)).NotTo(HaveOccurred())
|
||||||
@ -2025,7 +2025,7 @@ func execAffinityTestForLBService(f *framework.Framework, cs clientset.Interface
|
|||||||
jig.SanityCheckService(svc, v1.ServiceTypeLoadBalancer)
|
jig.SanityCheckService(svc, v1.ServiceTypeLoadBalancer)
|
||||||
defer func() {
|
defer func() {
|
||||||
framework.StopServeHostnameService(cs, ns, serviceName)
|
framework.StopServeHostnameService(cs, ns, serviceName)
|
||||||
lb := cloudprovider.GetLoadBalancerName(svc)
|
lb := cloudprovider.DefaultLoadBalancerName(svc)
|
||||||
framework.Logf("cleaning load balancer resource for %s", lb)
|
framework.Logf("cleaning load balancer resource for %s", lb)
|
||||||
framework.CleanupServiceResources(cs, lb, framework.TestContext.CloudConfig.Region, framework.TestContext.CloudConfig.Zone)
|
framework.CleanupServiceResources(cs, lb, framework.TestContext.CloudConfig.Region, framework.TestContext.CloudConfig.Zone)
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user