'Terraform EKS specify node-role.kubernetes.io label on node group

In the terraform aws_eks_node_group resource I can't set :

labels = {
  "node-role.kubernetes.io/others" = "other"
}

as AWS complains labels key should not contains kubernetes.io.

Error: error creating EKS Node Group (my-cluster:others): InvalidParameterException: Label cannot contain reserved labels kubernetes.io/
{
  ClusterName: "my-cluster",
  Message_: "Label cannot contain reserved labels kubernetes.io/",
  NodegroupName: "others"
}

Also, EC2 instances spawned have no name and I have no clue on how to specify a Name for my instances based on their node group.

Any idea on how to achieve this ?



Solution 1:[1]

As per the documentation you can't use specific labels, regarding labels:

The kubernetes.io/ and k8s.io/ prefixes are reserved for Kubernetes core components. Valid label values must be 63 characters or less and must be empty or begin and end with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between.

Regarding your specific label. There are many issues since k8s 1.15 or 1.16 where some change in the core kubernetes don’t allow that label. one detailed issue

As for naming of EC2 instances created by EKS Node Group. Currently, there is no way to pass "Name" tag. This question is a duplicate of this where you can also find the answer how to name your instances for time being.

Solution 2:[2]

node-role.kubernetes.io and kubernetes.io - this is DIFFERENT prefixes

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 user19095655