From 5077ff79d978cc9b4bddbb5d856ec4d4230ec16b Mon Sep 17 00:00:00 2001 From: Qi Ni Date: Wed, 11 Nov 2020 17:15:12 +0800 Subject: [PATCH] Support high availability ports --- .../azure/azure_loadbalancer.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer.go b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer.go index cc1ecacba0b..f2d69a7cd01 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer.go @@ -99,6 +99,10 @@ const ( // to create both TCP and UDP protocols when creating load balancer rules. ServiceAnnotationLoadBalancerMixedProtocols = "service.beta.kubernetes.io/azure-load-balancer-mixed-protocols" + // ServiceAnnotationLoadBalancerEnableHighAvailabilityPorts is the annotation used on the service + // to enable the high availability ports on the standard internal load balancer. + ServiceAnnotationLoadBalancerEnableHighAvailabilityPorts = "service.beta.kubernetes.io/azure-load-balancer-enable-high-availability-ports" + // ServiceAnnotationLoadBalancerDisableTCPReset is the annotation used on the service // to set enableTcpReset to false in load balancer rule. This only works for Azure standard load balancer backed service. // TODO(feiskyer): disable-tcp-reset annotations has been depracated since v1.18, it would removed on v1.20. @@ -1660,6 +1664,14 @@ func (az *Cloud) reconcileLoadBalancerRule( expectedRule.LoadBalancingRulePropertiesFormat.IdleTimeoutInMinutes = lbIdleTimeout } + if requiresInternalLoadBalancer(service) && + strings.EqualFold(az.LoadBalancerSku, loadBalancerSkuStandard) && + strings.EqualFold(service.Annotations[ServiceAnnotationLoadBalancerEnableHighAvailabilityPorts], "true") { + expectedRule.FrontendPort = to.Int32Ptr(0) + expectedRule.BackendPort = to.Int32Ptr(0) + expectedRule.Protocol = network.TransportProtocolAll + } + // we didn't construct the probe objects for UDP or SCTP because they're not allowed on Azure. // However, when externalTrafficPolicy is Local, Kubernetes HTTP health check would be used for probing. if servicehelpers.NeedsHealthCheck(service) || (protocol != v1.ProtocolUDP && protocol != v1.ProtocolSCTP) {