Skip to content
Draft
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
22 changes: 22 additions & 0 deletions pkg/actions/accessentry/migrator_internal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package accessentry

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/weaveworks/eksctl/pkg/authconfigmap"
"github.com/weaveworks/eksctl/pkg/iam"
)

// {{SessionName}} mappings are shared by Fargate, hybrid and AmazonLinux2027 nodes, so their access entry type is unknown.
var _ = DescribeTable("Migrate {{SessionName}} iamidentitymapping", func(groups []string) {
identity, err := iam.NewIdentity("arn:aws:iam::111122223333:role/test", authconfigmap.RoleNodeGroupUsernameInstanceID, groups)
Expect(err).NotTo(HaveOccurred())

entries, skipAPIMode := doFilterAccessEntries([]iam.Identity{identity}, nil)
Expect(entries).To(BeEmpty())
Expect(skipAPIMode).To(BeTrue())
},
Entry("Fargate pod execution role", []string{"system:bootstrappers", "system:nodes", "system:node-proxier"}),
Entry("hybrid nodes or AmazonLinux2027 node role", authconfigmap.RoleNodeGroupGroups),
)
4 changes: 2 additions & 2 deletions pkg/ami/ssm_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func MakeSSMParameterName(version, instanceType, imageFamily string) (string, er
const fieldName = "image_id"

switch imageFamily {
case api.NodeImageFamilyAmazonLinux2023:
case api.NodeImageFamilyAmazonLinux2023, api.NodeImageFamilyAmazonLinux2027:
return fmt.Sprintf("/aws/service/eks/optimized-ami/%s/%s/%s/%s/recommended/%s",
version, utils.ToKebabCase(imageFamily), instanceEC2ArchName(instanceType), imageType(imageFamily, instanceType, version), fieldName), nil
case api.NodeImageFamilyAmazonLinux2:
Expand Down Expand Up @@ -178,7 +178,7 @@ func ubuntuArchName(instanceType string) string {
func imageType(imageFamily, instanceType, version string) string {
family := utils.ToKebabCase(imageFamily)
switch imageFamily {
case api.NodeImageFamilyAmazonLinux2023:
case api.NodeImageFamilyAmazonLinux2023, api.NodeImageFamilyAmazonLinux2027:
if instanceutils.IsNvidiaInstanceType(instanceType) {
return "nvidia"
}
Expand Down
23 changes: 23 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/access_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (

"github.com/aws/aws-sdk-go-v2/aws/arn"
ekstypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
nodeadm "github.com/awslabs/amazon-eks-ami/nodeadm/api/v1alpha1"
"sigs.k8s.io/yaml"
)

// AccessEntry represents an access entry for managing access to a cluster.
Expand Down Expand Up @@ -66,9 +68,30 @@ func GetAccessEntryType(ng *NodeGroup) AccessEntryType {
if IsWindowsImage(ng.GetAMIFamily()) {
return AccessEntryTypeWindows
}
// EC2 maps nodes to system:node:{{SessionName}} (the instance ID); EC2_LINUX uses the private DNS name.
if UsesInstanceIDNodeName(ng.NodeGroupBase) {
return AccessEntryTypeEC2
}
return AccessEntryTypeLinux
}

// UsesInstanceIDNodeName reports whether nodeadm names the nodegroup's nodes by EC2 instance ID.
// This is the default for AmazonLinux2027. The InstanceIdNodeName feature gate in overrideBootstrapCommand overrides it.
func UsesInstanceIDNodeName(ng *NodeGroupBase) bool {
if !IsNodeadmImage(ng.AMIFamily) {
return false
}
if ng.OverrideBootstrapCommand != nil {
var nodeConfig nodeadm.NodeConfig
if err := yaml.Unmarshal([]byte(*ng.OverrideBootstrapCommand), &nodeConfig); err == nil {
if enabled, ok := nodeConfig.Spec.FeatureGates[nodeadm.InstanceIdNodeName]; ok {
return enabled
}
}
}
return ng.AMIFamily == NodeImageFamilyAmazonLinux2027
}

type ARN arn.ARN

// ARN provides custom unmarshalling for an AWS ARN.
Expand Down
131 changes: 131 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/al2027_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package v1alpha5_test

import (
"fmt"

"github.com/aws/aws-sdk-go-v2/aws"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
)

// instanceIDNodeNameConfig returns a nodeadm NodeConfig that sets the InstanceIdNodeName feature gate.
func instanceIDNodeNameConfig(enabled bool) *string {
return aws.String(fmt.Sprintf(`apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
featureGates:
InstanceIdNodeName: %t
`, enabled))
}

var _ = Describe("AmazonLinux2027", func() {
It("is a supported AMI family", func() {
Expect(api.SupportedAMIFamilies()).To(ContainElement(api.NodeImageFamilyAmazonLinux2027))
})

DescribeTable("IsNodeadmImage", func(amiFamily string, expected bool) {
Expect(api.IsNodeadmImage(amiFamily)).To(Equal(expected))
},
Entry(api.NodeImageFamilyAmazonLinux2027, api.NodeImageFamilyAmazonLinux2027, true),
Entry(api.NodeImageFamilyAmazonLinux2023, api.NodeImageFamilyAmazonLinux2023, true),
Entry(api.NodeImageFamilyAmazonLinux2, api.NodeImageFamilyAmazonLinux2, false),
Entry(api.NodeImageFamilyBottlerocket, api.NodeImageFamilyBottlerocket, false),
)

DescribeTable("node name and access entry type", func(amiFamily string, overrideBootstrapCommand *string, usesInstanceIDNodeName bool, expectedType api.AccessEntryType) {
ng := api.NewNodeGroup()
ng.AMIFamily = amiFamily
ng.OverrideBootstrapCommand = overrideBootstrapCommand
Expect(api.UsesInstanceIDNodeName(ng.NodeGroupBase)).To(Equal(usesInstanceIDNodeName))
Expect(api.GetAccessEntryType(ng)).To(Equal(expectedType))
},
Entry("AmazonLinux2027 by default", api.NodeImageFamilyAmazonLinux2027, (*string)(nil), true, api.AccessEntryTypeEC2),
Entry("AmazonLinux2027 with InstanceIdNodeName off", api.NodeImageFamilyAmazonLinux2027, instanceIDNodeNameConfig(false), false, api.AccessEntryTypeLinux),
Entry("AmazonLinux2027 with a NodeConfig that doesn't set InstanceIdNodeName", api.NodeImageFamilyAmazonLinux2027,
aws.String("apiVersion: node.eks.aws/v1alpha1\nkind: NodeConfig\nspec:\n instance:\n localStorage:\n strategy: RAID0\n"), true, api.AccessEntryTypeEC2),
Entry("AmazonLinux2023 by default", api.NodeImageFamilyAmazonLinux2023, (*string)(nil), false, api.AccessEntryTypeLinux),
Entry("AmazonLinux2023 with InstanceIdNodeName on", api.NodeImageFamilyAmazonLinux2023, instanceIDNodeNameConfig(true), true, api.AccessEntryTypeEC2),
Entry("AmazonLinux2 ignores overrideBootstrapCommand", api.NodeImageFamilyAmazonLinux2, aws.String("/etc/eks/bootstrap.sh my-cluster"), false, api.AccessEntryTypeLinux),
Entry("Windows", api.NodeImageFamilyWindowsServer2022CoreContainer, (*string)(nil), false, api.AccessEntryTypeWindows),
)

Describe("self-managed nodegroups", func() {
var (
cfg *api.ClusterConfig
ng *api.NodeGroup
)

BeforeEach(func() {
cfg = api.NewClusterConfig()
ng = cfg.NewNodeGroup()
ng.AMIFamily = api.NodeImageFamilyAmazonLinux2027
})

DescribeTable("accepts nodegroups without an AMI ID, as eksctl looks up the AMI", func(ami string) {
ng.AMI = ami
Expect(api.ValidateNodeGroup(0, ng, cfg)).To(Succeed())
},
Entry("ami not set", ""),
Entry("ami is auto-ssm", api.NodeImageResolverAutoSSM),
)

It("accepts an AMI ID without overrideBootstrapCommand", func() {
ng.AMI = "ami-0123456789abcdef0"
Expect(api.ValidateNodeGroup(0, ng, cfg)).To(Succeed())
})

It("accepts the InstanceIdNodeName feature gate in overrideBootstrapCommand", func() {
ng.AMI = "ami-0123456789abcdef0"
ng.OverrideBootstrapCommand = instanceIDNodeNameConfig(false)
Expect(api.ValidateNodeGroup(0, ng, cfg)).To(Succeed())
})

It("rejects the dockerd container runtime", func() {
ng.AMI = "ami-0123456789abcdef0"
ng.ContainerRuntime = aws.String(api.ContainerRuntimeDockerD)
Expect(api.ValidateNodeGroup(0, ng, cfg)).To(MatchError(ContainSubstring(fmt.Sprintf("only %s is supported for container runtime on %s nodes", api.ContainerRuntimeContainerD, api.NodeImageFamilyAmazonLinux2027))))
})

It("defaults the container runtime to containerd", func() {
ng.AMI = "ami-0123456789abcdef0"
Expect(api.SetNodeGroupDefaults(ng, &api.ClusterMeta{Version: api.Version1_23}, false)).To(Succeed())
Expect(*ng.ContainerRuntime).To(Equal(api.ContainerRuntimeContainerD))
})
})

DescribeTable("managed nodegroups", func(updateMNG func(*api.ManagedNodeGroup), expectedErr string) {
mng := api.NewManagedNodeGroup()
mng.AMIFamily = api.NodeImageFamilyAmazonLinux2027
mng.AMI = "ami-0123456789abcdef0"
updateMNG(mng)
err := api.ValidateManagedNodeGroup(0, mng)
if expectedErr == "" {
Expect(err).NotTo(HaveOccurred())
} else {
Expect(err).To(MatchError(ContainSubstring(expectedErr)))
}
},
Entry("rejects instance ID node names by default", func(*api.ManagedNodeGroup) {}, "nodes named by EC2 instance ID can't join yet"),
Entry("rejects a lowercase AMI family", func(mng *api.ManagedNodeGroup) {
mng.AMIFamily = "amazonlinux2027"
}, "nodes named by EC2 instance ID can't join yet"),
Entry("rejects InstanceIdNodeName turned on", func(mng *api.ManagedNodeGroup) {
mng.OverrideBootstrapCommand = instanceIDNodeNameConfig(true)
}, "nodes named by EC2 instance ID can't join yet"),
Entry("accepts InstanceIdNodeName turned off", func(mng *api.ManagedNodeGroup) {
mng.OverrideBootstrapCommand = instanceIDNodeNameConfig(false)
}, ""),
)

It("allows an AmazonLinux2027 managed nodegroup with a launch template, which sets its own node config", func() {
mng := api.NewManagedNodeGroup()
mng.AMIFamily = api.NodeImageFamilyAmazonLinux2027
// A launch template nodegroup must not set these fields; the template provides them.
mng.VolumeSize = nil
mng.VolumeType = nil
mng.LaunchTemplate = &api.LaunchTemplate{ID: "lt-1234"}
Expect(api.ValidateManagedNodeGroup(0, mng)).To(Succeed())
})
})
10 changes: 6 additions & 4 deletions pkg/apis/eksctl.io/v1alpha5/assets/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1843,11 +1843,12 @@
},
"amiFamily": {
"type": "string",
"description": "Valid variants are: `\"AmazonLinux2023\"` (default), `\"AmazonLinux2\"`, `\"UbuntuPro2604\"`, `\"Ubuntu2604\"`, `\"UbuntuPro2404\"`, `\"Ubuntu2404\"`, `\"UbuntuPro2204\"`, `\"Ubuntu2204\"`, `\"UbuntuPro2004\"`, `\"Ubuntu2004\"`, `\"Bottlerocket\"`, `\"BottlerocketFips\"`, `\"WindowsServer2019CoreContainer\"`, `\"WindowsServer2019FullContainer\"`, `\"WindowsServer2022CoreContainer\"`, `\"WindowsServer2022FullContainer\"`, `\"WindowsServer2025CoreContainer\"`, `\"WindowsServer2025FullContainer\"`.",
"x-intellij-html-description": "Valid variants are: <code>&quot;AmazonLinux2023&quot;</code> (default), <code>&quot;AmazonLinux2&quot;</code>, <code>&quot;UbuntuPro2604&quot;</code>, <code>&quot;Ubuntu2604&quot;</code>, <code>&quot;UbuntuPro2404&quot;</code>, <code>&quot;Ubuntu2404&quot;</code>, <code>&quot;UbuntuPro2204&quot;</code>, <code>&quot;Ubuntu2204&quot;</code>, <code>&quot;UbuntuPro2004&quot;</code>, <code>&quot;Ubuntu2004&quot;</code>, <code>&quot;Bottlerocket&quot;</code>, <code>&quot;BottlerocketFips&quot;</code>, <code>&quot;WindowsServer2019CoreContainer&quot;</code>, <code>&quot;WindowsServer2019FullContainer&quot;</code>, <code>&quot;WindowsServer2022CoreContainer&quot;</code>, <code>&quot;WindowsServer2022FullContainer&quot;</code>, <code>&quot;WindowsServer2025CoreContainer&quot;</code>, <code>&quot;WindowsServer2025FullContainer&quot;</code>.",
"description": "Valid variants are: `\"AmazonLinux2023\"` (default), `\"AmazonLinux2027\"`, `\"AmazonLinux2\"`, `\"UbuntuPro2604\"`, `\"Ubuntu2604\"`, `\"UbuntuPro2404\"`, `\"Ubuntu2404\"`, `\"UbuntuPro2204\"`, `\"Ubuntu2204\"`, `\"UbuntuPro2004\"`, `\"Ubuntu2004\"`, `\"Bottlerocket\"`, `\"BottlerocketFips\"`, `\"WindowsServer2019CoreContainer\"`, `\"WindowsServer2019FullContainer\"`, `\"WindowsServer2022CoreContainer\"`, `\"WindowsServer2022FullContainer\"`, `\"WindowsServer2025CoreContainer\"`, `\"WindowsServer2025FullContainer\"`.",
"x-intellij-html-description": "Valid variants are: <code>&quot;AmazonLinux2023&quot;</code> (default), <code>&quot;AmazonLinux2027&quot;</code>, <code>&quot;AmazonLinux2&quot;</code>, <code>&quot;UbuntuPro2604&quot;</code>, <code>&quot;Ubuntu2604&quot;</code>, <code>&quot;UbuntuPro2404&quot;</code>, <code>&quot;Ubuntu2404&quot;</code>, <code>&quot;UbuntuPro2204&quot;</code>, <code>&quot;Ubuntu2204&quot;</code>, <code>&quot;UbuntuPro2004&quot;</code>, <code>&quot;Ubuntu2004&quot;</code>, <code>&quot;Bottlerocket&quot;</code>, <code>&quot;BottlerocketFips&quot;</code>, <code>&quot;WindowsServer2019CoreContainer&quot;</code>, <code>&quot;WindowsServer2019FullContainer&quot;</code>, <code>&quot;WindowsServer2022CoreContainer&quot;</code>, <code>&quot;WindowsServer2022FullContainer&quot;</code>, <code>&quot;WindowsServer2025CoreContainer&quot;</code>, <code>&quot;WindowsServer2025FullContainer&quot;</code>.",
"default": "AmazonLinux2023",
"enum": [
"AmazonLinux2023",
"AmazonLinux2027",
"AmazonLinux2",
"UbuntuPro2604",
"Ubuntu2604",
Expand Down Expand Up @@ -2204,11 +2205,12 @@
},
"amiFamily": {
"type": "string",
"description": "Valid variants are: `\"AmazonLinux2023\"` (default), `\"AmazonLinux2\"`, `\"UbuntuPro2604\"`, `\"Ubuntu2604\"`, `\"UbuntuPro2404\"`, `\"Ubuntu2404\"`, `\"UbuntuPro2204\"`, `\"Ubuntu2204\"`, `\"UbuntuPro2004\"`, `\"Ubuntu2004\"`, `\"Bottlerocket\"`, `\"BottlerocketFips\"`, `\"WindowsServer2019CoreContainer\"`, `\"WindowsServer2019FullContainer\"`, `\"WindowsServer2022CoreContainer\"`, `\"WindowsServer2022FullContainer\"`, `\"WindowsServer2025CoreContainer\"`, `\"WindowsServer2025FullContainer\"`.",
"x-intellij-html-description": "Valid variants are: <code>&quot;AmazonLinux2023&quot;</code> (default), <code>&quot;AmazonLinux2&quot;</code>, <code>&quot;UbuntuPro2604&quot;</code>, <code>&quot;Ubuntu2604&quot;</code>, <code>&quot;UbuntuPro2404&quot;</code>, <code>&quot;Ubuntu2404&quot;</code>, <code>&quot;UbuntuPro2204&quot;</code>, <code>&quot;Ubuntu2204&quot;</code>, <code>&quot;UbuntuPro2004&quot;</code>, <code>&quot;Ubuntu2004&quot;</code>, <code>&quot;Bottlerocket&quot;</code>, <code>&quot;BottlerocketFips&quot;</code>, <code>&quot;WindowsServer2019CoreContainer&quot;</code>, <code>&quot;WindowsServer2019FullContainer&quot;</code>, <code>&quot;WindowsServer2022CoreContainer&quot;</code>, <code>&quot;WindowsServer2022FullContainer&quot;</code>, <code>&quot;WindowsServer2025CoreContainer&quot;</code>, <code>&quot;WindowsServer2025FullContainer&quot;</code>.",
"description": "Valid variants are: `\"AmazonLinux2023\"` (default), `\"AmazonLinux2027\"`, `\"AmazonLinux2\"`, `\"UbuntuPro2604\"`, `\"Ubuntu2604\"`, `\"UbuntuPro2404\"`, `\"Ubuntu2404\"`, `\"UbuntuPro2204\"`, `\"Ubuntu2204\"`, `\"UbuntuPro2004\"`, `\"Ubuntu2004\"`, `\"Bottlerocket\"`, `\"BottlerocketFips\"`, `\"WindowsServer2019CoreContainer\"`, `\"WindowsServer2019FullContainer\"`, `\"WindowsServer2022CoreContainer\"`, `\"WindowsServer2022FullContainer\"`, `\"WindowsServer2025CoreContainer\"`, `\"WindowsServer2025FullContainer\"`.",
"x-intellij-html-description": "Valid variants are: <code>&quot;AmazonLinux2023&quot;</code> (default), <code>&quot;AmazonLinux2027&quot;</code>, <code>&quot;AmazonLinux2&quot;</code>, <code>&quot;UbuntuPro2604&quot;</code>, <code>&quot;Ubuntu2604&quot;</code>, <code>&quot;UbuntuPro2404&quot;</code>, <code>&quot;Ubuntu2404&quot;</code>, <code>&quot;UbuntuPro2204&quot;</code>, <code>&quot;Ubuntu2204&quot;</code>, <code>&quot;UbuntuPro2004&quot;</code>, <code>&quot;Ubuntu2004&quot;</code>, <code>&quot;Bottlerocket&quot;</code>, <code>&quot;BottlerocketFips&quot;</code>, <code>&quot;WindowsServer2019CoreContainer&quot;</code>, <code>&quot;WindowsServer2019FullContainer&quot;</code>, <code>&quot;WindowsServer2022CoreContainer&quot;</code>, <code>&quot;WindowsServer2022FullContainer&quot;</code>, <code>&quot;WindowsServer2025CoreContainer&quot;</code>, <code>&quot;WindowsServer2025FullContainer&quot;</code>.",
"default": "AmazonLinux2023",
"enum": [
"AmazonLinux2023",
"AmazonLinux2027",
"AmazonLinux2",
"UbuntuPro2604",
"Ubuntu2604",
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/eksctl.io/v1alpha5/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func setContainerRuntimeDefault(ng *NodeGroup, clusterVersion string) {
return
}

if ng.AMIFamily == NodeImageFamilyAmazonLinux2023 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: If you are using IsNodeadmImage in places other than validation.go, then I don't think it belongs in validation.go. Is there a utilities/library file in this package? If not, defaults.go seems better.

@maitreya526 maitreya526 Nov 19, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept IsNodeadmImage in validation.go next to its sibling Is*Image helpers (IsAmazonLinuxImage, IsBottlerocketImage, IsWindowsImage, ...) for consistency. Some of those, like IsWindowsImage and IsBottlerocketImage, are already used outside validation.go too. Happy to move them together in a follow-up if you'd prefer.

if IsNodeadmImage(ng.AMIFamily) {
ng.ContainerRuntime = aws.String(ContainerRuntimeContainerD)
return
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ const (
// DefaultNodeImageFamily (default)
DefaultNodeImageFamily = NodeImageFamilyAmazonLinux2023
NodeImageFamilyAmazonLinux2023 = "AmazonLinux2023"
NodeImageFamilyAmazonLinux2027 = "AmazonLinux2027"
Comment thread
maitreya526 marked this conversation as resolved.
Resolved
NodeImageFamilyAmazonLinux2 = "AmazonLinux2"
NodeImageFamilyUbuntuPro2604 = "UbuntuPro2604"
NodeImageFamilyUbuntu2604 = "Ubuntu2604"
Expand Down Expand Up @@ -597,6 +598,7 @@ func SupportedNodeVolumeTypes() []string {
func SupportedAMIFamilies() []string {
return []string{
NodeImageFamilyAmazonLinux2023,
NodeImageFamilyAmazonLinux2027,
NodeImageFamilyAmazonLinux2,
NodeImageFamilyUbuntuPro2604,
NodeImageFamilyUbuntu2604,
Expand Down
Loading