Skip to content

Commit

Permalink
Add --instance-type-archs flag (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
cartermckinnon authored Dec 20, 2024
1 parent c649cbe commit e7dce5d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion kubetest2/internal/deployers/eksapi/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ type deployerOptions struct {
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."`
// TODO: remove this once it's no longer used in downstream jobs
GenerateSSHKey bool `flag:"generate-ssh-key" desc:"Generate an SSH key to use for tests. The generated key should not be used in production, as it will not have a passphrase."`
InstanceTypes []string `flag:"instance-types" desc:"Node instance types"`
InstanceTypes []string `flag:"instance-types" desc:"Node instance types. Cannot be used with --instance-type-archs"`
InstanceTypeArchs []string `flag:"instance-type-archs" desc:"Use default node instance types for specific architectures. Cannot be used with --instance-types"`
IPFamily string `flag:"ip-family" desc:"IP family for the cluster (ipv4 or ipv6)"`
KubeconfigPath string `flag:"kubeconfig" desc:"Path to kubeconfig"`
KubernetesVersion string `flag:"kubernetes-version" desc:"cluster Kubernetes version"`
Expand Down Expand Up @@ -259,6 +260,9 @@ func (d *deployer) verifyUpFlags() error {
klog.Infof("Skip configuration for static cluster")
return nil
}
if len(d.InstanceTypes) > 0 && len(d.InstanceTypeArchs) > 0 {
return fmt.Errorf("--instance-types and --instance-type-archs are mutually exclusive")
}
if d.UnmanagedNodes {
if d.AMI == "" {
return fmt.Errorf("--ami must be specified for --unmanaged-nodes")
Expand Down
12 changes: 11 additions & 1 deletion kubetest2/internal/deployers/eksapi/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,17 @@ func (m *nodeManager) createNodes(infra *Infrastructure, cluster *Cluster, opts
func (m *nodeManager) resolveInstanceTypes(opts *deployerOptions) (err error) {
instanceTypes := opts.InstanceTypes
if len(instanceTypes) == 0 {
if opts.UnmanagedNodes {

if len(opts.InstanceTypeArchs) > 0 {
klog.Infof("choosing instance types based on architecture(s): %v", opts.InstanceTypeArchs)
for _, arch := range opts.InstanceTypeArchs {
instanceTypesForArch, ok := defaultInstanceTypesByEC2ArchitectureValues[ec2types.ArchitectureValues(arch)]
if !ok {
return fmt.Errorf("no default instance types known for architecture: '%s'", arch)
}
instanceTypes = append(instanceTypes, instanceTypesForArch...)
}
} else if opts.UnmanagedNodes {
klog.Infof("choosing instance types based on AMI architecture...")
if out, err := m.clients.EC2().DescribeImages(context.TODO(), &ec2.DescribeImagesInput{
ImageIds: []string{opts.AMI},
Expand Down

0 comments on commit e7dce5d

Please sign in to comment.