Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach EFA SG to network interfaces #3467

Merged
merged 4 commits into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/cfn/builder/managed_launch_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func (m *ManagedNodeGroupResourceSet) makeLaunchTemplateData() (*gfnec2.LaunchTe
if api.IsEnabled(mng.EFAEnabled) {
// we don't want to touch the network interfaces at all if we have a
// managed nodegroup, unless EFA is enabled
desc := "worker nodes in group " + m.nodeGroup.Name
efaSG := m.addEFASecurityGroup(m.vpcImporter.VPC(), m.clusterConfig.Metadata.Name, desc)
securityGroupIDs = append(securityGroupIDs, efaSG)
if err := buildNetworkInterfaces(launchTemplateData, mng.InstanceTypeList(), true, securityGroupIDs, m.ec2API); err != nil {
return nil, errors.Wrap(err, "couldn't build network interfaces for launch template data")
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/cfn/builder/managed_nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ func (m *ManagedNodeGroupResourceSet) AddAllResources() error {
Id: ltRef,
}
}
if api.IsEnabled(m.nodeGroup.EFAEnabled) {
desc := "worker nodes in group " + m.nodeGroup.Name
m.addEFASecurityGroup(m.vpcImporter.VPC(), m.clusterConfig.Metadata.Name, desc)
}

managedResource.LaunchTemplate = launchTemplate
m.newResource(ManagedNodeGroupResourceName, managedResource)
Expand Down
7 changes: 5 additions & 2 deletions pkg/cfn/builder/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func (c *ClusterResourceSet) addResourcesForSecurityGroups(vpcResource *VPCResou
}
}

func (rs *resourceSet) addEFASecurityGroup(vpcID *gfnt.Value, clusterName, desc string) {
func (rs *resourceSet) addEFASecurityGroup(vpcID *gfnt.Value, clusterName, desc string) *gfnt.Value {
efaSG := rs.newResource("EFASG", &gfnec2.SecurityGroup{
VpcId: vpcID,
GroupDescription: gfnt.NewString("EFA-enabled security group"),
Expand All @@ -471,6 +471,8 @@ func (rs *resourceSet) addEFASecurityGroup(vpcID *gfnt.Value, clusterName, desc
Description: gfnt.NewString("Allow " + desc + " to communicate to itself (EFA-enabled)"),
IpProtocol: gfnt.NewString("-1"),
})

return efaSG
}

func (n *NodeGroupResourceSet) addResourcesForSecurityGroups() {
Expand Down Expand Up @@ -503,7 +505,8 @@ func (n *NodeGroupResourceSet) addResourcesForSecurityGroups() {
n.securityGroups = append(n.securityGroups, refNodeGroupLocalSG)

if api.IsEnabled(n.spec.EFAEnabled) {
n.rs.addEFASecurityGroup(vpcID, n.clusterSpec.Metadata.Name, desc)
efaSG := n.rs.addEFASecurityGroup(vpcID, n.clusterSpec.Metadata.Name, desc)
n.securityGroups = append(n.securityGroups, efaSG)
}

n.newResource("EgressInterCluster", &gfnec2.SecurityGroupEgress{
Expand Down