diff --git a/go.mod b/go.mod index e67af16d3b..32fa718847 100644 --- a/go.mod +++ b/go.mod @@ -130,6 +130,7 @@ require ( github.com/ashanbrown/forbidigo v1.6.0 // indirect github.com/ashanbrown/makezero v1.2.0 // indirect github.com/atotto/clipboard v0.1.4 // indirect + github.com/aws/amazon-ec2-instance-selector/v3 v3.1.0 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.29 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.33 // indirect diff --git a/go.sum b/go.sum index 275c74fd88..29e24f43c7 100644 --- a/go.sum +++ b/go.sum @@ -104,6 +104,8 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aws/amazon-ec2-instance-selector/v2 v2.4.2-0.20231216170552-14d4dfcbaadf h1:1zems5/6/Fs+1dFsjTZ+oSogVHkfGl1VWuttRXYGx+0= github.com/aws/amazon-ec2-instance-selector/v2 v2.4.2-0.20231216170552-14d4dfcbaadf/go.mod h1:zsxolOKwtNEvoOPScJy5+Bu8F72LZy7pqVJNhP8tqVE= +github.com/aws/amazon-ec2-instance-selector/v3 v3.1.0 h1:NtSErNyyzyMzV3RXD3HGMTYUHD+XcaHbAMQHFaoU5Y4= +github.com/aws/amazon-ec2-instance-selector/v3 v3.1.0/go.mod h1:S8Yga4m3aMYvvCDWE4DA72hywLmvY/yknG45QiW0l/M= github.com/aws/aws-sdk-go v1.55.6 h1:cSg4pvZ3m8dgYcgqB97MrcdjUmZ1BeMYKUxMMB89IPk= github.com/aws/aws-sdk-go v1.55.6/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= github.com/aws/aws-sdk-go-v2 v1.36.2 h1:Ub6I4lq/71+tPb/atswvToaLGVMxKZvjYDVOWEExOcU= diff --git a/integration/tests/instance_selector/instance_selector_test.go b/integration/tests/instance_selector/instance_selector_test.go index dd763461e4..ea42f35e1f 100644 --- a/integration/tests/instance_selector/instance_selector_test.go +++ b/integration/tests/instance_selector/instance_selector_test.go @@ -62,6 +62,7 @@ var _ = Describe("(Integration) [Instance Selector test]", func() { }, "--instance-selector-vcpus=8", "--instance-selector-memory=32", "--instance-selector-gpus=0", + "--instance-selector-accelerators=0", ), Entry("with vCPUs and memory", nil, "--instance-selector-vcpus=8", diff --git a/pkg/apis/eksctl.io/v1alpha5/types.go b/pkg/apis/eksctl.io/v1alpha5/types.go index 71820ef56e..0fa89d31b8 100644 --- a/pkg/apis/eksctl.io/v1alpha5/types.go +++ b/pkg/apis/eksctl.io/v1alpha5/types.go @@ -1999,6 +1999,9 @@ type InstanceSelector struct { // GPUs specifies the number of GPUs. // It can be set to 0 to select non-GPU instance types. GPUs *int `json:"gpus,omitempty"` + // Accelerators specifies the number of Accelerators. + // It can be set to 0 to select non-Accelerator instance types. + Accelerators *int `json:"accelerators,omitempty"` // CPU Architecture of the EC2 instance type. // Valid variants are: // `"x86_64"` diff --git a/pkg/apis/eksctl.io/v1alpha5/validation.go b/pkg/apis/eksctl.io/v1alpha5/validation.go index 0dcf40f0cc..0bead95bab 100644 --- a/pkg/apis/eksctl.io/v1alpha5/validation.go +++ b/pkg/apis/eksctl.io/v1alpha5/validation.go @@ -62,6 +62,10 @@ var ( GPUDriversWarning = func(amiFamily string) string { return fmt.Sprintf("%s does not ship with NVIDIA GPU drivers installed, hence won't support running GPU-accelerated workloads out of the box", amiFamily) } + + AcceleratorDriversWarning = func(amiFamily string) string { + return fmt.Sprintf("%s does not ship with Inferentia Accelerators drivers installed, hence won't support running inference-accelerated workloads out of the box", amiFamily) + } ) var ( @@ -736,6 +740,10 @@ func validateNodeGroupBase(np NodePool, path string, controlPlaneOnOutposts bool (ng.InstanceSelector.GPUs == nil || *ng.InstanceSelector.GPUs != 0) { logger.Warning("instance selector may/will select GPU instance types, " + GPUDriversWarning(ng.AMIFamily)) } + if ng.InstanceSelector != nil && !ng.InstanceSelector.IsZero() && + (ng.InstanceSelector.Accelerators == nil || *ng.InstanceSelector.Accelerators != 0) { + logger.Warning("instance selector may/will select Accelerator instance types, " + AcceleratorDriversWarning(ng.AMIFamily)) + } } if ng.AMIFamily != NodeImageFamilyAmazonLinux2 && diff --git a/pkg/ctl/cmdutils/configfile.go b/pkg/ctl/cmdutils/configfile.go index d0b082e8aa..6c3cecf4ee 100644 --- a/pkg/ctl/cmdutils/configfile.go +++ b/pkg/ctl/cmdutils/configfile.go @@ -674,6 +674,9 @@ func normalizeBaseNodeGroup(np api.NodePool, cmd *cobra.Command) { if !flags.Changed("instance-selector-gpus") { ng.InstanceSelector.GPUs = nil } + if !flags.Changed("instance-selector-accelerators") { + ng.InstanceSelector.Accelerators = nil + } if !flags.Changed("enable-ssm") { ng.SSH.EnableSSM = nil } diff --git a/pkg/ctl/cmdutils/nodegroup_flags.go b/pkg/ctl/cmdutils/nodegroup_flags.go index 50f4c751ea..3e9ac6cd67 100644 --- a/pkg/ctl/cmdutils/nodegroup_flags.go +++ b/pkg/ctl/cmdutils/nodegroup_flags.go @@ -75,6 +75,7 @@ func AddInstanceSelectorOptions(flagSetGroup *NamedFlagSetGroup, ng *api.NodeGro fs.StringVar(&ng.InstanceSelector.Memory, "instance-selector-memory", "", "4 or 4GiB") fs.StringVar(&ng.InstanceSelector.CPUArchitecture, "instance-selector-cpu-architecture", "", "x86_64, or arm64") ng.InstanceSelector.GPUs = fs.Int("instance-selector-gpus", 0, "an integer value") + ng.InstanceSelector.Accelerators = fs.Int("instance-selector-accelerators", 0, "an integer value") }) } diff --git a/pkg/ctl/create/cluster.go b/pkg/ctl/create/cluster.go index b66007762c..56303e1e11 100644 --- a/pkg/ctl/create/cluster.go +++ b/pkg/ctl/create/cluster.go @@ -20,7 +20,7 @@ import ( kubeclient "k8s.io/client-go/kubernetes" clientcmdlatest "k8s.io/client-go/tools/clientcmd/api/latest" - "github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector" + "github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector" "github.com/weaveworks/eksctl/pkg/accessentry" accessentryactions "github.com/weaveworks/eksctl/pkg/actions/accessentry" "github.com/weaveworks/eksctl/pkg/actions/addon" diff --git a/pkg/ctl/create/nodegroup.go b/pkg/ctl/create/nodegroup.go index e0669774f5..91ce6f9ff0 100644 --- a/pkg/ctl/create/nodegroup.go +++ b/pkg/ctl/create/nodegroup.go @@ -5,7 +5,7 @@ import ( "fmt" "io" - "github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector" + "github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector" "github.com/kris-nova/logger" "github.com/pkg/errors" diff --git a/pkg/ctl/get/nodegroup.go b/pkg/ctl/get/nodegroup.go index 4991391af7..566413f8ef 100644 --- a/pkg/ctl/get/nodegroup.go +++ b/pkg/ctl/get/nodegroup.go @@ -8,7 +8,7 @@ import ( "strconv" "time" - "github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector" + "github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector" "github.com/kris-nova/logger" "github.com/spf13/cobra" "github.com/spf13/pflag" diff --git a/pkg/ctl/scale/nodegroup.go b/pkg/ctl/scale/nodegroup.go index 1126480b57..1eb71dd312 100644 --- a/pkg/ctl/scale/nodegroup.go +++ b/pkg/ctl/scale/nodegroup.go @@ -3,7 +3,7 @@ package scale import ( "context" - "github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector" + "github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector" "github.com/spf13/cobra" "github.com/spf13/pflag" diff --git a/pkg/ctl/update/nodegroup.go b/pkg/ctl/update/nodegroup.go index e4e75f4a04..1ffe77dfb5 100644 --- a/pkg/ctl/update/nodegroup.go +++ b/pkg/ctl/update/nodegroup.go @@ -3,7 +3,7 @@ package update import ( "context" - "github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector" + "github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector" "github.com/lithammer/dedent" "github.com/spf13/cobra" diff --git a/pkg/ctl/upgrade/nodegroup.go b/pkg/ctl/upgrade/nodegroup.go index 7bf566cf11..0b85d6e984 100644 --- a/pkg/ctl/upgrade/nodegroup.go +++ b/pkg/ctl/upgrade/nodegroup.go @@ -4,7 +4,7 @@ import ( "context" "time" - "github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector" + "github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector" "github.com/spf13/cobra" "github.com/spf13/pflag" diff --git a/pkg/eks/fakes/fake_instance_selector.go b/pkg/eks/fakes/fake_instance_selector.go index c0fa903bb8..fae581e298 100644 --- a/pkg/eks/fakes/fake_instance_selector.go +++ b/pkg/eks/fakes/fake_instance_selector.go @@ -5,7 +5,7 @@ import ( "context" "sync" - "github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector" + "github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector" "github.com/weaveworks/eksctl/pkg/eks" ) diff --git a/pkg/eks/nodegroup_service.go b/pkg/eks/nodegroup_service.go index bfd4034ccd..cbd35f3626 100644 --- a/pkg/eks/nodegroup_service.go +++ b/pkg/eks/nodegroup_service.go @@ -6,8 +6,8 @@ import ( "reflect" "strings" - "github.com/aws/amazon-ec2-instance-selector/v2/pkg/bytequantity" - "github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector" + "github.com/aws/amazon-ec2-instance-selector/v3/pkg/bytequantity" + "github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector" "github.com/aws/aws-sdk-go-v2/aws" "github.com/kris-nova/logger" "github.com/pkg/errors" @@ -202,6 +202,12 @@ func (n *NodeGroupService) expandInstanceSelector(ins *api.InstanceSelector, azs if ins.GPUs != nil { filters.GpusRange = makeRange(*ins.GPUs) } + if ins.Accelerators != nil { + filters.InferenceAcceleratorsRange = &selector.IntRangeFilter{ + LowerBound: *ins.Accelerators, + UpperBound: *ins.Accelerators, + } + } cpuArch := ins.CPUArchitecture if cpuArch == "" { cpuArch = defaultCPUArch diff --git a/userdocs/src/usage/instance-selector.md b/userdocs/src/usage/instance-selector.md index 0ba096d10e..5d0c5deedf 100644 --- a/userdocs/src/usage/instance-selector.md +++ b/userdocs/src/usage/instance-selector.md @@ -60,7 +60,7 @@ $ eksctl create cluster -f instance-selector-cluster.yaml The following instance selector CLI options are supported by `eksctl create cluster` and `eksctl create nodegroup`: -`--instance-selector-vcpus`, `--instance-selector-memory`, `--instance-selector-gpus` and `instance-selector-cpu-architecture` +`--instance-selector-vcpus`, `--instance-selector-memory`, `--instance-selector-gpus`, `--instance-selector-accelerators` and `instance-selector-cpu-architecture` ???+ note By default, GPU instance types are not filtered out. If you wish to do so (e.g. for cost effectiveness, when your applications don't particularly benefit from GPU-accelerated workloads), please explicitly set `gpus: 0` (via config file) or `--instance-selector-gpus=0` (via CLI flag).