Examples
Merging multiple configuration objects
When using the IMDS configuration source (--config-source=imds://user-data),
nodeadm will merge any configuration objects it discovers before configuring your node.
With the following user data:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="BOUNDARY"
--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
--BOUNDARY
Content-Type: application/node.eks.aws
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
kubelet:
config:
shutdownGracePeriod: 30s
featureGates:
DisableKubeletCloudCredentialProviders: true
--BOUNDARY--
The configuration nodeadm will use is:
---
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:
shutdownGracePeriod: 30s
featureGates:
DisableKubeletCloudCredentialProviders: true
The configuration objects will be merged in the order they appear in the MIME multi-part document, meaning the value in the lattermost configuration object will take precedence.
Overriding configuration with drop-in files
On EKS AMIs, nodeadm-run.service is invoked with two configuration sources: user data and /etc/eks/nodeadm.d/.
Any NodeConfig objects placed in /etc/eks/nodeadm.d/ (as files with a .yaml, .yml, or .json extension) will be merged on top of the configuration provided via EC2 user data. Because drop-in files are evaluated after user data in the config source chain, values set in /etc/eks/nodeadm.d/ take precedence over values set in user data.
This is useful when you want to override a subset of the configuration for a specific instance or AMI (for example, from cloud-init or when building a custom AMI) without having to regenerate the full user data document. The directory is created for you during AMI build, so you can drop files into it directly.
⚠️ Note: A drop-in file only needs to contain the fields you want to override — it does not need to be a complete NodeConfig. At least one source in user data must provide the required cluster fields, so drop-in files cannot be used on their own.
For example, given the following user data:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="BOUNDARY"
--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
containerd:
baseRuntimeSpec:
process:
rlimits:
- type: RLIMIT_NOFILE
soft: 1024
hard: 1024
--BOUNDARY--
And the following drop-in file at /etc/eks/nodeadm.d/10-rlimits.yaml:
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
containerd:
baseRuntimeSpec:
process:
rlimits:
- type: RLIMIT_NOFILE
soft: 65536
hard: 65536
The resulting configuration used by nodeadm will contain the RLIMIT_NOFILE values from the drop-in file (65536), overriding the values set in user data.
Configuring kubelet
Additional kubelet configuration can be supplied in your NodeConfig. spec.kubelet.config is merged into the default KubeletConfiguration, and spec.kubelet.flags are appended to the default command-line arguments. See the API reference for details.
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
cluster: ...
kubelet:
config:
shutdownGracePeriod: 30s
flags:
- --node-labels=example.com/role=worker
This can be supplied in user data alongside the rest of your NodeConfig, or as a drop-in file under /etc/eks/nodeadm.d/.
⚠️ Note: Your user data should not run nodeadm init or start or restart kubelet (for example, with systemctl restart kubelet). On EKS AMIs, nodeadm-run.service runs after your user data, sets up the node (for example, by mounting local instance storage), and then starts kubelet. Starting kubelet from user data makes it run before that setup is complete.
Using instance ID as node name
When the InstanceIdNodeName feature gate is enabled, nodeadm will use the EC2 instance's ID (e.g. i-abcdefg1234) as the name of the Node object created by kubelet, instead of the EC2 instance's private DNS Name (e.g. ip-192-168-1-1.ec2.internal).
There are several benefits of doing this:
1. Your Node names are more meaningful in, for example, the output of kubectl get nodes.
2. The Node name, which is in the critical path of kubelet authentication, is non-volatile. While the private DNS name of an instance may change, its ID cannot.
3. The ec2:DescribeInstances permission can be removed from your node role's IAM policy; this is no longer necessary.
To enable this feature, you will need to:
- Create a new worker node IAM role
- ⚠️ Note: you should create a new role when migrating an existing cluster to avoid authentication failures on existing nodes.
- Configure authorization for the role using username
system:node:{{SessionName}}, for example by creating an access entry of typeEC2for the new role:- ⚠️ Note: you can still use the legacy
aws-authConfigMap to grant access, but services like EKS Managed Node Groups will require the use of access entries.
- ⚠️ Note: you can still use the legacy
aws eks create-access-entry \
--cluster-name $CLUSTER_NAME \
--principal-arn $ROLE_CREATED_ABOVE \
--type EC2
- Enable the feature gate in your user data:
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
featureGates:
InstanceIdNodeName: true
Enabling fast image pull (experimental)
When the FastImagePull feature gate is enabled, nodeadm will configure the container runtime to pull and unpack container images in parallel.
This has the benefit of potentially decreasing image pull time, at the cost of increased CPU, memory and EBS usage during image pull.
⚠️ Note: This flag will be ignored on instance sizes below a certain vCPU and memory threshold.
To enable this feature:
- Ensure your instance type is a larger instance type. Currently we recommend a 2xlarge instance or larger, but that value may change.
- Make sure your workloads can tolerate the increased CPU and memory usage during image pull. This makes the most sense when you need to pull a very large container image early in a node's lifecycle, before other workloads are running.
- Ensure you've configured additional EBS throughput for your instance root volume. We recommend at least 600MiB/s throughput. Below that value, you may see longer image pull times with this flag. Higher values up to 1000MiB/s and 16k IOPs may result in better performance.
- Enable the feature gate in your user data:
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
featureGates:
FastImagePull: true
Managing secondary ENIs with ENI tags
When the ENITags feature gate is enabled, nodeadm configures secondary ENIs tagged alpha.node.eks.aws/system_managed=true via systemd-networkd. ENIs without that tag, or with any other value, are left to the CNI.
⚠️ Note: This feature can significantly increase the number of ec2:DescribeNetworkInterfaces calls, and may not be suitable for all environments.
To enable this feature:
- Grant
ec2:DescribeNetworkInterfacesto the node instance role. If the tags can't be read, for example because this permission is missing, the ENI is left to the CNI. - Configure the CNIs running on the node not to manage these ENIs. For example, the VPC CNI skips ENIs tagged
node.k8s.amazonaws.com/no_manage=true. - Tag the ENI when you create it, for example with
TagSpecificationsinCreateNetworkInterface. Only the tags visible when the ENI is attached are taken into account, and tags added later may not be visible yet due to EC2's eventual consistency. - Enable the feature gate in your user data:
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
featureGates:
ENITags: true
⚠️ Note: Changing the tags of an ENI and attaching it again to the same instance is not supported.
Configuring containerd
Additional containerd configuration can be supplied in your NodeConfig. The values in your inline TOML document will overwrite any default value set by nodeadm.
The following configuration object:
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
cluster: ...
containerd:
config: |
[plugins."io.containerd.grpc.v1.cri".containerd]
discard_unpacked_layers = false
Can be used to disable deletion of unpacked image layers in the containerd content store.
Modifying container RLIMITs
If your workload requires different RLIMITs than the defaults, you can use the baseRuntimeSpec option of containerd to override them:
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
cluster: ...
containerd:
baseRuntimeSpec:
process:
rlimits:
- type: RLIMIT_NOFILE
soft: 1024
hard: 1024
This can be supplied in user data alongside the rest of your NodeConfig, or as a drop-in file under /etc/eks/nodeadm.d/.
Configuring the NVIDIA container runtime
On AMIs with the NVIDIA container runtime installed, additional NVIDIA Container Toolkit configuration can be supplied in your NodeConfig. The values in your inline TOML document are merged into /etc/nvidia-container-runtime/config.toml, overwriting the values already in that file. nodeadm ignores this setting, with a warning, on AMIs without the NVIDIA container runtime.
The following configuration object:
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
cluster: ...
nvidiaContainerRuntime:
config: |
accept-nvidia-visible-devices-as-volume-mounts = true
accept-nvidia-visible-devices-envvar-when-unprivileged = false
Can be used with device plugins that set deviceListStrategy to volume-mounts.
Defining a Max Pods Expression
Under certain circumstances, the desired max pods value for a given node or instance type can diverge from the
default calculation. Since the use of a static NodeConfig is encouraged as the input source for nodeadm, nodeadm
accepts a maxPodsExpression to determine the final maxPods value passed to kubelet. This string is interpreted
as a CEL expression with the following variables set in the environment:
default_enis- the maximum number of network interfaces attachable on the default network cardips_per_eni- the maximum number of IPv4 addresses attachable to a single interfacemax_pods- the standardmaxPodsfor the current instance type. This can be equivalently expressed in CEL as(default_enis * (ips_per_eni - 1)) + 2vcpus- the number of default vCPUs for the instance typephysical_memory_mib- the total physical memory of the instance type, in MiB (this is the hardware total; the memory perceivable by the OS will be somewhat lower)
⚠️ Note: These values will vary between instance types and may require ec2:DescribeInstanceTypes API calls. Expressions should be tested to confirm desired outputs before final use in the intended environment.
⚠️ Note: vcpus and physical_memory_mib are 0 for a small set of older instance types that ec2:DescribeInstanceTypes no longer returns and for which AWS publishes no current specifications (cr1.8xlarge, hs1.8xlarge, c5a.metal, c5ad.metal, bmn-sf1.metal). Expressions that key on these variables should guard against 0 if they may run on those types.
Some common use cases:
- Offset the final
maxPodsvalue to account for known host networking pods - e.g.
max_pods + 2to allow two additional pods - Limit the final
maxPodsvalue to a fixed value - e.g.
max_pods < 30 ? max_pods : 30 - Limit the number of ENIs that can be used for pods
- e.g.
((default_enis - 3) * (ips_per_eni - 1)) + 2to reserve three ENIs - For instances utilizing the AWS VPC CNI's Custom Networking feature, reserving a single ENI may be necessary
- Scale
maxPodswith instance size usingvcpusorphysical_memory_mib - e.g.
vcpus * 10 < max_pods ? vcpus * 10 : max_podsto cap at 10 pods per vCPU - e.g.
physical_memory_mib / 1024 > 32 ? 110 : max_podsto raise the limit only on instances with more than 32 GiB
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
cluster: ...
kubelet:
maxPodsExpression: "vcpus * 10 < max_pods ? vcpus * 10 : max_pods"
⚠️ Note: Values set for maxPods in the kubelet config will take precedence over the result of the maxPodsExpression. kubeReserved will be calculated using the result of the expression or
the internally calculated max pods value, if the expression cannot be evaluated.