in internal/deployers/eksapi/node.go [712:748]
func (m *nodeManager) getNetworkInterfaces(opts *deployerOptions, securityGroups []string, subnetIDs []string) ([]templates.NetworkInterface, error) {
if !opts.EFA {
// create only the default primary network interface if not using EFA
netiface, err := getNetworkInterface(opts, 0, subnetIDs, securityGroups)
if err != nil {
return nil, err
}
return []templates.NetworkInterface{netiface}, nil
}
// EFA option assumes a single instance type
instanceType := opts.InstanceTypes[0]
ec2InstanceType := ec2types.InstanceType(instanceType)
describeInstanceTypeOutput, err := m.clients.EC2().DescribeInstanceTypes(context.TODO(), &ec2.DescribeInstanceTypesInput{
InstanceTypes: []ec2types.InstanceType{ec2InstanceType},
})
if err != nil {
return nil, fmt.Errorf("failed to describe instance type %s to get network interface support: %v", instanceType, err)
}
networkInfo := describeInstanceTypeOutput.InstanceTypes[0].NetworkInfo
if !aws.ToBool(networkInfo.EfaSupported) {
// fail early for better transparency
return nil, fmt.Errorf("cannot generate efa interfaces for instance type %s because it does not support efa", instanceType)
}
// 1 EFA interface is supported per network card
// https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa.html#efa-limits
numEfaInterfaces := int(aws.ToInt32(networkInfo.MaximumNetworkCards))
var networkInterfaces []templates.NetworkInterface
for cardIndex := range numEfaInterfaces {
efaInterface, err := getNetworkInterface(opts, cardIndex, subnetIDs, securityGroups)
if err != nil {
return nil, err
}
networkInterfaces = append(networkInterfaces, efaInterface)
}
return networkInterfaces, nil
}