diff --git a/azure/scope/machinepool.go b/azure/scope/machinepool.go index e427d4f086d1..584755f39585 100644 --- a/azure/scope/machinepool.go +++ b/azure/scope/machinepool.go @@ -138,6 +138,7 @@ func (m *MachinePoolScope) ScaleSetSpec() azure.ScaleSetSpec { FailureDomains: m.MachinePool.Spec.FailureDomains, TerminateNotificationTimeout: m.AzureMachinePool.Spec.Template.TerminateNotificationTimeout, NetworkInterfaces: m.AzureMachinePool.Spec.Template.NetworkInterfaces, + IPv6Enabled: m.IsIPv6Enabled(), OrchestrationMode: m.AzureMachinePool.Spec.OrchestrationMode, } } diff --git a/azure/services/scalesets/scalesets.go b/azure/services/scalesets/scalesets.go index 783056b62607..315cee6566c5 100644 --- a/azure/services/scalesets/scalesets.go +++ b/azure/services/scalesets/scalesets.go @@ -605,15 +605,25 @@ func (s *Service) getVirtualMachineScaleSetNetworkConfiguration(vmssSpec azure.S }, } - ipconfig.Subnet = &compute.APIEntityReference{ - ID: pointer.String(azure.SubnetID(s.Scope.SubscriptionID(), vmssSpec.VNetResourceGroup, vmssSpec.VNetName, n.SubnetName)), - } if j == 0 { // Always use the first IPConfig as the Primary ipconfig.Primary = pointer.Bool(true) } ipconfigs = append(ipconfigs, ipconfig) } + if vmssSpec.IPv6Enabled { + ipv6Config := compute.VirtualMachineScaleSetIPConfiguration{ + Name: pointer.String("ipConfigv6"), + VirtualMachineScaleSetIPConfigurationProperties: &compute.VirtualMachineScaleSetIPConfigurationProperties{ + PrivateIPAddressVersion: "IPv6", + Primary: pointer.Bool(false), + Subnet: &compute.APIEntityReference{ + ID: pointer.String(azure.SubnetID(s.Scope.SubscriptionID(), vmssSpec.VNetResourceGroup, vmssSpec.VNetName, n.SubnetName)), + }, + }, + } + ipconfigs = append(ipconfigs, ipv6Config) + } if i == 0 { ipconfigs[0].LoadBalancerBackendAddressPools = &backendAddressPools nicConfig.VirtualMachineScaleSetNetworkConfigurationProperties.Primary = pointer.Bool(true) diff --git a/azure/types.go b/azure/types.go index 5a57c4133d1a..3078688d5928 100644 --- a/azure/types.go +++ b/azure/types.go @@ -68,6 +68,7 @@ type ScaleSetSpec struct { FailureDomains []string VMExtensions []infrav1.VMExtension NetworkInterfaces []infrav1.NetworkInterface + IPv6Enabled bool OrchestrationMode infrav1.OrchestrationModeType }