@@ -121,6 +121,8 @@ func (ctx *EksInstanceGroupContext) GetBasicUserData(clusterName, args string, k
121121 nodeLabels = ctx .GetComputedLabels ()
122122 nodeTaints = configuration .GetTaints ()
123123 bootstrapOptions = ctx .GetComputedBootstrapOptions ()
124+ cluster = state .GetCluster ()
125+ clusterIP = ctx .AwsWorker .GetDNSClusterIP (cluster )
124126 )
125127 var maxPods int64
126128
@@ -193,6 +195,59 @@ set -o xtrace
193195/etc/eks/bootstrap.sh {{ .ClusterName }} {{ .Arguments }}
194196set +o xtrace
195197{{range $post := .PostBootstrap}}{{$post}}{{end}}`
198+ case OsFamilyAmazonLinux2023 :
199+ UserDataTemplate = `MIME-Version: 1.0
200+ Content-Type: multipart/mixed; boundary="BOUNDARY"
201+
202+ --BOUNDARY
203+ Content-Type: text/x-shellscript; charset="us-ascii"
204+
205+ #!/bin/bash
206+ echo "IG manager using AL2023 amis"
207+ {{range $pre := .PreBootstrap}}{{$pre}}{{end}}
208+ {{- range .MountOptions}}
209+ mkfs.{{ .FileSystem | ToLower }} {{ .Device }}
210+ mkdir {{ .Mount }}
211+ mount {{ .Device }} {{ .Mount }}
212+ mount
213+ {{- if .Persistance}}
214+ echo "{{ .Device}} {{ .Mount }} {{ .FileSystem | ToLower }} defaults 0 2" >> /etc/fstab
215+ {{- end}}
216+ {{- end}}
217+ if [[ $(type -P $(which aws)) ]] && [[ $(type -P $(which jq)) ]] ; then
218+ TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
219+ INSTANCE_ID=$(curl url -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/instance-id)
220+ REGION=$(curl url -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/placement/region)
221+ LIFECYCLE=$(curl url -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/autoscaling/target-lifecycle-state)
222+ if [[ $LIFECYCLE == *"Warmed"* ]]; then
223+ rm /var/lib/cloud/instances/$INSTANCE_ID/sem/config_scripts_user
224+ exit 0
225+ fi
226+ fi
227+ --BOUNDARY
228+ Content-Type: application/node.eks.aws
229+
230+ {{ .NodeConfigYaml }}
231+
232+ --BOUNDARY
233+ Content-Type: application/node.eks.aws
234+
235+ ---
236+ apiVersion: node.eks.aws/v1alpha1
237+ kind: NodeConfig
238+ spec:
239+ kubelet:
240+ flags:
241+ - --node-labels={{ $first := true }}{{ range $key, $value := .NodeLabels }}{{if not $first}},{{end}}{{ $key }}={{ $value }}{{ $first = false}}{{- end}}
242+ - --register-with-taints={{ $first := true }}{{- range .NodeTaints}}{{if not $first}},{{end}}{{ .Key }}={{ .Value }}:{{ .Effect }}{{ $first = false}}{{- end}}
243+
244+ --BOUNDARY
245+ Content-Type: text/x-shellscript; charset="us-ascii"
246+
247+ #!/bin/bash
248+ set +o xtrace
249+ {{range $post := .PostBootstrap}}{{$post}}{{end}}
250+ --BOUNDARY--`
196251 }
197252
198253 data := EKSUserData {
@@ -206,7 +261,9 @@ set +o xtrace
206261 Arguments : args ,
207262 PreBootstrap : payload .PreBootstrap ,
208263 PostBootstrap : payload .PostBootstrap ,
264+ NodeConfigYaml : payload .NodeConfigYaml ,
209265 MountOptions : mounts ,
266+ ClusterIP : clusterIP ,
210267 }
211268 out := & bytes.Buffer {}
212269 tmpl := template .New ("userData" ).Funcs (template.FuncMap {
@@ -246,6 +303,12 @@ func (ctx *EksInstanceGroupContext) GetUserDataStages() UserDataPayload {
246303 ctx .Log .Error (err , "failed to decode base64 stage data" , "stage" , stage .Stage , "data" , stage .Data )
247304 }
248305 payload .PostBootstrap = append (payload .PostBootstrap , data )
306+ case strings .EqualFold (stage .Stage , v1alpha1 .NodeConfigYamlStage ):
307+ data , err := common .GetDecodedString (stage .Data )
308+ if err != nil {
309+ ctx .Log .Error (err , "failed to decode base64 stage data" , "stage" , stage .Stage , "data" , stage .Data )
310+ }
311+ payload .NodeConfigYaml = data
249312 default :
250313 ctx .Log .Info ("invalid userdata stage will not be rendered" , "stage" , stage .Stage , "data" , stage .Data )
251314 }
@@ -562,7 +625,7 @@ func (ctx *EksInstanceGroupContext) GetBootstrapArgs() string {
562625 sb .WriteString (fmt .Sprintf ("-ContainerRuntime %v " , bootstrapOptions .ContainerRuntime ))
563626 }
564627 sb .WriteString (fmt .Sprintf ("-KubeletExtraArgs '%v'" , ctx .GetKubeletExtraArgs ()))
565- case OsFamilyAmazonLinux2 :
628+ case OsFamilyAmazonLinux2 , OsFamilyAmazonLinux2023 :
566629 if bootstrapOptions != nil && bootstrapOptions .MaxPods > 0 {
567630 sb .WriteString ("--use-max-pods false " )
568631 }
@@ -1225,10 +1288,13 @@ func (ctx *EksInstanceGroupContext) GetEksLatestAmi() (string, error) {
12251288 )
12261289 clusterVersion := state .GetClusterVersion ()
12271290 annotations := instanceGroup .GetAnnotations ()
1291+ overrideAmazonLinuxFamily := strings .Trim (ctx .AmazonLinuxOsFamily , "\" " )
12281292
12291293 var OSFamily string
12301294 if kubeprovider .HasAnnotation (annotations , OsFamilyAnnotation ) {
12311295 OSFamily = annotations [OsFamilyAnnotation ]
1296+ } else if overrideAmazonLinuxFamily != "" {
1297+ OSFamily = overrideAmazonLinuxFamily
12321298 } else {
12331299 OSFamily = OsFamilyAmazonLinux2
12341300 }
0 commit comments