in pkg/engine/networkinterfaces.go [138:245]
func createPrivateClusterMasterVMNetworkInterface(cs *api.ContainerService) NetworkInterfaceARM {
var dependencies []string
if cs.Properties.MasterProfile.IsCustomVNET() {
dependencies = append(dependencies, "[variables('nsgID')]")
} else {
dependencies = append(dependencies, "[variables('vnetID')]")
}
loadBalancerIPConfig := network.InterfaceIPConfiguration{
Name: to.StringPtr("ipconfig1"),
InterfaceIPConfigurationPropertiesFormat: &network.InterfaceIPConfigurationPropertiesFormat{
PrivateIPAddress: to.StringPtr("[variables('masterPrivateIpAddrs')[copyIndex(variables('masterOffset'))]]"),
Primary: to.BoolPtr(true),
PrivateIPAllocationMethod: network.Static,
Subnet: &network.Subnet{
ID: to.StringPtr("[variables('vnetSubnetID')]"),
},
},
}
if cs.Properties.MasterProfile.HasMultipleNodes() {
dependencies = append(dependencies, "[variables('masterInternalLbName')]")
var lbBackendAddressPools []network.BackendAddressPool
internalLbPool := network.BackendAddressPool{
ID: to.StringPtr("[concat(variables('masterInternalLbID'), '/backendAddressPools/', variables('masterLbBackendPoolName'))]"),
}
lbBackendAddressPools = append(lbBackendAddressPools, internalLbPool)
if cs.Properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku == api.StandardLoadBalancerSku {
dependencies = append(dependencies, "[variables('masterLbName')]")
publicLbPool := network.BackendAddressPool{
ID: to.StringPtr("[concat(variables('masterLbID'), '/backendAddressPools/', variables('masterLbBackendPoolName'))]"),
}
lbBackendAddressPools = append(lbBackendAddressPools, publicLbPool)
}
loadBalancerIPConfig.InterfaceIPConfigurationPropertiesFormat.LoadBalancerBackendAddressPools = &lbBackendAddressPools
loadBalancerIPConfig.InterfaceIPConfigurationPropertiesFormat.LoadBalancerInboundNatRules = &[]network.InboundNatRule{}
}
ipConfigurations := []network.InterfaceIPConfiguration{loadBalancerIPConfig}
isAzureCNI := cs.Properties.OrchestratorProfile.IsAzureCNI()
if isAzureCNI {
for i := 2; i <= cs.Properties.MasterProfile.IPAddressCount; i++ {
ipConfig := network.InterfaceIPConfiguration{
Name: to.StringPtr(fmt.Sprintf("ipconfig%d", i)),
InterfaceIPConfigurationPropertiesFormat: &network.InterfaceIPConfigurationPropertiesFormat{
Primary: to.BoolPtr(false),
PrivateIPAllocationMethod: network.Dynamic,
Subnet: &network.Subnet{
ID: to.StringPtr("[variables('vnetSubnetID')]"),
},
},
}
ipConfigurations = append(ipConfigurations, ipConfig)
}
}
nicProperties := network.InterfacePropertiesFormat{
IPConfigurations: &ipConfigurations,
}
if !isAzureCNI && !cs.Properties.IsAzureStackCloud() {
nicProperties.EnableIPForwarding = to.BoolPtr(true)
}
// Enable IPForwarding on NetworkInterface for azurecni dualstack
if isAzureCNI {
if cs.Properties.FeatureFlags.IsFeatureEnabled("EnableIPv6DualStack") {
nicProperties.EnableIPForwarding = to.BoolPtr(true)
}
}
linuxProfile := cs.Properties.LinuxProfile
if linuxProfile != nil && linuxProfile.HasCustomNodesDNS() {
nicProperties.DNSSettings = &network.InterfaceDNSSettings{
DNSServers: &[]string{
"[parameters('dnsServer')]",
},
}
}
if cs.Properties.MasterProfile.IsCustomVNET() {
nicProperties.NetworkSecurityGroup = &network.SecurityGroup{
ID: to.StringPtr("[variables('nsgID')]"),
}
}
networkInterface := network.Interface{
Location: to.StringPtr("[variables('location')]"),
Name: to.StringPtr("[concat(variables('masterVMNamePrefix'), 'nic-', copyIndex(variables('masterOffset')))]"),
InterfacePropertiesFormat: &nicProperties,
Type: to.StringPtr("Microsoft.Network/networkInterfaces"),
}
armResource := ARMResource{
APIVersion: "[variables('apiVersionNetwork')]",
Copy: map[string]string{
"count": "[sub(variables('masterCount'), variables('masterOffset'))]",
"name": "nicLoopNode",
},
DependsOn: dependencies,
}
return NetworkInterfaceARM{
ARMResource: armResource,
Interface: networkInterface,
}
}