Add roles to EKS nodes using Terraform and node groups

8/13/2020

I'm using Terraform to create an EKS cluster using this repo the official hashicorp repo. It works fine but all the nodes have the role none

kubectl get nodes
NAME                                         STATUS   ROLES    AGE     VERSION
xxxx1.compute.internal                       Ready    **<none>**   3m35s   v1.14.9-eks-658790
xxxx2.compute.internal                       Ready    **<none>**   3m42s   v1.14.9-eks-658790

I tried to use labels on the eks node group declaration but it's doesn't work

labels           = {"node-role.kubernetes.io/workers5" = "label1"}

Error: error updating EKS Node Group (clustertest:workers5) config: InvalidParameterException: Label cannot contain reserved labels kubernetes.io/

Any Idea how can i fix it ? or if there is any work around?

thanks

-- hajji_0081
amazon-eks
kubernetes
terraform

1 Answer

8/14/2020

As already explained by BogdanL and in documentation:

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.

So you have to change this label.

-- kool
Source: StackOverflow