mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 08:40:42 +00:00
Merge pull request #59747 from feiskyer/fix-59746
Automatic merge from submit-queue. 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>. Map correct vmset name for internal load balancers **What this PR does / why we need it**: When creating an internal loadbalancer, e.g. ```sh cat << EOF | kubectl create -f - apiVersion: v1 kind: Service metadata: name: ingress-nginx annotations: service.beta.kubernetes.io/azure-load-balancer-internal: "true" spec: type: LoadBalancer ports: - name: http port: 80 targetPort: 80 protocol: TCP - name: https port: 443 targetPort: 443 protocol: TCP selector: app: ingress-nginx EOF ``` Then wait a while, and no target backends present for the internal load balancer even after 15 mins.  Refer https://github.com/Azure/acs-engine/issues/2151#issuecomment-364726846. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #59746 **Special notes for your reviewer**: Should cherry pick to v1.9, v1.8, and v1.7 (and requires resolving conflicts manually). **Release note**: ```release-note Map correct vmset name for internal load balancers ```
This commit is contained in:
commit
4cc993a720
@ -110,7 +110,7 @@ func (az *Cloud) getLoadBalancerProbeID(lbName, lbRuleName string) string {
|
|||||||
|
|
||||||
func (az *Cloud) mapLoadBalancerNameToVMSet(lbName string, clusterName string) (vmSetName string) {
|
func (az *Cloud) mapLoadBalancerNameToVMSet(lbName string, clusterName string) (vmSetName string) {
|
||||||
vmSetName = strings.TrimSuffix(lbName, InternalLoadBalancerNameSuffix)
|
vmSetName = strings.TrimSuffix(lbName, InternalLoadBalancerNameSuffix)
|
||||||
if strings.EqualFold(clusterName, lbName) {
|
if strings.EqualFold(clusterName, vmSetName) {
|
||||||
vmSetName = az.vmSet.GetPrimaryVMSetName()
|
vmSetName = az.vmSet.GetPrimaryVMSetName()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ package azure
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
@ -120,3 +122,45 @@ func TestGenerateStorageAccountName(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMapLoadBalancerNameToVMSet(t *testing.T) {
|
||||||
|
az := getTestCloud()
|
||||||
|
az.PrimaryAvailabilitySetName = "primary"
|
||||||
|
|
||||||
|
cases := []struct {
|
||||||
|
description string
|
||||||
|
lbName string
|
||||||
|
clusterName string
|
||||||
|
expectedVMSet string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
description: "default external LB should map to primary vmset",
|
||||||
|
lbName: "azure",
|
||||||
|
clusterName: "azure",
|
||||||
|
expectedVMSet: "primary",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "default internal LB should map to primary vmset",
|
||||||
|
lbName: "azure-internal",
|
||||||
|
clusterName: "azure",
|
||||||
|
expectedVMSet: "primary",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "non-default external LB should map to its own vmset",
|
||||||
|
lbName: "azuretest-internal",
|
||||||
|
clusterName: "azure",
|
||||||
|
expectedVMSet: "azuretest",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "non-default internal LB should map to its own vmset",
|
||||||
|
lbName: "azuretest-internal",
|
||||||
|
clusterName: "azure",
|
||||||
|
expectedVMSet: "azuretest",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, c := range cases {
|
||||||
|
vmset := az.mapLoadBalancerNameToVMSet(c.lbName, c.clusterName)
|
||||||
|
assert.Equal(t, c.expectedVMSet, vmset, c.description)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user