Skip to content

Commit

Permalink
fix: try to find suitable AZ for EFA, honor capacity-reservation for …
Browse files Browse the repository at this point in the history
…non-EFA (#588)

* combine nodegroup stacks for easier maintenance

* preserve comment

Co-authored-by: Nick Baker <[email protected]>

* remove redundant instance type, explicit error for efa

* Always create network interface

* Add instance-types flag requirement to EFA flag doc

* fix non-efa interface

* fix creation timeout var

* Fix non-EFA network interface case

* Undo extra EFA validation

* Remove EFA enabled parameter

* Force EFA ASGs to use the same subnet

* Isolate subnet & az selection for nodes

* force nil pointer if networkcardindex empty, only render interfaces if passed

---------

Co-authored-by: Nick Baker <[email protected]>
  • Loading branch information
mselim00 and ndbaker1 authored Feb 27, 2025
1 parent 5e2e5c1 commit ecc47a9
Show file tree
Hide file tree
Showing 6 changed files with 266 additions and 453 deletions.
2 changes: 1 addition & 1 deletion internal/deployers/eksapi/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type deployerOptions struct {
CapacityReservation bool `flag:"capacity-reservation" desc:"Use capacity reservation for the unmanaged nodegroup"`
ClusterCreationTimeout time.Duration `flag:"cluster-creation-timeout" desc:"Time to wait for cluster to be created and become active."`
ClusterRoleServicePrincipal string `flag:"cluster-role-service-principal" desc:"Additional service principal that can assume the cluster role"`
EFA bool `flag:"efa" desc:"Create EFA interfaces on the node of an unmanaged nodegroup. Requires --unmanaged-nodes."`
EFA bool `flag:"efa" desc:"Create EFA interfaces on the node of an unmanaged nodegroup. One instance type must be passed if set. Requires --unmanaged-nodes and --instance-types."`
EKSEndpointURL string `flag:"endpoint-url" desc:"Endpoint URL for the EKS API"`
EmitMetrics bool `flag:"emit-metrics" desc:"Record and emit metrics to CloudWatch"`
ExpectedAMI string `flag:"expected-ami" desc:"Expected AMI of nodes. Up will fail if the actual nodes are not utilizing the expected AMI. Defaults to --ami if defined."`
Expand Down
15 changes: 9 additions & 6 deletions internal/deployers/eksapi/infra.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,21 @@ func NewInfrastructureManager(clients *awsClients, resourceID string, metrics me
}

type Infrastructure struct {
vpc string
subnetsPublic []string
subnetsPrivate []string
clusterRoleARN string
nodeRoleARN string
nodeRoleName string
availabilityZones []string
vpc string
subnetsPublic []string
subnetsPrivate []string
clusterRoleARN string
nodeRoleARN string
nodeRoleName string
}

func (i *Infrastructure) subnets() []string {
return append(i.subnetsPublic, i.subnetsPrivate...)
}

func (m *InfrastructureManager) createInfrastructureStack(opts *deployerOptions) (*Infrastructure, error) {
// TODO: create a subnet in every AZ
// get two AZs for the subnets
azs, err := m.clients.EC2().DescribeAvailabilityZones(context.TODO(), &ec2.DescribeAvailabilityZonesInput{})
if err != nil {
Expand Down Expand Up @@ -165,6 +167,7 @@ func (m *InfrastructureManager) createInfrastructureStack(opts *deployerOptions)
}
klog.Infof("getting infrastructure stack resources: %s", *out.StackId)
infra, err := m.getInfrastructureStackResources()
infra.availabilityZones = subnetAzs
if err != nil {
return nil, fmt.Errorf("failed to get infrastructure stack resources: %w", err)
}
Expand Down
Loading

0 comments on commit ecc47a9

Please sign in to comment.