Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

fix: add UDP Standard LB rule to enable outbound access #1155

Merged
merged 3 commits into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions parts/k8s/addons/kubernetesmasteraddons-elb-svc.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: v1
kind: Service
metadata:
Expand All @@ -10,6 +11,24 @@ spec:
ports:
- port: 8765
targetPort: 9376
protocol: TCP
selector:
app: "<svcName>"
type: LoadBalancer
---
apiVersion: v1
kind: Service
metadata:
labels:
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: EnsureExists
name: elb-udp
namespace: kube-system
spec:
ports:
- port: 8765
targetPort: 9376
protocol: UDP
selector:
app: "<svcName>"
type: LoadBalancer
75 changes: 73 additions & 2 deletions pkg/engine/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/Azure/go-autorest/autorest/to"
)

func CreateLoadBalancer(masterCount int, isVMSS bool) LoadBalancerARM {
func CreateLoadBalancer(prop *api.Properties, isVMSS bool) LoadBalancerARM {

loadBalancer := LoadBalancerARM{
ARMResource: ARMResource{
Expand Down Expand Up @@ -80,6 +80,30 @@ func CreateLoadBalancer(masterCount int, isVMSS bool) LoadBalancerARM {
},
}

if prop.OrchestratorProfile.KubernetesConfig.LoadBalancerSku == "Standard" {
udpRule := network.LoadBalancingRule{
Name: to.StringPtr("LBRuleUDP"),
LoadBalancingRulePropertiesFormat: &network.LoadBalancingRulePropertiesFormat{
FrontendIPConfiguration: &network.SubResource{
ID: to.StringPtr("[variables('masterLbIPConfigID')]"),
},
BackendAddressPool: &network.SubResource{
ID: to.StringPtr("[concat(variables('masterLbID'), '/backendAddressPools/', variables('masterLbBackendPoolName'))]"),
},
Protocol: network.TransportProtocolUDP,
FrontendPort: to.Int32Ptr(1123),
BackendPort: to.Int32Ptr(1123),
EnableFloatingIP: to.BoolPtr(false),
IdleTimeoutInMinutes: to.Int32Ptr(5),
LoadDistribution: network.Default,
Probe: &network.SubResource{
ID: to.StringPtr("[concat(variables('masterLbID'),'/probes/tcpHTTPSProbe')]"),
},
},
}
*loadBalancer.LoadBalancer.LoadBalancerPropertiesFormat.LoadBalancingRules = append(*loadBalancer.LoadBalancer.LoadBalancerPropertiesFormat.LoadBalancingRules, udpRule)
}

if isVMSS {
inboundNATPools := []network.InboundNatPool{
{
Expand Down Expand Up @@ -107,7 +131,7 @@ func CreateLoadBalancer(masterCount int, isVMSS bool) LoadBalancerARM {
2203,
2204,
}
for i := 0; i < masterCount; i++ {
for i := 0; i < prop.MasterProfile.Count; i++ {
inboundNATRule := network.InboundNatRule{
Name: to.StringPtr(fmt.Sprintf("[concat('SSH-', variables('masterVMNamePrefix'), %d)]", i)),
InboundNatRulePropertiesFormat: &network.InboundNatRulePropertiesFormat{
Expand Down Expand Up @@ -204,10 +228,57 @@ func CreateMasterInternalLoadBalancer(cs *api.ContainerService) LoadBalancerARM
},
Type: to.StringPtr("Microsoft.Network/loadBalancers"),
}

if cs.Properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku == "Standard" {
udpRule := network.LoadBalancingRule{
Name: to.StringPtr("LBRuleUDP"),
LoadBalancingRulePropertiesFormat: &network.LoadBalancingRulePropertiesFormat{
BackendAddressPool: &network.SubResource{
ID: to.StringPtr("[concat(variables('masterInternalLbID'), '/backendAddressPools/', variables('masterLbBackendPoolName'))]"),
},
BackendPort: to.Int32Ptr(1123),
EnableFloatingIP: to.BoolPtr(false),
FrontendIPConfiguration: &network.SubResource{
ID: to.StringPtr("[variables('masterInternalLbIPConfigID')]"),
},
FrontendPort: to.Int32Ptr(1123),
IdleTimeoutInMinutes: to.Int32Ptr(5),
Protocol: network.TransportProtocolUDP,
Probe: &network.SubResource{
ID: to.StringPtr("[concat(variables('masterInternalLbID'),'/probes/tcpHTTPSProbe')]"),
},
},
}
*loadBalancer.LoadBalancerPropertiesFormat.LoadBalancingRules = append(*loadBalancer.LoadBalancerPropertiesFormat.LoadBalancingRules, udpRule)
}

loadBalancerARM := LoadBalancerARM{
ARMResource: armResource,
LoadBalancer: loadBalancer,
}

return loadBalancerARM
}

func getUDPLoadBalancingRule() network.LoadBalancingRule {
return network.LoadBalancingRule{
Name: to.StringPtr("LBRuleUDP"),
LoadBalancingRulePropertiesFormat: &network.LoadBalancingRulePropertiesFormat{
FrontendIPConfiguration: &network.SubResource{
ID: to.StringPtr("[variables('masterLbIPConfigID')]"),
},
BackendAddressPool: &network.SubResource{
ID: to.StringPtr("[concat(variables('masterLbID'), '/backendAddressPools/', variables('masterLbBackendPoolName'))]"),
},
Protocol: network.TransportProtocolUDP,
FrontendPort: to.Int32Ptr(1123),
BackendPort: to.Int32Ptr(1123),
EnableFloatingIP: to.BoolPtr(false),
IdleTimeoutInMinutes: to.Int32Ptr(5),
LoadDistribution: network.Default,
Probe: &network.SubResource{
ID: to.StringPtr("[concat(variables('masterLbID'),'/probes/tcpHTTPSProbe')]"),
},
},
}
}
Loading