https://pulumi.com logo
#kubernetes
Title
# kubernetes
r

ripe-shampoo-80285

06/19/2021, 1:52 AM
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

proud-pizza-80589

06/19/2021, 9:20 AM
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

billowy-army-68599

06/20/2021, 12:31 PM
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

ripe-shampoo-80285

06/20/2021, 6:54 PM
Cool, thanks to both of you @proud-pizza-80589 & @billowy-army-68599!
4 Views