Skip to content

Commit 1f2732f

Browse files
committed
Implement support for EFA interface type
1 parent f3ba287 commit 1f2732f

11 files changed

+190
-5
lines changed

api/v1beta1/awscluster_conversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error {
5959
dst.Status.Bastion.PlacementGroupPartition = restored.Status.Bastion.PlacementGroupPartition
6060
dst.Status.Bastion.PrivateDNSName = restored.Status.Bastion.PrivateDNSName
6161
dst.Status.Bastion.PublicIPOnLaunch = restored.Status.Bastion.PublicIPOnLaunch
62+
dst.Status.Bastion.NetworkInterfaceType = restored.Status.Bastion.NetworkInterfaceType
6263
dst.Status.Bastion.CapacityReservationID = restored.Status.Bastion.CapacityReservationID
6364
dst.Status.Bastion.MarketType = restored.Status.Bastion.MarketType
6465
}

api/v1beta1/awsmachine_conversion.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func (src *AWSMachine) ConvertTo(dstRaw conversion.Hub) error {
4343
dst.Spec.SecurityGroupOverrides = restored.Spec.SecurityGroupOverrides
4444
dst.Spec.CapacityReservationID = restored.Spec.CapacityReservationID
4545
dst.Spec.MarketType = restored.Spec.MarketType
46+
dst.Spec.NetworkInterfaceType = restored.Spec.NetworkInterfaceType
4647
if restored.Spec.ElasticIPPool != nil {
4748
if dst.Spec.ElasticIPPool == nil {
4849
dst.Spec.ElasticIPPool = &infrav1.ElasticIPPool{}
@@ -106,6 +107,7 @@ func (r *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error {
106107
dst.Spec.Template.Spec.SecurityGroupOverrides = restored.Spec.Template.Spec.SecurityGroupOverrides
107108
dst.Spec.Template.Spec.CapacityReservationID = restored.Spec.Template.Spec.CapacityReservationID
108109
dst.Spec.Template.Spec.MarketType = restored.Spec.Template.Spec.MarketType
110+
dst.Spec.Template.Spec.NetworkInterfaceType = restored.Spec.Template.Spec.NetworkInterfaceType
109111
if restored.Spec.Template.Spec.ElasticIPPool != nil {
110112
if dst.Spec.Template.Spec.ElasticIPPool == nil {
111113
dst.Spec.Template.Spec.ElasticIPPool = &infrav1.ElasticIPPool{}

api/v1beta1/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/awsmachine_types.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ const (
5454
IgnitionStorageTypeOptionUnencryptedUserData = IgnitionStorageTypeOption("UnencryptedUserData")
5555
)
5656

57+
// NetworkInterfaceType is the type of network interface.
58+
type NetworkInterfaceType string
59+
60+
const (
61+
// NetworkInterfaceTypeENI means the network interface type is Elastic Network Interface.
62+
NetworkInterfaceTypeENI NetworkInterfaceType = NetworkInterfaceType("interface")
63+
// NetworkInterfaceTypeEFAWithENAInterface means the network interface type is Elastic Fabric Adapter with Elastic Network Adapter.
64+
NetworkInterfaceTypeEFAWithENAInterface NetworkInterfaceType = NetworkInterfaceType("efa")
65+
)
66+
5767
// AWSMachineSpec defines the desired state of an Amazon EC2 instance.
5868
type AWSMachineSpec struct {
5969
// ProviderID is the unique identifier as specified by the cloud provider.
@@ -153,6 +163,12 @@ type AWSMachineSpec struct {
153163
// +kubebuilder:validation:MaxItems=2
154164
NetworkInterfaces []string `json:"networkInterfaces,omitempty"`
155165

166+
// NetworkInterfaceType is the interface type of the primary network Interface.
167+
// If not specified, AWS applies a default value.
168+
// +kubebuilder:validation:Enum=interface;efa
169+
// +optional
170+
NetworkInterfaceType NetworkInterfaceType `json:"networkInterfaceType,omitempty"`
171+
156172
// UncompressedUserData specify whether the user data is gzip-compressed before it is sent to ec2 instance.
157173
// cloud-init has built-in support for gzip-compressed user data
158174
// user data stored in aws secret manager is always gzip-compressed.

api/v1beta2/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ type Instance struct {
217217
// Specifies ENIs attached to instance
218218
NetworkInterfaces []string `json:"networkInterfaces,omitempty"`
219219

220+
// NetworkInterfaceType is the interface type of the primary network Interface.
221+
NetworkInterfaceType NetworkInterfaceType `json:"networkInterfaceType,omitempty"`
222+
220223
// The tags associated with the instance.
221224
Tags map[string]string `json:"tags,omitempty"`
222225

config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,10 @@ spec:
12231223
- Spot
12241224
- CapacityBlock
12251225
type: string
1226+
networkInterfaceType:
1227+
description: NetworkInterfaceType is the interface type of the
1228+
primary network Interface.
1229+
type: string
12261230
networkInterfaces:
12271231
description: Specifies ENIs attached to instance
12281232
items:
@@ -3276,6 +3280,10 @@ spec:
32763280
- Spot
32773281
- CapacityBlock
32783282
type: string
3283+
networkInterfaceType:
3284+
description: NetworkInterfaceType is the interface type of the
3285+
primary network Interface.
3286+
type: string
32793287
networkInterfaces:
32803288
description: Specifies ENIs attached to instance
32813289
items:

config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,6 +2190,10 @@ spec:
21902190
- Spot
21912191
- CapacityBlock
21922192
type: string
2193+
networkInterfaceType:
2194+
description: NetworkInterfaceType is the interface type of the
2195+
primary network Interface.
2196+
type: string
21932197
networkInterfaces:
21942198
description: Specifies ENIs attached to instance
21952199
items:

config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,14 @@ spec:
891891
- Spot
892892
- CapacityBlock
893893
type: string
894+
networkInterfaceType:
895+
description: |-
896+
NetworkInterfaceType is the interface type of the primary network Interface.
897+
If not specified, AWS applies a default value.
898+
enum:
899+
- interface
900+
- efa
901+
type: string
894902
networkInterfaces:
895903
description: |-
896904
NetworkInterfaces is a list of ENIs to associate with the instance.

config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,14 @@ spec:
825825
- Spot
826826
- CapacityBlock
827827
type: string
828+
networkInterfaceType:
829+
description: |-
830+
NetworkInterfaceType is the interface type of the primary network Interface.
831+
If not specified, AWS applies a default value.
832+
enum:
833+
- interface
834+
- efa
835+
type: string
828836
networkInterfaces:
829837
description: |-
830838
NetworkInterfaces is a list of ENIs to associate with the instance.

pkg/cloud/services/ec2/instances.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,12 @@ func (s *Service) CreateInstance(scope *scope.MachineScope, userData []byte, use
113113
s.scope.Debug("Creating an instance for a machine")
114114

115115
input := &infrav1.Instance{
116-
Type: scope.AWSMachine.Spec.InstanceType,
117-
IAMProfile: scope.AWSMachine.Spec.IAMInstanceProfile,
118-
RootVolume: scope.AWSMachine.Spec.RootVolume.DeepCopy(),
119-
NonRootVolumes: scope.AWSMachine.Spec.NonRootVolumes,
120-
NetworkInterfaces: scope.AWSMachine.Spec.NetworkInterfaces,
116+
Type: scope.AWSMachine.Spec.InstanceType,
117+
IAMProfile: scope.AWSMachine.Spec.IAMInstanceProfile,
118+
RootVolume: scope.AWSMachine.Spec.RootVolume.DeepCopy(),
119+
NonRootVolumes: scope.AWSMachine.Spec.NonRootVolumes,
120+
NetworkInterfaces: scope.AWSMachine.Spec.NetworkInterfaces,
121+
NetworkInterfaceType: scope.AWSMachine.Spec.NetworkInterfaceType,
121122
}
122123

123124
// Make sure to use the MachineScope here to get the merger of AWSCluster and AWSMachine tags
@@ -584,6 +585,10 @@ func (s *Service) runInstance(role string, i *infrav1.Instance) (*infrav1.Instan
584585
}
585586
}
586587

588+
if i.NetworkInterfaceType != "" {
589+
input.NetworkInterfaces[0].InterfaceType = aws.String(string(i.NetworkInterfaceType))
590+
}
591+
587592
if i.IAMProfile != "" {
588593
input.IamInstanceProfile = &ec2.IamInstanceProfileSpecification{
589594
Name: aws.String(i.IAMProfile),

0 commit comments

Comments
 (0)