pulumi-eks icon indicating copy to clipboard operation
pulumi-eks copied to clipboard

Getting invalid name error creating nodegroup when name is valid

Open jazzdan opened this issue 3 years ago • 2 comments

Hello!

  • Vote on this issue by adding a 👍 reaction
  • To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already)

Issue details

I'm trying to create a new nodegroup in my cluster that looks like this (output from "details" of pulumi up):

Do you want to perform this update? details
  pulumi:pulumi:Stack: (same)
    [urn=urn:pulumi:prod::backend::pulumi:pulumi:Stack::backend-prod]
    > aws:iam/role:Role: (read)
        [id=AWSReservedSSO_ReplayDeveloperProduction_7f9a4f50e1961bb2]
        [urn=urn:pulumi:prod::backend::aws:iam/role:Role::kube-user-role]
        [provider=urn:pulumi:prod::backend::pulumi:providers:aws::default_4_21_2::344de5a7-56da-4718-9965-930d8e62049b]
        + aws:eks/nodeGroup:NodeGroup: (create)
            [urn=urn:pulumi:prod::backend::eks:index:Cluster$aws:eks/nodeGroup:NodeGroup::purple-spot2-2022-02-10]
            [provider=urn:pulumi:prod::backend::pulumi:providers:aws::default_4_21_2::344de5a7-56da-4718-9965-930d8e62049b]
            capacityType       : "SPOT"
            clusterName        : "purple-replay-eks-us-east-2"
            instanceTypes      : [
                [0]: "r5.24xlarge"
                [1]: "r5a.24xlarge"
                [2]: "m5n.24xlarge"
                [3]: "m5.24xlarge"
                [4]: "m5d.24xlarge"
                [5]: "m5a.24xlarge"
                [6]: "m5ad.24xlarge"
            ]
            labels             : {
                VantaContainsUserData: "false"
            }
            launchTemplate     : {
                id        : "lt-0832345ed1ac5522c"
                version   : "1"
            }
            nodeGroupNamePrefix: "purple"
            nodeRoleArn        : "arn:aws:iam::1:role/purple-worker-role2-d9c3eac"
            scalingConfig      : {
                desiredSize: 5
                maxSize    : 8
                minSize    : 5
            }
            subnetIds          : [
                [0]: "subnet-056c58eaf14fe7919"
                [1]: "subnet-0a71c87ab72dfdb25"
                [2]: "subnet-09e691f4c093e3d4c"
                [3]: "subnet-0992bb814df455764"
            ]
            tags               : {
                k8s.io/cluster-autoscaler/cluster/purple-replay-eks-us-east-2: "true"
                k8s.io/cluster-autoscaler/enabled                            : "true"
            }

Which errors with this output:

  aws:eks:NodeGroup (purple-spot2-2022-02-10):
   error: 1 error occurred:
   	* error creating EKS Node Group (purple-replay-eks-us-east-2:purple20220212044608893500000001): InvalidParameterException: Invalid value: Kubernetes node : field must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName',  or 'my.name',  or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')

   {
     RespMetadata: {
       StatusCode: 400,
       RequestID: "f59f13ba-11dd-45eb-ab24-2793685b80ed"
     },
     ClusterName: "purple-replay-eks-us-east-2",
     Message_: "Invalid value: Kubernetes node : field must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName',  or 'my.name',  or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')",
     NodegroupName: "purple20220212044608893500000001"
   }

Which is weird because the Nodegroupname being generated does match that regex and should be valid based on the rules described.

If I don't use a prefix name and hardcode the name I get the same error:

  aws:eks:NodeGroup (purple-spot2-2022-02-10):
    error: 1 error occurred:
    	* error creating EKS Node Group (purple-replay-eks-us-east-2:purple-test): InvalidParameterException: Invalid value: Kubernetes node : field must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName',  or 'my.name',  or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')
    {
      RespMetadata: {
        StatusCode: 400,
        RequestID: "e2ff7293-d9ef-4b63-8481-1a06aa581b7f"
      },
      ClusterName: "purple-replay-eks-us-east-2",
      Message_: "Invalid value: Kubernetes node : field must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName',  or 'my.name',  or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')",
      NodegroupName: "purple-test"
    }

Any obvious things that I'm doing wrong here?

Thanks!

jazzdan avatar Feb 12 '22 04:02 jazzdan

This ended up being because my kubernetes labels were invalid (they contained a ., and I elided them above because they contained sensitive data). The error message is really confusing though, it made it seem like it was a problem with the nodegroup.

jazzdan avatar Feb 14 '22 21:02 jazzdan

Cannot close issue without required labels: resolution/

pulumi-bot avatar Feb 14 '22 21:02 pulumi-bot