diff --git a/api/v1beta1/types.go b/api/v1beta1/types.go index 5f3c642587f..6d70c0e31fb 100644 --- a/api/v1beta1/types.go +++ b/api/v1beta1/types.go @@ -547,12 +547,12 @@ type SubnetSpec struct { // +optional type AzureNetworkInterface struct { SubnetName string `json:"subnetName,omitempty"` - IpConfigs []AzureIPConfig `json:"ipConfigs,omitempty"` + IPConfigs []AzureIPConfig `json:"ipConfigs,omitempty"` AcceleratedNetworking *bool `json:"acceleratedNetworking,omitempty"` - Id string `json:"id,omitempty"` + ID string `json:"id,omitempty"` } -// IP Configuration defines options to confiure a network interface +// IP Configuration defines options to confiure a network interface. type AzureIPConfig struct { PrivateIP string `json:"privateIP,omitempty"` PublicIP bool `json:"publicIP,omitempty"` diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 881b2a64014..4a6831ae460 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -758,8 +758,8 @@ func (in *AzureMarketplaceImage) DeepCopy() *AzureMarketplaceImage { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AzureNetworkInterface) DeepCopyInto(out *AzureNetworkInterface) { *out = *in - if in.IpConfigs != nil { - in, out := &in.IpConfigs, &out.IpConfigs + if in.IPConfigs != nil { + in, out := &in.IPConfigs, &out.IPConfigs *out = make([]AzureIPConfig, len(*in)) copy(*out, *in) } diff --git a/azure/scope/machine.go b/azure/scope/machine.go index ab5f94e5524..2f3d04e98b6 100644 --- a/azure/scope/machine.go +++ b/azure/scope/machine.go @@ -221,7 +221,6 @@ func (m *MachineScope) InboundNatSpecs(portsInUse map[int32]struct{}) []azure.Re // NICSpecs returns the network interface specs. func (m *MachineScope) NICSpecs() []azure.ResourceSpecGetter { - nicSpecs := []azure.ResourceSpecGetter{} if len(m.AzureMachine.Spec.NetworkInterfaces) < 1 { @@ -267,7 +266,7 @@ func (m *MachineScope) NICSpecs() []azure.ResourceSpecGetter { } for i, n := range m.AzureMachine.Spec.NetworkInterfaces { - if n.Id != "" { + if n.ID != "" { continue } spec := &networkinterfaces.NICSpec{ @@ -318,7 +317,7 @@ func (m *MachineScope) NICSpecs() []azure.ResourceSpecGetter { spec.SKU = &m.cache.VMSKU } - for _, c := range n.IpConfigs { + for _, c := range n.IPConfigs { config := networkinterfaces.IPConfig{ PublicIP: c.PublicIP, PrivateIP: c.PrivateIP, @@ -339,8 +338,8 @@ func (m *MachineScope) NICIDs() []string { nicIDs[i] = azure.NetworkInterfaceID(m.SubscriptionID(), nic.ResourceGroupName(), nic.ResourceName()) } for _, n := range m.AzureMachine.Spec.NetworkInterfaces { - if n.Id != "" { - nicIDs = append(nicIDs, n.Id) + if n.ID != "" { + nicIDs = append(nicIDs, n.ID) } } return nicIDs diff --git a/azure/services/networkinterfaces/spec.go b/azure/services/networkinterfaces/spec.go index 8a862b59c42..631193aba65 100644 --- a/azure/services/networkinterfaces/spec.go +++ b/azure/services/networkinterfaces/spec.go @@ -143,11 +143,11 @@ func (s *NICSpec) Parameters(existing interface{}) (parameters interface{}, err } for i, c := range s.IPConfigs { - newIpConfigPropertiesFormat := &network.InterfaceIPConfigurationPropertiesFormat{} - newIpConfigPropertiesFormat.Subnet = subnet + newIPConfigPropertiesFormat := &network.InterfaceIPConfigurationPropertiesFormat{} + newIPConfigPropertiesFormat.Subnet = subnet config := network.InterfaceIPConfiguration{ Name: to.StringPtr(s.Name + "-" + strconv.Itoa(i)), - InterfaceIPConfigurationPropertiesFormat: newIpConfigPropertiesFormat, + InterfaceIPConfigurationPropertiesFormat: newIPConfigPropertiesFormat, } if c.PrivateIP == "" { config.InterfaceIPConfigurationPropertiesFormat.PrivateIPAllocationMethod = network.IPAllocationMethodDynamic diff --git a/azure/services/scalesets/scalesets.go b/azure/services/scalesets/scalesets.go index 50251cee309..5028ab1a7fc 100644 --- a/azure/services/scalesets/scalesets.go +++ b/azure/services/scalesets/scalesets.go @@ -459,15 +459,15 @@ func (s *Service) buildVMSSFromSpec(ctx context.Context, vmssSpec azure.ScaleSet nicConfig := compute.VirtualMachineScaleSetNetworkConfiguration{} nicConfig.VirtualMachineScaleSetNetworkConfigurationProperties = &compute.VirtualMachineScaleSetNetworkConfigurationProperties{} nicConfig.Name = to.StringPtr(vmssSpec.Name + "-" + strconv.Itoa(i)) - if n.Id != "" { - nicConfig.ID = &n.Id + if n.ID != "" { + nicConfig.ID = &n.ID } else { if to.Bool(n.AcceleratedNetworking) { nicConfig.VirtualMachineScaleSetNetworkConfigurationProperties.EnableAcceleratedNetworking = to.BoolPtr(true) } else { nicConfig.VirtualMachineScaleSetNetworkConfigurationProperties.EnableAcceleratedNetworking = to.BoolPtr(false) } - if len(n.IpConfigs) == 0 { + if len(n.IPConfigs) == 0 { nicConfig.VirtualMachineScaleSetNetworkConfigurationProperties.IPConfigurations = &[]compute.VirtualMachineScaleSetIPConfiguration{ { Name: to.StringPtr(vmssSpec.Name + "-" + strconv.Itoa(i)), @@ -483,7 +483,7 @@ func (s *Service) buildVMSSFromSpec(ctx context.Context, vmssSpec azure.ScaleSet } } else { ipconfigs := []compute.VirtualMachineScaleSetIPConfiguration{} - for j, _ := range n.IpConfigs { + for j := range n.IPConfigs { ipconfig := compute.VirtualMachineScaleSetIPConfiguration{ VirtualMachineScaleSetIPConfigurationProperties: &compute.VirtualMachineScaleSetIPConfigurationProperties{}, } diff --git a/azure/types.go b/azure/types.go index 1468e6f598f..a598375063c 100644 --- a/azure/types.go +++ b/azure/types.go @@ -20,7 +20,6 @@ import ( "reflect" "github.com/google/go-cmp/cmp" - "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -128,7 +127,7 @@ type ScaleSetSpec struct { SecurityProfile *infrav1.SecurityProfile SpotVMOptions *infrav1.SpotVMOptions FailureDomains []string - NetworkInterfaces []v1beta1.AzureNetworkInterface + NetworkInterfaces []infrav1.AzureNetworkInterface } // TagsSpec defines the specification for a set of tags. diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_azuremachinepools.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_azuremachinepools.yaml index a206f6037d5..6d07d054e16 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_azuremachinepools.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_azuremachinepools.yaml @@ -1647,11 +1647,16 @@ spec: description: Network Interfaces to attach to the to a virtual machine items: + description: Network Interfaces to attach to each VM properties: acceleratedNetworking: type: boolean + id: + type: string ipConfigs: items: + description: IP Configuration defines options to confiure + a network interface. properties: privateIP: type: string diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_azuremachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_azuremachines.yaml index 857076b7964..3a0aa71b133 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_azuremachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_azuremachines.yaml @@ -1263,7 +1263,7 @@ spec: ipConfigs: items: description: IP Configuration defines options to confiure - a network interface + a network interface. properties: privateIP: type: string diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_azuremachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_azuremachinetemplates.yaml index 02cd4403b8b..a7f0ed6eb89 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_azuremachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_azuremachinetemplates.yaml @@ -1042,7 +1042,7 @@ spec: ipConfigs: items: description: IP Configuration defines options to confiure - a network interface + a network interface. properties: privateIP: type: string diff --git a/exp/api/v1beta1/azuremachinepool_types.go b/exp/api/v1beta1/azuremachinepool_types.go index 11a29b7ac59..fe204403fcd 100644 --- a/exp/api/v1beta1/azuremachinepool_types.go +++ b/exp/api/v1beta1/azuremachinepool_types.go @@ -19,7 +19,6 @@ package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/errors" @@ -91,7 +90,7 @@ type ( // Network Interfaces to attach to the to a virtual machine // +optional - NetworkInterfaces []v1beta1.AzureNetworkInterface `json:"networkInterfaces,omitempty"` + NetworkInterfaces []infrav1.AzureNetworkInterface `json:"networkInterfaces,omitempty"` } // AzureMachinePoolSpec defines the desired state of AzureMachinePool.