Skip to content

Commit a3d98fd

Browse files
aciba90TiberiuGC
authored andcommitted
Add support for Ubuntu Pro 22.04 based EKS images (eksctl-io#7711)
* feat: Add support for Ubuntu Pro 22.04 based EKS images * update schema.json * test: Add nodegroup with Ubuntu Pro 22.04 * fix integration test --------- Co-authored-by: Tibi <[email protected]>
1 parent 811fcc2 commit a3d98fd

15 files changed

Lines changed: 139 additions & 25 deletions

File tree

integration/tests/custom_ami/custom_ami_test.go

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ func TestOverrideBootstrap(t *testing.T) {
3737
}
3838

3939
var (
40-
customAMIAL2 string
41-
customAMIAL2023 string
42-
customAMIBottlerocket string
40+
customAMIAL2 string
41+
customAMIAL2023 string
42+
customAMIBottlerocket string
43+
customAMIUbuntuPro2204 string
4344
)
4445

4546
var _ = BeforeSuite(func() {
@@ -70,6 +71,14 @@ var _ = BeforeSuite(func() {
7071
Expect(err).NotTo(HaveOccurred())
7172
customAMIBottlerocket = *output.Parameter.Value
7273

74+
// retrieve Ubuntu Pro 22.04 AMI
75+
input = &awsssm.GetParameterInput{
76+
Name: aws.String(fmt.Sprintf("/aws/service/canonical/ubuntu/eks-pro/22.04/%s/stable/current/amd64/hvm/ebs-gp2/ami-id", params.Version)),
77+
}
78+
output, err = ssm.GetParameter(context.Background(), input)
79+
Expect(err).NotTo(HaveOccurred())
80+
customAMIUbuntuPro2204 = *output.Parameter.Value
81+
7382
cmd := params.EksctlCreateCmd.WithArgs(
7483
"cluster",
7584
"--verbose", "4",
@@ -147,6 +156,28 @@ var _ = Describe("(Integration) [Test Custom AMI]", func() {
147156
})
148157

149158
})
159+
160+
Context("ubuntu-pro-2204 un-managed nodegroups", func() {
161+
162+
It("can create a working nodegroup which can join the cluster", func() {
163+
By(fmt.Sprintf("using the following EKS optimised AMI: %s", customAMIUbuntuPro2204))
164+
content, err := os.ReadFile(filepath.Join("testdata/ubuntu-pro-2204.yaml"))
165+
Expect(err).NotTo(HaveOccurred())
166+
content = bytes.ReplaceAll(content, []byte("<generated>"), []byte(params.ClusterName))
167+
content = bytes.ReplaceAll(content, []byte("<generated-region>"), []byte(params.Region))
168+
content = bytes.ReplaceAll(content, []byte("<generated-ami>"), []byte(customAMIUbuntuPro2204))
169+
cmd := params.EksctlCreateCmd.
170+
WithArgs(
171+
"nodegroup",
172+
"--config-file", "-",
173+
"--verbose", "4",
174+
).
175+
WithoutArg("--region", params.Region).
176+
WithStdin(bytes.NewReader(content))
177+
Expect(cmd).To(RunSuccessfully())
178+
})
179+
180+
})
150181
})
151182

152183
var _ = AfterSuite(func() {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: eksctl.io/v1alpha5
2+
kind: ClusterConfig
3+
4+
# name is generated
5+
metadata:
6+
name: <generated>
7+
region: <generated-region>
8+
9+
nodeGroups:
10+
- name: unm-ubuntu-pro-2204
11+
ami: <generated-ami>
12+
amiFamily: UbuntuPro2204
13+
desiredCapacity: 1
14+
overrideBootstrapCommand: |
15+
#!/bin/bash
16+
source /var/lib/cloud/scripts/eksctl/bootstrap.helper.sh
17+
/etc/eks/bootstrap.sh <generated> --kubelet-extra-args "--node-labels=${NODE_LABELS}"

pkg/ami/auto_resolver.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ func MakeImageSearchPatterns(version string) map[string]map[int]string {
3232
ImageClassGPU: fmt.Sprintf("amazon-eks-gpu-node-%s-*", version),
3333
ImageClassARM: fmt.Sprintf("amazon-eks-arm64-node-%s-*", version),
3434
},
35+
api.NodeImageFamilyUbuntuPro2204: {
36+
ImageClassGeneral: fmt.Sprintf("ubuntu-eks-pro/k8s_%s/images/*22.04-amd64*", version),
37+
ImageClassARM: fmt.Sprintf("ubuntu-eks-pro/k8s_%s/images/*22.04-arm64*", version),
38+
},
3539
api.NodeImageFamilyUbuntu2204: {
3640
ImageClassGeneral: fmt.Sprintf("ubuntu-eks/k8s_%s/images/*22.04-amd64*", version),
3741
ImageClassARM: fmt.Sprintf("ubuntu-eks/k8s_%s/images/*22.04-arm64*", version),
@@ -61,7 +65,7 @@ func MakeImageSearchPatterns(version string) map[string]map[int]string {
6165
// OwnerAccountID returns the AWS account ID that owns worker AMI.
6266
func OwnerAccountID(imageFamily, region string) (string, error) {
6367
switch imageFamily {
64-
case api.NodeImageFamilyUbuntu2204, api.NodeImageFamilyUbuntu2004, api.NodeImageFamilyUbuntu1804:
68+
case api.NodeImageFamilyUbuntuPro2204, api.NodeImageFamilyUbuntu2204, api.NodeImageFamilyUbuntu2004, api.NodeImageFamilyUbuntu1804:
6569
return ownerIDUbuntuFamily, nil
6670
case api.NodeImageFamilyAmazonLinux2023, api.NodeImageFamilyAmazonLinux2:
6771
return api.EKSResourceAccountID(region), nil

pkg/ami/auto_resolver_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ var _ = Describe("AMI Auto Resolution", func() {
6767
Expect(ownerAccount).To(BeEquivalentTo("099720109477"))
6868
Expect(err).NotTo(HaveOccurred())
6969
})
70+
It("should return the Ubuntu Account ID for Ubuntu images", func() {
71+
ownerAccount, err := OwnerAccountID(api.NodeImageFamilyUbuntuPro2204, region)
72+
Expect(ownerAccount).To(BeEquivalentTo("099720109477"))
73+
Expect(err).NotTo(HaveOccurred())
74+
})
7075

7176
It("should return the Windows Account ID for Windows Server images", func() {
7277
ownerAccount, err := OwnerAccountID(api.NodeImageFamilyWindowsServer2022CoreContainer, region)

pkg/ami/ssm_resolver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func MakeSSMParameterName(version, instanceType, imageFamily string) (string, er
7575
return fmt.Sprintf("/aws/service/ami-windows-latest/Windows_Server-2022-English-%s-EKS_Optimized-%s/%s", windowsAmiType(imageFamily), version, fieldName), nil
7676
case api.NodeImageFamilyBottlerocket:
7777
return fmt.Sprintf("/aws/service/bottlerocket/aws-k8s-%s/%s/latest/%s", imageType(imageFamily, instanceType, version), instanceEC2ArchName(instanceType), fieldName), nil
78-
case api.NodeImageFamilyUbuntu2204, api.NodeImageFamilyUbuntu2004, api.NodeImageFamilyUbuntu1804:
78+
case api.NodeImageFamilyUbuntuPro2204, api.NodeImageFamilyUbuntu2204, api.NodeImageFamilyUbuntu2004, api.NodeImageFamilyUbuntu1804:
7979
// FIXME: SSM lookup for Ubuntu EKS images is supported nowadays
8080
return "", &UnsupportedQueryError{msg: fmt.Sprintf("SSM Parameter lookups for %s AMIs is not supported yet", imageFamily)}
8181
default:

pkg/apis/eksctl.io/v1alpha5/assets/schema.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,12 +1279,13 @@
12791279
},
12801280
"amiFamily": {
12811281
"type": "string",
1282-
"description": "Valid variants are: `\"AmazonLinux2\"` (default), `\"AmazonLinux2023\"`, `\"Ubuntu2204\"`, `\"Ubuntu2004\"`, `\"Ubuntu1804\"`, `\"Bottlerocket\"`, `\"WindowsServer2019CoreContainer\"`, `\"WindowsServer2019FullContainer\"`, `\"WindowsServer2022CoreContainer\"`, `\"WindowsServer2022FullContainer\"`.",
1283-
"x-intellij-html-description": "Valid variants are: <code>&quot;AmazonLinux2&quot;</code> (default), <code>&quot;AmazonLinux2023&quot;</code>, <code>&quot;Ubuntu2204&quot;</code>, <code>&quot;Ubuntu2004&quot;</code>, <code>&quot;Ubuntu1804&quot;</code>, <code>&quot;Bottlerocket&quot;</code>, <code>&quot;WindowsServer2019CoreContainer&quot;</code>, <code>&quot;WindowsServer2019FullContainer&quot;</code>, <code>&quot;WindowsServer2022CoreContainer&quot;</code>, <code>&quot;WindowsServer2022FullContainer&quot;</code>.",
1282+
"description": "Valid variants are: `\"AmazonLinux2\"` (default), `\"AmazonLinux2023\"`, `\"UbuntuPro2204\"`, `\"Ubuntu2204\"`, `\"Ubuntu2004\"`, `\"Ubuntu1804\"`, `\"Bottlerocket\"`, `\"WindowsServer2019CoreContainer\"`, `\"WindowsServer2019FullContainer\"`, `\"WindowsServer2022CoreContainer\"`, `\"WindowsServer2022FullContainer\"`.",
1283+
"x-intellij-html-description": "Valid variants are: <code>&quot;AmazonLinux2&quot;</code> (default), <code>&quot;AmazonLinux2023&quot;</code>, <code>&quot;UbuntuPro2204&quot;</code>, <code>&quot;Ubuntu2204&quot;</code>, <code>&quot;Ubuntu2004&quot;</code>, <code>&quot;Ubuntu1804&quot;</code>, <code>&quot;Bottlerocket&quot;</code>, <code>&quot;WindowsServer2019CoreContainer&quot;</code>, <code>&quot;WindowsServer2019FullContainer&quot;</code>, <code>&quot;WindowsServer2022CoreContainer&quot;</code>, <code>&quot;WindowsServer2022FullContainer&quot;</code>.",
12841284
"default": "AmazonLinux2",
12851285
"enum": [
12861286
"AmazonLinux2",
12871287
"AmazonLinux2023",
1288+
"UbuntuPro2204",
12881289
"Ubuntu2204",
12891290
"Ubuntu2004",
12901291
"Ubuntu1804",
@@ -1613,12 +1614,13 @@
16131614
},
16141615
"amiFamily": {
16151616
"type": "string",
1616-
"description": "Valid variants are: `\"AmazonLinux2\"` (default), `\"AmazonLinux2023\"`, `\"Ubuntu2204\"`, `\"Ubuntu2004\"`, `\"Ubuntu1804\"`, `\"Bottlerocket\"`, `\"WindowsServer2019CoreContainer\"`, `\"WindowsServer2019FullContainer\"`, `\"WindowsServer2022CoreContainer\"`, `\"WindowsServer2022FullContainer\"`.",
1617-
"x-intellij-html-description": "Valid variants are: <code>&quot;AmazonLinux2&quot;</code> (default), <code>&quot;AmazonLinux2023&quot;</code>, <code>&quot;Ubuntu2204&quot;</code>, <code>&quot;Ubuntu2004&quot;</code>, <code>&quot;Ubuntu1804&quot;</code>, <code>&quot;Bottlerocket&quot;</code>, <code>&quot;WindowsServer2019CoreContainer&quot;</code>, <code>&quot;WindowsServer2019FullContainer&quot;</code>, <code>&quot;WindowsServer2022CoreContainer&quot;</code>, <code>&quot;WindowsServer2022FullContainer&quot;</code>.",
1617+
"description": "Valid variants are: `\"AmazonLinux2\"` (default), `\"AmazonLinux2023\"`, `\"UbuntuPro2204\"`, `\"Ubuntu2204\"`, `\"Ubuntu2004\"`, `\"Ubuntu1804\"`, `\"Bottlerocket\"`, `\"WindowsServer2019CoreContainer\"`, `\"WindowsServer2019FullContainer\"`, `\"WindowsServer2022CoreContainer\"`, `\"WindowsServer2022FullContainer\"`.",
1618+
"x-intellij-html-description": "Valid variants are: <code>&quot;AmazonLinux2&quot;</code> (default), <code>&quot;AmazonLinux2023&quot;</code>, <code>&quot;UbuntuPro2204&quot;</code>, <code>&quot;Ubuntu2204&quot;</code>, <code>&quot;Ubuntu2004&quot;</code>, <code>&quot;Ubuntu1804&quot;</code>, <code>&quot;Bottlerocket&quot;</code>, <code>&quot;WindowsServer2019CoreContainer&quot;</code>, <code>&quot;WindowsServer2019FullContainer&quot;</code>, <code>&quot;WindowsServer2022CoreContainer&quot;</code>, <code>&quot;WindowsServer2022FullContainer&quot;</code>.",
16181619
"default": "AmazonLinux2",
16191620
"enum": [
16201621
"AmazonLinux2",
16211622
"AmazonLinux2023",
1623+
"UbuntuPro2204",
16221624
"Ubuntu2204",
16231625
"Ubuntu2004",
16241626
"Ubuntu1804",

pkg/apis/eksctl.io/v1alpha5/gpu_validation_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,22 @@ var _ = Describe("GPU instance support", func() {
6565
gpuInstanceType: "g5.12xlarge",
6666
amiFamily: api.NodeImageFamilyAmazonLinux2,
6767
}),
68+
Entry("Ubuntu1804", gpuInstanceEntry{
69+
amiFamily: api.NodeImageFamilyUbuntu2004,
70+
gpuInstanceType: "g4dn.xlarge",
71+
}),
6872
Entry("Ubuntu2004", gpuInstanceEntry{
6973
amiFamily: api.NodeImageFamilyUbuntu2004,
7074
gpuInstanceType: "g4dn.xlarge",
7175
}),
76+
Entry("Ubuntu2204", gpuInstanceEntry{
77+
amiFamily: api.NodeImageFamilyUbuntu2004,
78+
gpuInstanceType: "g4dn.xlarge",
79+
}),
80+
Entry("UbuntuPro2204", gpuInstanceEntry{
81+
amiFamily: api.NodeImageFamilyUbuntu2004,
82+
gpuInstanceType: "g4dn.xlarge",
83+
}),
7284
Entry("Bottlerocket", gpuInstanceEntry{
7385
amiFamily: api.NodeImageFamilyBottlerocket,
7486
gpuInstanceType: "inf1.xlarge",

pkg/apis/eksctl.io/v1alpha5/outposts_validation_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ var _ = Describe("Outposts validation", func() {
209209
Entry("Ubuntu1804", api.NodeImageFamilyUbuntu1804, true),
210210
Entry("Ubuntu2004", api.NodeImageFamilyUbuntu2004, true),
211211
Entry("Ubuntu2204", api.NodeImageFamilyUbuntu2204, true),
212+
Entry("UbuntuPro2204", api.NodeImageFamilyUbuntuPro2204, true),
212213
Entry("Windows2019Core", api.NodeImageFamilyWindowsServer2019CoreContainer, true),
213214
Entry("Windows2019Full", api.NodeImageFamilyWindowsServer2019FullContainer, true),
214215
Entry("Windows2022Core", api.NodeImageFamilyWindowsServer2022CoreContainer, true),

pkg/apis/eksctl.io/v1alpha5/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ const (
225225
DefaultNodeImageFamily = NodeImageFamilyAmazonLinux2
226226
NodeImageFamilyAmazonLinux2023 = "AmazonLinux2023"
227227
NodeImageFamilyAmazonLinux2 = "AmazonLinux2"
228+
NodeImageFamilyUbuntuPro2204 = "UbuntuPro2204"
228229
NodeImageFamilyUbuntu2204 = "Ubuntu2204"
229230
NodeImageFamilyUbuntu2004 = "Ubuntu2004"
230231
NodeImageFamilyUbuntu1804 = "Ubuntu1804"
@@ -631,6 +632,7 @@ func SupportedAMIFamilies() []string {
631632
return []string{
632633
NodeImageFamilyAmazonLinux2023,
633634
NodeImageFamilyAmazonLinux2,
635+
NodeImageFamilyUbuntuPro2204,
634636
NodeImageFamilyUbuntu2204,
635637
NodeImageFamilyUbuntu2004,
636638
NodeImageFamilyUbuntu1804,

pkg/apis/eksctl.io/v1alpha5/validation.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,8 @@ func IsAmazonLinuxImage(imageFamily string) bool {
15091509

15101510
func IsUbuntuImage(imageFamily string) bool {
15111511
switch imageFamily {
1512-
case NodeImageFamilyUbuntu2204,
1512+
case NodeImageFamilyUbuntuPro2204,
1513+
NodeImageFamilyUbuntu2204,
15131514
NodeImageFamilyUbuntu2004,
15141515
NodeImageFamilyUbuntu1804:
15151516
return true

0 commit comments

Comments
 (0)