Warm tip: This article is reproduced from stackoverflow.com, please click
kubernetes terraform terraform-provider-aws amazon-eks

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

发布于 2020-04-13 10:05:41

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 ?

Questioner
rmonjo
Viewed
183
marcincuber 2020-02-04 02:50

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.