Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please provide worker nodes details as an output map (information like instance id, private ip) #1048

Closed
2 of 4 tasks
MesterJoda opened this issue Oct 13, 2020 · 2 comments
Closed
2 of 4 tasks

Comments

@MesterJoda
Copy link

MesterJoda commented Oct 13, 2020

I have issues

When creating AWS EKS worker instances details are needed for creation of AWS NLB Load Balancer. Currently, it's not possible to do so, since it requires target (instance or IP) which is not known while creating the cluster as it's not defined as an output. If we want fully terraform managed environment, NLB should be created by terraform and not kubernetes.

I'm submitting a...

  • bug report
  • feature request
  • support request - read the FAQ first!
  • kudos, thank you, warm fuzzy

What is the current behavior?

Creating the EKS cluster there is no information on details of workers created.

If this is a bug, how to reproduce? Please include a code sample if relevant.

Default installation is enough. Here is a code sample:

resource "aws_lb" "eks_lb" {
  name               = var.eks_cluster_name
  internal           = true
  load_balancer_type = "network"
  subnets            = aws_subnet.private.*.id

  enable_deletion_protection = false

  tags = {
    Environment = var.domain_name
  }
}

resource "aws_lb_target_group" "eks_lb_target_group_443" {
  name        = "eks-lb-tg-443"
  port        = 443
  protocol    = "TCP"
  vpc_id      = aws_vpc.main.id
}

resource "aws_lb_listener" "eks_lb_listener_443" {
  load_balancer_arn = aws_lb.eks_lb.arn
  port              = "443"
  protocol          = "TCP"

  default_action {
    type             = "forward"
    target_group_arn = aws_lb_target_group.eks_lb_target_group_443.arn
  }
}

resource "aws_lb_target_group_attachment" "eks_lb_tg_443" {
  count = length(module.eks.node_groups)
  target_group_arn = aws_lb_target_group.eks_lb_target_group_443.arn
  target_id        = module.eks.node_groups[count.index].id                   <---------------- this part here
  port             = 443
}

As documentation for AWS NLB states:
target_id (Required) The ID of the target. This is the Instance ID for an instance, or the container ID for an ECS container. If the target type is ip, specify an IP address. If the target type is lambda, specify the arn of lambda.

What's the expected behavior?

After creation as an output it would be nice to have detailed information for worker group instances (non-aws managed).
Creation of AWS NLB Load Balancer is not possible since it requires target (instance or IP) which is not known while creating the cluster.

Are you able to fix this problem and submit a PR? Link here if you have already.

Maybe this PR can be referenced #992

Environment details

  • Affected module version: v12.2.0
  • OS:
  • Terraform version:
    0.12

Any other relevant info

Terraform destroy won't work if LB is created by Kubernetes and NLB (network load balancer) cannot be created by terraform since there is no information on worker instance id or private IP. This is a setup of K8s in AWS private subnet which is hidden from internet. Another LB is in-front that accepts ports 80 and 443. NLB is chosen for speed in private subnet.

@MesterJoda
Copy link
Author

I've managed to resolve the issue by assigning to target group to autoscale group.

module "eks" {
  source           = "terraform-aws-modules/eks/aws"
  cluster_name     = var.eks_cluster_name
  workers_group_defaults = {
    instance_type  = var.eks_workers_group_instance_type
  worker_groups    = [
    {
      name = "nodeGroup-1"
    },
    {
      name = "nodeGroup-2"
    }

    target_group_arns = [                                        <-------------- Solution starts here
      aws_lb_target_group.eks_lb_target_group_80.arn,
      aws_lb_target_group.eks_lb_target_group_443.arn
      ]                                                          <-------------- Solution ends here
  }

Closing the ticket since it's possible to create NLB and register worker groups made from this module.
Thank you for making this module.

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant