diff --git a/charts/internal/machineclass/templates/machineclass.yaml b/charts/internal/machineclass/templates/machineclass.yaml
index 48cebf067..ee442fc72 100644
--- a/charts/internal/machineclass/templates/machineclass.yaml
+++ b/charts/internal/machineclass/templates/machineclass.yaml
@@ -35,6 +35,10 @@ spec:
{{- if hasKey $machineClass "identityID" }}
identityID: {{ $machineClass.identityID }}
{{- end }}
+ {{- if hasKey $machineClass.network "acceleratedNetworking" }}
+ networkProfile:
+ acceleratedNetworking: {{ $machineClass.network.acceleratedNetworking }}
+ {{- end }}
hardwareProfile:
vmSize: {{ $machineClass.machineType }}
osProfile:
@@ -65,11 +69,11 @@ spec:
name: {{ $machineClass.name }}
namespace: {{ $.Release.Namespace }}
subnetInfo:
- vnetName: {{ $machineClass.vnetName }}
- {{- if hasKey $machineClass "vnetResourceGroup" }}
- vnetResourceGroup: {{ $machineClass.vnetResourceGroup}}
+ vnetName: {{ $machineClass.network.vnet }}
+ {{- if hasKey $machineClass.network "vnetResourceGroup" }}
+ vnetResourceGroup: {{ $machineClass.network.vnetResourceGroup}}
{{- end }}
- subnetName: {{ $machineClass.subnetName }}
+ subnetName: {{ $machineClass.network.subnet }}
{{- if $machineClass.tags }}
tags:
{{ toYaml $machineClass.tags | indent 4 }}
diff --git a/charts/internal/machineclass/values.yaml b/charts/internal/machineclass/values.yaml
index 3647dc519..d1347c834 100644
--- a/charts/internal/machineclass/values.yaml
+++ b/charts/internal/machineclass/values.yaml
@@ -4,10 +4,13 @@ machineClasses:
# foo: bar
region: westeurope
resourceGroup: my-resource-group
- vnetName: my-vnet
- subnetName: my-subnet-in-my-vnet
zone: 1
# identityID: /subscriptions/subscription-id/resourceGroups/resource-group-name/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name
+ network:
+ vnet: my-vnet
+ subnet: my-subnet-in-my-vnet
+ # vnetResourceGroup: my-vnet-resource-group
+ # acceleratedNetworking: true
tags:
Name: shoot-crazy-botany
kubernetes.io-cluster-shoot-crazy-botany: "1"
@@ -29,8 +32,9 @@ machineClasses:
- name: class-2-availability-set
region: westeurope
resourceGroup: my-resource-group
- vnetName: my-vnet
- subnetName: my-subnet-in-my-vnet
+ network:
+ vnet: my-vnet
+ subnet: my-subnet-in-my-vnet
availabilitySetID: /subscriptions/subscription-id/resourceGroups/resource-group-name/providers/Microsoft.Compute/availabilitySets/availablity-set-name
tags:
Name: shoot-crazy-botany
diff --git a/docs/usage-as-end-user.md b/docs/usage-as-end-user.md
index 82ca06c27..ec8690009 100644
--- a/docs/usage-as-end-user.md
+++ b/docs/usage-as-end-user.md
@@ -210,3 +210,10 @@ spec:
nginxIngress:
enabled: true
```
+
+## Miscellaneous
+
+### Azure Accelerated Networking
+All worker machines of the cluster will be automatically configured to use [Azure Accelerated Networking](https://docs.microsoft.com/en-us/azure/virtual-network/create-vm-accelerated-networking-cli) if the prerequisites are fulfilled.
+The prerequisites are that the used machine type and operating system image version are compatible for Accelerated Networking.
+Supported machine types are listed in the CloudProfile in `.spec.providerConfig.machineTypes[].acceleratedNetworking` and the supported operating system image versions are defined in `.spec.providerConfig.machineImages[].versions[].acceleratedNetworking`.
diff --git a/docs/usage-as-operator.md b/docs/usage-as-operator.md
index 7db123a5d..febf8b2f7 100644
--- a/docs/usage-as-operator.md
+++ b/docs/usage-as-operator.md
@@ -6,10 +6,7 @@ In this document we are describing how this configuration looks like for Azure a
## `CloudProfileConfig`
-The cloud profile configuration contains information about the update and failure domain counts in the Azure regions you want to offer.
-Additionally, it contains the real machine image identifiers in the Azure environment. You can provide either URN for Azure Market Place images or id of [Shared Image Gallery](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/shared-image-galleries) images.
-When Shared Image Gallery is used, you have to ensure that the image is available in the desired regions and the end-user subscriptions have access to the image or to the whole gallery.
-You have to map every version that you specify in `.spec.machineImages[].versions` here such that the Azure extension knows the machine image identifiers for every version you want to offer.
+
An example `CloudProfileConfig` for the Azure extension looks as follows:
@@ -22,17 +19,31 @@ countUpdateDomains:
countFaultDomains:
- region: westeurope
count: 3
+machineTypes:
+- name: Standard_D3_v2
+ acceleratedNetworking: true
+- name: Standard_X
machineImages:
- name: coreos
versions:
- version: 2135.6.0
urn: "CoreOS:CoreOS:Stable:2135.6.0"
+ acceleratedNetworking: true
- name: myimage
versions:
- version: 1.0.0
id: "/subscriptions/
machineTypes
+
+
+[]MachineType
+
+
+MachineTypes is a list of machine types complete with provider specific information.
+ID is the VM image ID
+acceleratedNetworking
+
+bool
+
+AcceleratedNetworking is an indicator if the image supports Azure accelerated networking.
+ID is the Shared Image Gallery image id.
+acceleratedNetworking
+
+bool
+
+AcceleratedNetworking is an indicator if the image supports Azure accelerated networking.
++(Appears on: +CloudProfileConfig) +
++
MachineType contains provider specific information to a machine type.
+ +Field | +Description | +
---|---|
+name
+
+string
+
+ |
+
+ Name is the name of the machine type. + |
+
+acceleratedNetworking
+
+bool
+
+ |
+
+(Optional)
+ AcceleratedNetworking is an indicator if the machine type supports Azure accelerated networking. + |
+
diff --git a/pkg/apis/azure/helper/helper.go b/pkg/apis/azure/helper/helper.go index 6a3869320..e94d1f9a9 100644 --- a/pkg/apis/azure/helper/helper.go +++ b/pkg/apis/azure/helper/helper.go @@ -102,10 +102,11 @@ func FindImageFromCloudProfile(cloudProfileConfig *api.CloudProfileConfig, image for _, version := range machineImage.Versions { if imageVersion == version.Version { return &api.MachineImage{ - Name: imageName, - Version: version.Version, - URN: version.URN, - ID: version.ID, + Name: imageName, + Version: version.Version, + URN: version.URN, + ID: version.ID, + AcceleratedNetworking: version.AcceleratedNetworking, }, nil } } diff --git a/pkg/apis/azure/types_cloudprofile.go b/pkg/apis/azure/types_cloudprofile.go index 6422e7b02..9d932b620 100644 --- a/pkg/apis/azure/types_cloudprofile.go +++ b/pkg/apis/azure/types_cloudprofile.go @@ -31,6 +31,8 @@ type CloudProfileConfig struct { // MachineImages is the list of machine images that are understood by the controller. It maps // logical names and versions to provider-specific identifiers. MachineImages []MachineImages + // MachineTypes is a list of machine types complete with provider specific information. + MachineTypes []MachineType } // DomainCount defines the region and the count for this domain count value. @@ -57,4 +59,14 @@ type MachineImageVersion struct { URN *string // ID is the Shared Image Gallery image id. ID *string + // AcceleratedNetworking is an indicator if the image supports Azure accelerated networking. + AcceleratedNetworking *bool +} + +// MachineType contains provider specific information to a machine type. +type MachineType struct { + // Name is the name of the machine type. + Name string + // AcceleratedNetworking is an indicator if the machine type supports Azure accelerated networking. + AcceleratedNetworking *bool } diff --git a/pkg/apis/azure/types_worker.go b/pkg/apis/azure/types_worker.go index 506c257a8..b79eb6d2f 100644 --- a/pkg/apis/azure/types_worker.go +++ b/pkg/apis/azure/types_worker.go @@ -42,4 +42,6 @@ type MachineImage struct { URN *string // ID is the VM image ID ID *string + // AcceleratedNetworking is an indicator if the image supports Azure accelerated networking. + AcceleratedNetworking *bool } diff --git a/pkg/apis/azure/v1alpha1/types_cloudprofile.go b/pkg/apis/azure/v1alpha1/types_cloudprofile.go index 47ce5234f..60f74e267 100644 --- a/pkg/apis/azure/v1alpha1/types_cloudprofile.go +++ b/pkg/apis/azure/v1alpha1/types_cloudprofile.go @@ -32,6 +32,9 @@ type CloudProfileConfig struct { // MachineImages is the list of machine images that are understood by the controller. It maps // logical names and versions to provider-specific identifiers. MachineImages []MachineImages `json:"machineImages"` + // MachineTypes is a list of machine types complete with provider specific information. + // +optional + MachineTypes []MachineType `json:"machineTypes,omitempty"` } // DomainCount defines the region and the count for this domain count value. @@ -60,4 +63,16 @@ type MachineImageVersion struct { // ID is the Shared Image Gallery image id. // +optional ID *string `json:"id,omitempty"` + // AcceleratedNetworking is an indicator if the image supports Azure accelerated networking. + // +optional + AcceleratedNetworking *bool `json:"acceleratedNetworking,omitempty"` +} + +// MachineType contains provider specific information to a machine type. +type MachineType struct { + // Name is the name of the machine type. + Name string `json:"name"` + // AcceleratedNetworking is an indicator if the machine type supports Azure accelerated networking. + // +optional + AcceleratedNetworking *bool `json:"acceleratedNetworking,omitempty"` } diff --git a/pkg/apis/azure/v1alpha1/types_worker.go b/pkg/apis/azure/v1alpha1/types_worker.go index 18c60a955..086dc68ee 100644 --- a/pkg/apis/azure/v1alpha1/types_worker.go +++ b/pkg/apis/azure/v1alpha1/types_worker.go @@ -46,4 +46,7 @@ type MachineImage struct { // ID is the VM image ID // +optional ID *string `json:"id,omitempty"` + // AcceleratedNetworking is an indicator if the image supports Azure accelerated networking. + // +optional + AcceleratedNetworking *bool `json:"acceleratedNetworking,omitempty"` } diff --git a/pkg/apis/azure/v1alpha1/zz_generated.conversion.go b/pkg/apis/azure/v1alpha1/zz_generated.conversion.go index 30ed86a15..8f1922554 100644 --- a/pkg/apis/azure/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/azure/v1alpha1/zz_generated.conversion.go @@ -155,6 +155,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*MachineType)(nil), (*azure.MachineType)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_MachineType_To_azure_MachineType(a.(*MachineType), b.(*azure.MachineType), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*azure.MachineType)(nil), (*MachineType)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_azure_MachineType_To_v1alpha1_MachineType(a.(*azure.MachineType), b.(*MachineType), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*NatGatewayConfig)(nil), (*azure.NatGatewayConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha1_NatGatewayConfig_To_azure_NatGatewayConfig(a.(*NatGatewayConfig), b.(*azure.NatGatewayConfig), scope) }); err != nil { @@ -306,6 +316,7 @@ func autoConvert_v1alpha1_CloudProfileConfig_To_azure_CloudProfileConfig(in *Clo out.CountUpdateDomains = *(*[]azure.DomainCount)(unsafe.Pointer(&in.CountUpdateDomains)) out.CountFaultDomains = *(*[]azure.DomainCount)(unsafe.Pointer(&in.CountFaultDomains)) out.MachineImages = *(*[]azure.MachineImages)(unsafe.Pointer(&in.MachineImages)) + out.MachineTypes = *(*[]azure.MachineType)(unsafe.Pointer(&in.MachineTypes)) return nil } @@ -318,6 +329,7 @@ func autoConvert_azure_CloudProfileConfig_To_v1alpha1_CloudProfileConfig(in *azu out.CountUpdateDomains = *(*[]DomainCount)(unsafe.Pointer(&in.CountUpdateDomains)) out.CountFaultDomains = *(*[]DomainCount)(unsafe.Pointer(&in.CountFaultDomains)) out.MachineImages = *(*[]MachineImages)(unsafe.Pointer(&in.MachineImages)) + out.MachineTypes = *(*[]MachineType)(unsafe.Pointer(&in.MachineTypes)) return nil } @@ -491,6 +503,7 @@ func autoConvert_v1alpha1_MachineImage_To_azure_MachineImage(in *MachineImage, o out.Version = in.Version out.URN = (*string)(unsafe.Pointer(in.URN)) out.ID = (*string)(unsafe.Pointer(in.ID)) + out.AcceleratedNetworking = (*bool)(unsafe.Pointer(in.AcceleratedNetworking)) return nil } @@ -504,6 +517,7 @@ func autoConvert_azure_MachineImage_To_v1alpha1_MachineImage(in *azure.MachineIm out.Version = in.Version out.URN = (*string)(unsafe.Pointer(in.URN)) out.ID = (*string)(unsafe.Pointer(in.ID)) + out.AcceleratedNetworking = (*bool)(unsafe.Pointer(in.AcceleratedNetworking)) return nil } @@ -516,6 +530,7 @@ func autoConvert_v1alpha1_MachineImageVersion_To_azure_MachineImageVersion(in *M out.Version = in.Version out.URN = (*string)(unsafe.Pointer(in.URN)) out.ID = (*string)(unsafe.Pointer(in.ID)) + out.AcceleratedNetworking = (*bool)(unsafe.Pointer(in.AcceleratedNetworking)) return nil } @@ -528,6 +543,7 @@ func autoConvert_azure_MachineImageVersion_To_v1alpha1_MachineImageVersion(in *a out.Version = in.Version out.URN = (*string)(unsafe.Pointer(in.URN)) out.ID = (*string)(unsafe.Pointer(in.ID)) + out.AcceleratedNetworking = (*bool)(unsafe.Pointer(in.AcceleratedNetworking)) return nil } @@ -558,6 +574,28 @@ func Convert_azure_MachineImages_To_v1alpha1_MachineImages(in *azure.MachineImag return autoConvert_azure_MachineImages_To_v1alpha1_MachineImages(in, out, s) } +func autoConvert_v1alpha1_MachineType_To_azure_MachineType(in *MachineType, out *azure.MachineType, s conversion.Scope) error { + out.Name = in.Name + out.AcceleratedNetworking = (*bool)(unsafe.Pointer(in.AcceleratedNetworking)) + return nil +} + +// Convert_v1alpha1_MachineType_To_azure_MachineType is an autogenerated conversion function. +func Convert_v1alpha1_MachineType_To_azure_MachineType(in *MachineType, out *azure.MachineType, s conversion.Scope) error { + return autoConvert_v1alpha1_MachineType_To_azure_MachineType(in, out, s) +} + +func autoConvert_azure_MachineType_To_v1alpha1_MachineType(in *azure.MachineType, out *MachineType, s conversion.Scope) error { + out.Name = in.Name + out.AcceleratedNetworking = (*bool)(unsafe.Pointer(in.AcceleratedNetworking)) + return nil +} + +// Convert_azure_MachineType_To_v1alpha1_MachineType is an autogenerated conversion function. +func Convert_azure_MachineType_To_v1alpha1_MachineType(in *azure.MachineType, out *MachineType, s conversion.Scope) error { + return autoConvert_azure_MachineType_To_v1alpha1_MachineType(in, out, s) +} + func autoConvert_v1alpha1_NatGatewayConfig_To_azure_NatGatewayConfig(in *NatGatewayConfig, out *azure.NatGatewayConfig, s conversion.Scope) error { out.Enabled = in.Enabled return nil diff --git a/pkg/apis/azure/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/azure/v1alpha1/zz_generated.deepcopy.go index 7498ed217..f79e76c69 100644 --- a/pkg/apis/azure/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/azure/v1alpha1/zz_generated.deepcopy.go @@ -84,6 +84,13 @@ func (in *CloudProfileConfig) DeepCopyInto(out *CloudProfileConfig) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.MachineTypes != nil { + in, out := &in.MachineTypes, &out.MachineTypes + *out = make([]MachineType, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } @@ -284,6 +291,11 @@ func (in *MachineImage) DeepCopyInto(out *MachineImage) { *out = new(string) **out = **in } + if in.AcceleratedNetworking != nil { + in, out := &in.AcceleratedNetworking, &out.AcceleratedNetworking + *out = new(bool) + **out = **in + } return } @@ -310,6 +322,11 @@ func (in *MachineImageVersion) DeepCopyInto(out *MachineImageVersion) { *out = new(string) **out = **in } + if in.AcceleratedNetworking != nil { + in, out := &in.AcceleratedNetworking, &out.AcceleratedNetworking + *out = new(bool) + **out = **in + } return } @@ -346,6 +363,27 @@ func (in *MachineImages) DeepCopy() *MachineImages { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineType) DeepCopyInto(out *MachineType) { + *out = *in + if in.AcceleratedNetworking != nil { + in, out := &in.AcceleratedNetworking, &out.AcceleratedNetworking + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineType. +func (in *MachineType) DeepCopy() *MachineType { + if in == nil { + return nil + } + out := new(MachineType) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NatGatewayConfig) DeepCopyInto(out *NatGatewayConfig) { *out = *in diff --git a/pkg/apis/azure/zz_generated.deepcopy.go b/pkg/apis/azure/zz_generated.deepcopy.go index d4be231a1..a737a4305 100644 --- a/pkg/apis/azure/zz_generated.deepcopy.go +++ b/pkg/apis/azure/zz_generated.deepcopy.go @@ -84,6 +84,13 @@ func (in *CloudProfileConfig) DeepCopyInto(out *CloudProfileConfig) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.MachineTypes != nil { + in, out := &in.MachineTypes, &out.MachineTypes + *out = make([]MachineType, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } @@ -284,6 +291,11 @@ func (in *MachineImage) DeepCopyInto(out *MachineImage) { *out = new(string) **out = **in } + if in.AcceleratedNetworking != nil { + in, out := &in.AcceleratedNetworking, &out.AcceleratedNetworking + *out = new(bool) + **out = **in + } return } @@ -310,6 +322,11 @@ func (in *MachineImageVersion) DeepCopyInto(out *MachineImageVersion) { *out = new(string) **out = **in } + if in.AcceleratedNetworking != nil { + in, out := &in.AcceleratedNetworking, &out.AcceleratedNetworking + *out = new(bool) + **out = **in + } return } @@ -346,6 +363,27 @@ func (in *MachineImages) DeepCopy() *MachineImages { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineType) DeepCopyInto(out *MachineType) { + *out = *in + if in.AcceleratedNetworking != nil { + in, out := &in.AcceleratedNetworking, &out.AcceleratedNetworking + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineType. +func (in *MachineType) DeepCopy() *MachineType { + if in == nil { + return nil + } + out := new(MachineType) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NatGatewayConfig) DeepCopyInto(out *NatGatewayConfig) { *out = *in diff --git a/pkg/controller/worker/machine_images.go b/pkg/controller/worker/machine_images.go index 108624630..3f863fdf3 100644 --- a/pkg/controller/worker/machine_images.go +++ b/pkg/controller/worker/machine_images.go @@ -61,28 +61,28 @@ func (w *workerDelegate) GetMachineImages(ctx context.Context) (runtime.Object, return workerStatusV1alpha1, nil } -func (w *workerDelegate) findMachineImage(name, version string) (urn, id *string, err error) { +func (w *workerDelegate) findMachineImage(name, version string) (urn, id *string, acceleratedNetworking *bool, err error) { machineImage, err := helper.FindImageFromCloudProfile(w.cloudProfileConfig, name, version) if err == nil { - return machineImage.URN, machineImage.ID, nil + return machineImage.URN, machineImage.ID, machineImage.AcceleratedNetworking, nil } // Try to look up machine image in worker provider status as it was not found in componentconfig. if providerStatus := w.worker.Status.ProviderStatus; providerStatus != nil { workerStatus := &api.WorkerStatus{} if _, _, err := w.Decoder().Decode(providerStatus.Raw, nil, workerStatus); err != nil { - return nil, nil, errors.Wrapf(err, "could not decode worker status of worker '%s'", util.ObjectName(w.worker)) + return nil, nil, nil, errors.Wrapf(err, "could not decode worker status of worker '%s'", util.ObjectName(w.worker)) } machineImage, err := helper.FindMachineImage(workerStatus.MachineImages, name, version) if err != nil { - return nil, nil, worker.ErrorMachineImageNotFound(name, version) + return nil, nil, nil, worker.ErrorMachineImageNotFound(name, version) } - return machineImage.URN, machineImage.ID, nil + return machineImage.URN, machineImage.ID, machineImage.AcceleratedNetworking, nil } - return nil, nil, worker.ErrorMachineImageNotFound(name, version) + return nil, nil, nil, worker.ErrorMachineImageNotFound(name, version) } func appendMachineImage(machineImages []api.MachineImage, machineImage api.MachineImage) []api.MachineImage { diff --git a/pkg/controller/worker/machines.go b/pkg/controller/worker/machines.go index e51abd471..c7c202ad4 100644 --- a/pkg/controller/worker/machines.go +++ b/pkg/controller/worker/machines.go @@ -124,15 +124,16 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error { return err } - urn, id, err := w.findMachineImage(pool.MachineImage.Name, pool.MachineImage.Version) + urn, id, imageSupportAcceleratedNetworking, err := w.findMachineImage(pool.MachineImage.Name, pool.MachineImage.Version) if err != nil { return err } machineImages = appendMachineImage(machineImages, apisazure.MachineImage{ - Name: pool.MachineImage.Name, - Version: pool.MachineImage.Version, - URN: urn, - ID: id, + Name: pool.MachineImage.Name, + Version: pool.MachineImage.Version, + URN: urn, + ID: id, + AcceleratedNetworking: imageSupportAcceleratedNetworking, }) volumeSize, err := worker.DiskSize(pool.Volume.Size) @@ -174,12 +175,13 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error { Annotations: pool.Annotations, Taints: pool.Taints, } - + networkConfig = map[string]interface{}{ + "vnet": infrastructureStatus.Networks.VNet.Name, + "subnet": nodesSubnet.Name, + } machineClassSpec = map[string]interface{}{ "region": w.worker.Spec.Region, "resourceGroup": infrastructureStatus.ResourceGroup.Name, - "vnetName": infrastructureStatus.Networks.VNet.Name, - "subnetName": nodesSubnet.Name, "tags": map[string]interface{}{ "Name": w.worker.Namespace, fmt.Sprintf("kubernetes.io-cluster-%s", w.worker.Namespace): "1", @@ -198,12 +200,16 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error { machineClassSpec["vnetResourceGroup"] = *infrastructureStatus.Networks.VNet.ResourceGroup } + if imageSupportAcceleratedNetworking != nil && *imageSupportAcceleratedNetworking && w.isMachineTypeSupportingAcceleratedNetworking(pool.MachineType) { + networkConfig["acceleratedNetworking"] = true + } + machineClassSpec["network"] = networkConfig + if zone != nil { machineDeployment.Minimum = worker.DistributeOverZones(zone.index, pool.Minimum, zone.count) machineDeployment.Maximum = worker.DistributeOverZones(zone.index, pool.Maximum, zone.count) machineDeployment.MaxSurge = worker.DistributePositiveIntOrPercent(zone.index, pool.MaxSurge, zone.count, pool.Maximum) machineDeployment.MaxUnavailable = worker.DistributePositiveIntOrPercent(zone.index, pool.MaxUnavailable, zone.count, pool.Minimum) - machineClassSpec["zone"] = zone.name } if availabilitySetID != nil { @@ -268,3 +274,13 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error { return nil } + +// isMachineTypeSupportingAcceleratedNetworking checks if the passed machine type is supporting Azure accelerated networking. +func (w *workerDelegate) isMachineTypeSupportingAcceleratedNetworking(machineTypeName string) bool { + for _, machType := range w.cloudProfileConfig.MachineTypes { + if machType.Name == machineTypeName && machType.AcceleratedNetworking != nil && *machType.AcceleratedNetworking { + return true + } + } + return false +} diff --git a/pkg/controller/worker/machines_test.go b/pkg/controller/worker/machines_test.go index 0dcdfdbd1..388c0b676 100644 --- a/pkg/controller/worker/machines_test.go +++ b/pkg/controller/worker/machines_test.go @@ -84,7 +84,6 @@ var _ = Describe("Machines", func() { var ( namespace string cloudProfileName string - identityID = "identity-id" azureClientID string azureClientSecret string @@ -102,6 +101,7 @@ var _ = Describe("Machines", func() { vnetName string subnetName string availabilitySetID string + identityID string machineType string userData []byte volumeSize int @@ -129,6 +129,8 @@ var _ = Describe("Machines", func() { clusterWithoutImages *extensionscontroller.Cluster cluster *extensionscontroller.Cluster w *extensionsv1alpha1.Worker + + boolTrue = true ) BeforeEach(func() { @@ -155,6 +157,7 @@ var _ = Describe("Machines", func() { userData = []byte("some-user-data") volumeSize = 20 sshKey = "public-key" + identityID = "identity-id" namePool1 = "pool-1" minPool1 = 5 @@ -180,7 +183,6 @@ var _ = Describe("Machines", func() { }, }, } - cloudProfileConfig := &apiv1alpha1.CloudProfileConfig{ TypeMeta: metav1.TypeMeta{ APIVersion: apiv1alpha1.SchemeGroupVersion.String(), @@ -191,8 +193,9 @@ var _ = Describe("Machines", func() { Name: machineImageName, Versions: []apiv1alpha1.MachineImageVersion{ apiv1alpha1.MachineImageVersion{ - Version: machineImageVersion, - URN: &machineImageURN, + Version: machineImageVersion, + URN: &machineImageURN, + AcceleratedNetworking: &boolTrue, }, apiv1alpha1.MachineImageVersion{ Version: machineImageVersionID, @@ -201,6 +204,12 @@ var _ = Describe("Machines", func() { }, }, }, + MachineTypes: []apiv1alpha1.MachineType{ + apiv1alpha1.MachineType{ + Name: machineType, + AcceleratedNetworking: &boolTrue, + }, + }, } cloudProfileConfigJSON, _ := json.Marshal(cloudProfileConfig) cluster = &extensionscontroller.Cluster{ @@ -315,10 +324,13 @@ var _ = Describe("Machines", func() { BeforeEach(func() { defaultMachineClass := map[string]interface{}{ - "region": region, - "resourceGroup": resourceGroupName, - "vnetName": vnetName, - "subnetName": subnetName, + "region": region, + "resourceGroup": resourceGroupName, + "network": map[string]interface{}{ + "vnet": vnetName, + "subnet": subnetName, + "acceleratedNetworking": true, + }, "availabilitySetID": availabilitySetID, "tags": map[string]interface{}{ "Name": namespace, @@ -341,6 +353,10 @@ var _ = Describe("Machines", func() { "urn": machineImageURN, } + defaultMachineClass["network"] = map[string]interface{}{ + "vnet": vnetName, + "subnet": subnetName, + } imageIdMachineClass = copyMachineClass(defaultMachineClass) imageIdMachineClass["image"] = map[string]interface{}{ "id": machineImageID, @@ -408,9 +424,10 @@ var _ = Describe("Machines", func() { }, MachineImages: []apiv1alpha1.MachineImage{ { - Name: machineImageName, - Version: machineImageVersion, - URN: &machineImageURN, + Name: machineImageName, + Version: machineImageVersion, + URN: &machineImageURN, + AcceleratedNetworking: &boolTrue, }, { Name: machineImageName, @@ -430,9 +447,7 @@ var _ = Describe("Machines", func() { }) It("should fail because the secret cannot be read", func() { - c.EXPECT(). - Get(context.TODO(), gomock.Any(), gomock.AssignableToTypeOf(&corev1.Secret{})). - Return(fmt.Errorf("error")) + c.EXPECT().Get(context.TODO(), gomock.Any(), gomock.AssignableToTypeOf(&corev1.Secret{})).Return(fmt.Errorf("error")) result, err := workerDelegate.GenerateMachineDeployments(context.TODO()) Expect(err).To(HaveOccurred())