How do I set managed node group tags for the under...
# kubernetes
r
How do I set managed node group tags for the underlying cluster at the cluster creation time? I'd like to set these 2 tags so cluster autoscaler can auto-discover the node group.
<http://k8s.io/cluster-autoscaler/|k8s.io/cluster-autoscaler/><cluster-name>
owned
<http://k8s.io/cluster-autoscaler/enabledTRUE|k8s.io/cluster-autoscaler/enabledTRUE>
p
this is how i do it
Copy code
const cluster = new eks.Cluster(
      name,
      {
        name,
        skipDefaultNodeGroup: true,
        vpcId: vpc.id,
        publicSubnetIds: vpc.publicSubnetIds,
        privateSubnetIds: vpc.privateSubnetIds,
        nodeAssociatePublicIpAddress: false,
        instanceRoles: [role],
        userMappings: [
          {
            /**
             * The ARN of the IAM user to add.
             */
            userArn: 'arn:aws:iam::xxx:root',
            /**
             * The user name within Kubernetes to map to the IAM user. By default, the user name is the ARN of the IAM user.
             */
            username: 'xxx',
            /**
             * A list of groups within Kubernetes to which the user is mapped to.
             */
            groups: ['system:masters'],
          },
        ],
        providerCredentialOpts: {},
      },
      {
        provider: regionProvider,
        parent: this,
        protect: false,
      }
    );

    eks.createManagedNodeGroup(
      `${name}-ng`,
      {
        cluster: cluster,
        nodeGroupName: `${name}`,
        nodeRoleArn: role.arn,
        instanceTypes: ['t3.xlarge'],
        scalingConfig: {
          desiredSize: 3,
          minSize: 3,
          maxSize: 50,
        },
        labels: {
          [`cluster-autoscaler/${name}`]: 'owned',
          'cluster-autoscaler/enabled': 'true',
        },
      },
      cluster,
      regionProvider
    );
b
you can do something like this as well, this is for the vpc subnet but will work for the node groups as well: https://github.com/jaxxstorm/pulumi-examples/blob/main/typescript/aws/eks_subnet_tags/index.ts#L51-L57
r
Cool, thanks to both of you @proud-pizza-80589 & @billowy-army-68599!