I didn't see it in examples anywhere, but there is...
# aws
c
I didn't see it in examples anywhere, but there is a preferred way of creating an EKS cluster with a managed nodegroup and then associating the autoscaling group that creates with an autoscaling.Attachment for a targetgroup?
q
I guess you're trying to expose services running on your cluster via a Load Balancer? In that case I'd recommend using the AWS Load Balancer Controller. The benefit here is that you do not need to add your nodes into the target group, instead the controller will add the pods directly. Additionally it will insert pod readiness gates to ensure downtimeless deployments
c
I am unable to use ALB load balancer controller in our environment. The ALB has to be created outside and attached to the cluster ASG.
q
You can do that with the load balancer controller. You can create the ALB in pulumi for example and instruct the load balancer controller to use it
This is how you can instruct the Load Balancer Controller to bind to your existing target group: https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.1/guide/targetgroupbinding/targetgroupbinding/
In case this approach does not work for you, you can use this function to look up the node group: https://www.pulumi.com/registry/packages/aws/api-docs/eks/getnodegroup/#aws-eks-getnodegroup The return value will include a reference to the auto scaling group
c
Is there a way to reference the Name of the cluster and Nodegroup as strings without having to wrap the lookup and attachment inside an ApplyT?
q
You're using Go I guess? The output form accepts Input-wrapped arguments. I.e.
LookupNodeGroupOutput
c
Thanks for the help.
Actually having an issue with this, so I have an *eks.ManagedNodeGroup, and need to create an autoscaling.Attachment and iam.RolePolicyAttachment on it, the outputs from the ManagedNodeGroup do not appear to include an Autoscalinggroup from which I can get an autoscaling group name. The eks.ManagedNodeGroup.Resources() Array has an "AutoscalingGroups()" but it is nil.
q
Could it be an eventual consistency issue? IIRC, the AWS EKS service creates the ASG asynchronously. Are the other properties in the
LookupNodeGroupOutput
response populated?
c
The managed node group NodeGroup.Resources().Index(pulumi.Int(0)).AutoscalingGroups().Index(pulumi.Int(0)).Name().Elem() was empty, but it actually started working correctly for no reason I could tell. Using this I was able to do an attachment. I had another issue that I didn't find a "good" solution for - the autoscaling group is directly targeted on node port by a loadbalancer so I had to join them both to a security group but the EKS created security group for the managed node group was not retrievable with pulumi and I instead had to resort to lookup by tags.
Not retrievable from any of the objects as far as I could tell, lookup worked.
q
The security group you're referring to is the Cluster Security Group the EKS service creates themselves. This is included in the cluster's output:
cluster.eksCluster.vpcConfig.clusterSecurityGroupId
c
Didn't catch that cluster.clusterSecurityGroupId was different from that, it was the wrong group which threw me off.