I want to provide custom user data when I use custom scripts, self-managed nodes, or custom launch templates in Amazon Linux 2023 AMIs in Amazon Elastic Kubernetes Service (Amazon EKS).
Short description
Amazon Linux 2023 uses the nodeadm node initialization process that uses a YAML configuration schema. For more information, see the Before upgrading to AL2023 section in the Amazon EKS-optimized Amazon Linux 2023 AMIs now available.
Resolution
Add the minimum required parameters to user data in the following format:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="//"
--//
Content-Type: application/node.eks.aws
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
cluster:
apiServerEndpoint: https://example.com
certificateAuthority: Y2VydGlmaWNhdGVBdXRob3JpdHk=
cidr: 10.100.0.0/16
name: my-cluster
--//--
Modify the kubelet or containerd components in the following format:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="
--==MYBOUNDARY==
Content-Type: application/node.eks.aws
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
cluster:
name: my-cluster
apiServerEndpoint: https://example.com
certificateAuthority: Y2VydGlmaWNhdGVBdXRob3JpdHk=
cidr: 10.100.0.0/16
kubelet:
config:
maxPods: 17
clusterDNS:
- 10.100.0.10
flags:
- "--node-labels=eks.amazonaws.com/nodegroup-image=ami-0cc04929616d2c6ba,eks.amazonaws.com/capacityType=ON_DEMAND,eks.amazonaws.com/nodegroup=al23"
containerd: {}
instance:
localStorage: {}
--==MYBOUNDARY==--
Pass custom scripts or commands in the following format:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="//"
--//
Content-Type: application/node.eks.aws
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
cluster:
name: my-cluster
apiServerEndpoint: https://example.com
certificateAuthority: Y2VydGlmaWNhdGVBdXRob3JpdHk=
cidr: 10.100.0.0/16
--//
Content-Type: text/x-shellscript; charset="us-ascii"
#!/bin/bash
echo "Hello AL2023!"
--//
Related information
Amazon EKS AMI API reference