in pkg/engine/loadbalancers.go [77:204]
func CreateMasterLoadBalancer(prop *api.Properties) LoadBalancerARM {
loadBalancer := LoadBalancerARM{
ARMResource: ARMResource{
APIVersion: "[variables('apiVersionNetwork')]",
DependsOn: []string{
"[concat('Microsoft.Network/publicIPAddresses/', variables('masterPublicIPAddressName'))]",
},
},
LoadBalancer: network.LoadBalancer{
Location: to.StringPtr("[variables('location')]"),
Name: to.StringPtr("[variables('masterLbName')]"),
LoadBalancerPropertiesFormat: &network.LoadBalancerPropertiesFormat{
BackendAddressPools: &[]network.BackendAddressPool{
{
Name: to.StringPtr("[variables('masterLbBackendPoolName')]"),
},
},
FrontendIPConfigurations: &[]network.FrontendIPConfiguration{
{
Name: to.StringPtr("[variables('masterLbIPConfigName')]"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
PublicIPAddress: &network.PublicIPAddress{
ID: to.StringPtr("[resourceId('Microsoft.Network/publicIpAddresses',variables('masterPublicIPAddressName'))]"),
},
},
},
},
},
Sku: &network.LoadBalancerSku{
Name: "[variables('loadBalancerSku')]",
},
Type: to.StringPtr("Microsoft.Network/loadBalancers"),
},
}
if !prop.OrchestratorProfile.IsPrivateCluster() {
loadBalancingRules := &[]network.LoadBalancingRule{
{
Name: to.StringPtr("LBRuleHTTPS"),
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.TransportProtocolTCP,
FrontendPort: to.Int32Ptr(443),
BackendPort: to.Int32Ptr(443),
EnableFloatingIP: to.BoolPtr(false),
IdleTimeoutInMinutes: to.Int32Ptr(5),
LoadDistribution: network.LoadDistributionDefault,
Probe: &network.SubResource{
ID: to.StringPtr("[concat(variables('masterLbID'),'/probes/tcpHTTPSProbe')]"),
},
},
},
}
probes := &[]network.Probe{
{
Name: to.StringPtr("tcpHTTPSProbe"),
ProbePropertiesFormat: &network.ProbePropertiesFormat{
Protocol: network.ProbeProtocolTCP,
Port: to.Int32Ptr(443),
IntervalInSeconds: to.Int32Ptr(5),
NumberOfProbes: to.Int32Ptr(2),
},
},
}
loadBalancer.LoadBalancer.LoadBalancerPropertiesFormat.LoadBalancingRules = loadBalancingRules
loadBalancer.LoadBalancer.LoadBalancerPropertiesFormat.Probes = probes
if prop.OrchestratorProfile.KubernetesConfig.LoadBalancerSku == api.StandardLoadBalancerSku {
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.LoadDistributionDefault,
Probe: &network.SubResource{
ID: to.StringPtr("[concat(variables('masterLbID'),'/probes/tcpHTTPSProbe')]"),
},
},
}
*loadBalancer.LoadBalancer.LoadBalancerPropertiesFormat.LoadBalancingRules = append(*loadBalancer.LoadBalancer.LoadBalancerPropertiesFormat.LoadBalancingRules, udpRule)
}
var inboundNATRules []network.InboundNatRule
sshNATPorts := []int32{
22,
2201,
2202,
2203,
2204,
}
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{
BackendPort: to.Int32Ptr(22),
EnableFloatingIP: to.BoolPtr(false),
FrontendIPConfiguration: &network.SubResource{
ID: to.StringPtr("[variables('masterLbIPConfigID')]"),
},
FrontendPort: to.Int32Ptr(sshNATPorts[i]),
Protocol: network.TransportProtocolTCP,
},
}
inboundNATRules = append(inboundNATRules, inboundNATRule)
}
loadBalancer.InboundNatRules = &inboundNATRules
} else {
outboundRules := createOutboundRules(prop)
outboundRule := (*outboundRules)[0]
outboundRule.OutboundRulePropertiesFormat.BackendAddressPool.ID = to.StringPtr("[concat(variables('masterLbID'), '/backendAddressPools/', variables('masterLbBackendPoolName'))]")
(*outboundRule.OutboundRulePropertiesFormat.FrontendIPConfigurations)[0].ID = to.StringPtr("[variables('masterLbIPConfigID')]")
loadBalancer.LoadBalancer.LoadBalancerPropertiesFormat.OutboundRules = outboundRules
}
return loadBalancer
}