Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 0 additions & 11 deletions kubetest2/internal/deployers/eksapi/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,6 @@ func (d *deployer) verifyUpFlags() error {
d.IPFamily = string(ekstypes.IpFamilyIpv4)
klog.V(2).Infof("Using default IP family: %s", d.IPFamily)
}
if len(d.InstanceTypes) == 0 && d.UnmanagedNodes {
d.InstanceTypes = []string{
"m6i.xlarge",
"m6i.large",
"m6a.large",
"m5.large",
"m5a.large",
"m4.large",
}
klog.V(2).Infof("Using default instance types: %v", d.InstanceTypes)
}
if d.UnmanagedNodes && d.AMI == "" {
return fmt.Errorf("--ami must be specified for --unmanaged-nodes")
}
Expand Down
39 changes: 39 additions & 0 deletions kubetest2/internal/deployers/eksapi/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/cloudformation"
cloudformationtypes "github.com/aws/aws-sdk-go-v2/service/cloudformation/types"
"github.com/aws/aws-sdk-go-v2/service/ec2"
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
"github.com/aws/aws-sdk-go-v2/service/eks"
ekstypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
"k8s.io/klog/v2"
Expand All @@ -27,6 +28,26 @@ const (
nodegroupDeletionTimeout = time.Minute * 20
)

var (
defaultInstanceTypes_x86_64 = []string{
"m6i.xlarge",
"m6i.large",
"m6a.large",
"m5.large",
"m5a.large",
"m4.large",
}

defaultInstanceTypes_arm64 = []string{
"m7g.xlarge",
"m7g.large",
"m6g.xlarge",
"m6g.large",
"t4g.xlarge",
"t4g.large",
}
)

type NodegroupManager struct {
clients *awsClients
resourceID string
Expand All @@ -41,6 +62,24 @@ func NewNodegroupManager(clients *awsClients, resourceID string) *NodegroupManag

func (m *NodegroupManager) createNodegroup(infra *Infrastructure, cluster *Cluster, opts *deployerOptions) error {
if opts.UnmanagedNodes {
if len(opts.InstanceTypes) == 0 {
if out, err := m.clients.EC2().DescribeImages(context.TODO(), &ec2.DescribeImagesInput{
ImageIds: []string{opts.AMI},
}); err != nil {
return fmt.Errorf("failed to describe AMI when populating default instance types: %s: %v", opts.AMI, err)
} else {
amiArch := out.Images[0].Architecture
switch out.Images[0].Architecture {
case ec2types.ArchitectureValuesX8664:
opts.InstanceTypes = defaultInstanceTypes_x86_64
case ec2types.ArchitectureValuesArm64:
opts.InstanceTypes = defaultInstanceTypes_arm64
default:
return fmt.Errorf("no default instance types known for AMI architecture: %v", out.Images[0].Architecture)
}
klog.V(2).Infof("Using default instance types for AMI architecture: %v: %v", amiArch, opts.InstanceTypes)
}
}
if opts.EFA {
return m.createUnmanagedNodegroupWithEFA(infra, cluster, opts)
}
Expand Down