04 · The NodeClass: the infrastructure contract¶
Goal: one NodeClass that says how every node in our pools is built: whose identity it runs as, what it's tagged with, which network it lives in, how much disk it gets, and how its kubelet and kernel are tuned.
The manifest¶
# The infrastructure contract: HOW every node in our pools is built.
# Both NodePools reference this one NodeClass. Edit it and every node in
# both pools drifts and is replaced, so treat changes like an AMI rollout.
# Walkthrough: docs/04-nodeclass.md
apiVersion: eks.amazonaws.com/v1
kind: NodeClass
metadata:
name: demo-default # never call a custom NodeClass "default"
labels:
talk: mastering-custom-node-pools
spec:
# ---- identity -------------------------------------------------------------
role: auto-mode-nodepools-demo-node # CHANGE ME to your $NODE_ROLE_NAME
tags: # stamped on every EC2 instance
CostCentre: platform-demo
Owner: your-name # CHANGE ME
Environment: demo
Talk: mastering-custom-node-pools
# ---- network --------------------------------------------------------------
# Private subnets that eksctl created for THIS cluster. Both tags must match.
subnetSelectorTerms:
- tags:
alpha.eksctl.io/cluster-name: auto-mode-nodepools # CHANGE ME to $CLUSTER_NAME
kubernetes.io/role/internal-elb: "1"
# The cluster security group that EKS created and tagged.
securityGroupSelectorTerms:
- tags:
aws:eks:cluster-name: auto-mode-nodepools # CHANGE ME to $CLUSTER_NAME
advancedNetworking:
associatePublicIPAddress: false # no public IPs, whatever the subnet says
# ---- storage --------------------------------------------------------------
ephemeralStorage:
size: 80Gi
# ---- compute tuning (advancedCompute) ---------------------------------------
# Settings that used to need a custom AMI or a privileged DaemonSet.
# Applied at boot; changing any of them drifts (replaces) every node.
advancedCompute:
kubelet:
# A maximum, not a target: EKS applies the lowest of this, its own
# per-instance-type value (27 on a 2-vCPU m6a.large) and 110.
maxPods: 48
eviction:
hard:
memory.available: "200Mi"
nodefs.available: "10%"
logging:
containerLogMaxSize: "20Mi"
containerLogMaxFiles: 5
kernel:
sysctl:
# e.g. Elasticsearch, databases. Note: Auto Mode nodes already default
# to 1048576, so this LOWERS the limit; raise it for production.
vm.max_map_count: 262144
Read it the way you'd review it in a pull request: by concern.
Identity¶
role: the IAM role from step 03, by name. (instanceProfileis the alternative; the two are mutually exclusive.)tags: stamped on every EC2 instance this NodeClass launches. This is how "mandatory cost-allocation tags on every instance" gets enforced. Some keys are reserved for Auto Mode (kubernetes.io/cluster/*,karpenter.sh/*,eks.amazonaws.com/nodeclass) and can't be used. Custom tags only work because of the cluster-role policy from step 03, part 4.
Network¶
subnetSelectorTerms: which subnets nodes launch into. Both tags in one term must match (AND). eksctl tags its private subnets withkubernetes.io/role/internal-elb: "1"and every resource in its stacks withalpha.eksctl.io/cluster-name. Together they mean "the private subnets of this cluster", and nothing in any other VPC.securityGroupSelectorTerms: EKS tags the cluster security group it creates withaws:eks:cluster-name: <cluster>.advancedNetworking.associatePublicIPAddress: false: no public IPs, regardless of the subnet's ownMapPublicIpOnLaunch. Nodes reach the internet (ECR, EKS API) through the NAT gateway from step 01.
Storage¶
ephemeralStorage.size: the node's data volume. AddkmsKeyIDhere to encrypt it (and the root volume) with your own KMS key.
Compute tuning: advancedCompute¶
New in October 2026. Settings that used to mean a custom AMI or a privileged DaemonSet now live in the NodeClass, and Auto Mode validates them on admission and applies them at boot:
kubelet.maxPods: 48: a maximum, not a target. EKS applies the lowest of your value, its own per-instance-type value, and 110. Smaller instances may fit fewer pods than you asked for: a 2-vCPUm6a.largestays at Auto Mode's own 27. Step 07 shows both cases.kubelet.eviction.hard: when the kubelet starts evicting pods under memory or disk pressure.kubelet.logging: container log rotation: 20 MiB per file, 5 files.kernel.sysctl."vm.max_map_count": 262144: memory-map areas per process, the figure Elasticsearch and many databases document. Only an allow-listed set of sysctls is supported, each with a min and max.
Read the defaults first, again
Auto Mode nodes run Bottlerocket, whose vm.max_map_count default is
already 1048576. So 262144 doesn't raise the limit, it lowers it to a
quarter. It's used here because it's the familiar value and it's easy to
spot in step 07. For production, check the default on your nodes and only
set a value above it (for example 2097152).
Step 07 proves maxPods and vm.max_map_count actually reached the nodes.
Blast radius
Every node in every NodePool that references this NodeClass drifts when you change it, and is replaced. Changing a kubelet setting or a sysctl is not applied in place. One edit to a shared NodeClass can roll the whole cluster. Treat NodeClass changes like AMI rollouts: staged, budgeted, outside business hours.
Never call it default
Auto Mode owns a NodeClass called default (step 02). Name yours anything
else.
Fill in the values¶
If you kept CLUSTER_NAME=auto-mode-nodepools, the cluster name and role name
are already right. Change Owner to your name. Otherwise, edit every
# CHANGE ME line:
Check what the selectors match, before applying¶
These run the same tag queries the NodeClass will:
aws ec2 describe-subnets \
--filters "Name=tag:alpha.eksctl.io/cluster-name,Values=$CLUSTER_NAME" \
"Name=tag:kubernetes.io/role/internal-elb,Values=1" \
--query 'Subnets[].{id: SubnetId, az: AvailabilityZone, public: MapPublicIpOnLaunch}' \
--output table
aws ec2 describe-security-groups \
--filters "Name=tag:aws:eks:cluster-name,Values=$CLUSTER_NAME" \
--query 'SecurityGroups[].{id: GroupId, name: GroupName}' --output table
Expect three private subnets (one per AZ, public: False) and one
security group named eks-cluster-sg-<cluster>-…. Compare that ID with the
cluster's own record:
aws eks describe-cluster --name "$CLUSTER_NAME" \
--query cluster.resourcesVpcConfig.clusterSecurityGroupId --output text
Alternative: select by ID instead of by tag
If the tag queries return nothing (for example you brought your own VPC rather than letting eksctl create one), select by ID. Find them:
# The cluster security group
aws eks describe-cluster --name "$CLUSTER_NAME" \
--query cluster.resourcesVpcConfig.clusterSecurityGroupId --output text
# The cluster's subnets that don't auto-assign public IPs
aws ec2 describe-subnets \
--subnet-ids $(aws eks describe-cluster --name "$CLUSTER_NAME" \
--query 'cluster.resourcesVpcConfig.subnetIds' --output text) \
--query 'Subnets[?MapPublicIpOnLaunch==`false`].SubnetId' --output text
Then replace the two selector blocks with IDs, one - id: entry per subnet:
Apply it¶
Validate against the API server first. A server-side dry run runs Auto Mode's admission checks, so a bad sysctl or an unknown field fails here, not later:
Now for real, and wait for it to become Ready:
kubectl apply -f manifests/10-nodeclass.yaml
kubectl wait nodeclass/demo-default --for=condition=Ready --timeout=180s
It usually takes about a minute. If it times out, check the conditions; one of them says what's wrong:
kubectl get nodeclass demo-default \
-o jsonpath='{range .status.conditions[*]}{.type}={.status} {.message}{"\n"}{end}'
See what it resolved to¶
Scroll to status. The selectors have been resolved to concrete subnets
(with their zones) and securityGroups, exactly the IDs the pre-check found,
plus the instanceProfile Auto Mode created for your role. The conditions
should all be True.
A compact view:
kubectl get nodeclass demo-default \
-o jsonpath='{range .status.subnets[*]}{.id}{" "}{.zone}{"\n"}{end}{range .status.securityGroups[*]}{.id}{"\n"}{end}'
Nothing has launched yet: a NodeClass on its own never creates a node. That takes a NodePool.
Not Ready after three minutes? See Troubleshooting.
Next: 05 The NodePools.