diff --git a/pkg/apis/crds/karpenter.k8s.aws_ec2nodeclasses.yaml b/pkg/apis/crds/karpenter.k8s.aws_ec2nodeclasses.yaml index af4acba6004c..456eb9b47a8d 100644 --- a/pkg/apis/crds/karpenter.k8s.aws_ec2nodeclasses.yaml +++ b/pkg/apis/crds/karpenter.k8s.aws_ec2nodeclasses.yaml @@ -50,6 +50,7 @@ spec: description: AMIFamily is the AMI family that instances use. enum: - AL2 + - AL2023 - Bottlerocket - Ubuntu - Custom diff --git a/pkg/apis/v1beta1/ec2nodeclass.go b/pkg/apis/v1beta1/ec2nodeclass.go index 17b607278581..baa84b0317d9 100644 --- a/pkg/apis/v1beta1/ec2nodeclass.go +++ b/pkg/apis/v1beta1/ec2nodeclass.go @@ -48,7 +48,7 @@ type EC2NodeClassSpec struct { // +optional AMISelectorTerms []AMISelectorTerm `json:"amiSelectorTerms,omitempty" hash:"ignore"` // AMIFamily is the AMI family that instances use. - // +kubebuilder:validation:Enum:={AL2,Bottlerocket,Ubuntu,Custom,Windows2019,Windows2022} + // +kubebuilder:validation:Enum:={AL2,AL2023,Bottlerocket,Ubuntu,Custom,Windows2019,Windows2022} // +required AMIFamily *string `json:"amiFamily"` // UserData to be applied to the provisioned nodes. diff --git a/pkg/apis/v1beta1/labels.go b/pkg/apis/v1beta1/labels.go index 1b86eb70726f..a938aa2d48cf 100644 --- a/pkg/apis/v1beta1/labels.go +++ b/pkg/apis/v1beta1/labels.go @@ -73,6 +73,7 @@ var ( } AMIFamilyBottlerocket = "Bottlerocket" AMIFamilyAL2 = "AL2" + AMIFamilyAL2023 = "AL2023" AMIFamilyUbuntu = "Ubuntu" AMIFamilyWindows2019 = "Windows2019" AMIFamilyWindows2022 = "Windows2022" diff --git a/pkg/providers/amifamily/al2023.go b/pkg/providers/amifamily/al2023.go new file mode 100644 index 000000000000..e9b4658b0fe3 --- /dev/null +++ b/pkg/providers/amifamily/al2023.go @@ -0,0 +1,62 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package amifamily + +import ( + "github.com/samber/lo" + v1 "k8s.io/api/core/v1" + corev1beta1 "sigs.k8s.io/karpenter/pkg/apis/v1beta1" + "sigs.k8s.io/karpenter/pkg/cloudprovider" + + "github.com/aws/karpenter-provider-aws/pkg/apis/v1beta1" + "github.com/aws/karpenter-provider-aws/pkg/providers/amifamily/bootstrap" +) + +type AL2023 struct { + DefaultFamily + *Options +} + +func (a AL2023) DefaultAMIs(version string) []DefaultAMIOutput { + // TODO: SSM parameters not yet available + return []DefaultAMIOutput{} +} + +func (a AL2023) UserData(kubeletConfig *corev1beta1.KubeletConfiguration, taints []v1.Taint, labels map[string]string, caBundle *string, _ []*cloudprovider.InstanceType, customUserData *string, _ *v1beta1.InstanceStorePolicy) bootstrap.Bootstrapper { + return bootstrap.Nodeadm{ + Options: bootstrap.Options{ + ClusterName: a.Options.ClusterName, + ClusterEndpoint: a.Options.ClusterEndpoint, + ClusterCIDR: a.Options.ClusterCIDR, + KubeletConfig: kubeletConfig, + Taints: taints, + Labels: labels, + CABundle: caBundle, + CustomUserData: customUserData, + }, + } +} + +// DefaultBlockDeviceMappings returns the default block device mappings for the AMI Family +func (a AL2023) DefaultBlockDeviceMappings() []*v1beta1.BlockDeviceMapping { + return []*v1beta1.BlockDeviceMapping{{ + DeviceName: a.EphemeralBlockDevice(), + EBS: &DefaultEBS, + }} +} + +func (a AL2023) EphemeralBlockDevice() *string { + return lo.ToPtr("/dev/xvda") +} diff --git a/pkg/providers/amifamily/resolver.go b/pkg/providers/amifamily/resolver.go index e5073ffadfd0..2c6fbbccc676 100644 --- a/pkg/providers/amifamily/resolver.go +++ b/pkg/providers/amifamily/resolver.go @@ -176,6 +176,8 @@ func GetAMIFamily(amiFamily *string, options *Options) AMIFamily { return &Windows{Options: options, Version: v1beta1.Windows2022, Build: v1beta1.Windows2022Build} case v1beta1.AMIFamilyCustom: return &Custom{Options: options} + case v1beta1.AMIFamilyAL2023: + return &AL2023{Options: options} default: return &AL2{Options: options} }