@@ -408,12 +408,14 @@ func (v *Validation) getPrioritizedInstanceTypes(ctx context.Context, nodeClass
408408 if err != nil {
409409 return nil , err
410410 }
411- // We fallback to the default instance type if the AMI family is Windows. Karpenter currently incorrectly marks certain instance
412- // types as Windows compatible, and dynamic instance type resolution may choose those instance types for the dry-run, even if they
411+ // If there weren't any matching instance types, we should fallback to some defaults. There's an instance type included
412+ // for both x86_64 and arm64 architectures, ensuring that there will be a matching AMI. We also fallback to the default
413+ // instance types if the AMI family is Windows. Karpenter currently incorrectly marks certain instance types as Windows
414+ // compatible, and dynamic instance type resolution may choose those instance types for the dry-run, even if they
413415 // wouldn't be chosen due to cost in practice. This ensures the behavior matches that on Karpenter v1.3, preventing a
414416 // potential regression for Windows users.
415417 // Tracking issue: https://github.com/aws/karpenter-provider-aws/issues/7985
416- if lo .ContainsBy ([]string {
418+ if len ( instanceTypes ) == 0 || lo .ContainsBy ([]string {
417419 v1 .AMIFamilyWindows2019 ,
418420 v1 .AMIFamilyWindows2022 ,
419421 v1 .AMIFamilyWindows2025 ,
@@ -430,14 +432,18 @@ func (v *Validation) getPrioritizedInstanceTypes(ctx context.Context, nodeClass
430432 scheduling .NewRequirement (corev1 .LabelWindowsBuild , corev1 .NodeSelectorOpExists ),
431433 )... ),
432434 },
435+ {
436+ Name : string (ec2types .InstanceTypeM6gLarge ),
437+ Requirements : scheduling .NewRequirements (append (
438+ lo .Values (amifamily .VariantStandard .Requirements ()),
439+ scheduling .NewRequirement (corev1 .LabelArchStable , corev1 .NodeSelectorOpIn , karpv1 .ArchitectureArm64 ),
440+ scheduling .NewRequirement (corev1 .LabelOSStable , corev1 .NodeSelectorOpExists ),
441+ scheduling .NewRequirement (corev1 .LabelWindowsBuild , corev1 .NodeSelectorOpExists ),
442+ )... ),
443+ },
433444 }
434445 instanceTypes = getAMICompatibleInstanceTypes (instanceTypes , nodeClass )
435446 }
436-
437- if len (instanceTypes ) == 0 {
438- panic ("Could not select on any instance type during NodeClass validation" )
439- }
440-
441447 return instanceTypes , nil
442448}
443449
0 commit comments