Skip to content

Commit

Permalink
feat: al2023 AMI Family
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdeal committed Feb 6, 2024
1 parent 273c79f commit 907d990
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/apis/crds/karpenter.k8s.aws_ec2nodeclasses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ spec:
description: AMIFamily is the AMI family that instances use.
enum:
- AL2
- AL2023
- Bottlerocket
- Ubuntu
- Custom
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/v1beta1/ec2nodeclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/v1beta1/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ var (
}
AMIFamilyBottlerocket = "Bottlerocket"
AMIFamilyAL2 = "AL2"
AMIFamilyAL2023 = "AL2023"
AMIFamilyUbuntu = "Ubuntu"
AMIFamilyWindows2019 = "Windows2019"
AMIFamilyWindows2022 = "Windows2022"
Expand Down
62 changes: 62 additions & 0 deletions pkg/providers/amifamily/al2023.go
Original file line number Diff line number Diff line change
@@ -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")
}
2 changes: 2 additions & 0 deletions pkg/providers/amifamily/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down

0 comments on commit 907d990

Please sign in to comment.