Is there a way to add node labels when deploying worker nodes in EKS. I do not see an option in the CF template available for worker nodes.
The only option I see right now is to use kubectl label command to add labels which is post cluster setup. However, the need to have complete automation which means applications are deployed automatically post cluster deployments and labels help in achieving the segregation.
You'll need to add the config in
user_data
and use the--node-labels
option for the kubelet. Here's an example user_data which includes node_labels:The relevant line is:
WARNING: I haven't tested this, but I do something similar and it works fine
With the new EKS-optimized AMIs(amazon-eks-node-vXX) and Cloudformation template refactors provided by AWS it is now possible to add node labels as simple as providing arguments to the
BootstrapArguments
parameter of the[amazon-eks-nodegroup.yaml][1]
Cloudfomation template. For example--kubelet-extra-args --node-labels=my-key=my-value
. For more details check the AWS announcement: Improvements for Amazon EKS Worker Node ProvisioningI've managed to get it work with the next sed expression: