Skip to content

Attach EBS volumes to worker nodes #233 #572

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

Conversation

szpuni
Copy link

@szpuni szpuni commented Oct 25, 2019

PR o'clock

Description

This PR updates functionality of ASG to allow external Launch Configuration to be used rather than one provided by module.
This was requested in #233

Checklist

@szpuni
Copy link
Author

szpuni commented Oct 25, 2019

I'm not sure if solution provided by @max-rocket-internet will work here. I'm trying to use it and I'm getting Cycle Errors on plan.

I'm trying to reuse some of outputs from cluster like Instance profile, cluster name etc.
As soon as I try to use this feature I get issues:
Error: Cycle: module.eks.aws_iam_instance_profile.workers, module.eks.output.worker_iam_instance_profile_names, module.eks.local.worker_group_count, module.eks.data.template_file.userdata, module.eks.output.workers_user_data, aws_launch_configuration.application, module.eks.var.worker_groups

I guess it's better off to hold this change since it might not actually work.
Idea here is to have easy option to add additional EBS volumes when needed and seems like creating LC outside module is not as easy as one would think.

LC used for test:

resource "aws_launch_configuration" "application" {
  # Below is new option supported by AWS where they use parameter store for releasing new AMI
  image_id                    = jsondecode(data.aws_ssm_parameter.eks_node_ami.value)["image_id"]
  instance_type               = "t2.large"
  associate_public_ip_address = false
  ebs_optimized               = false
  enable_monitoring           = true
  iam_instance_profile        = module.eks.worker_iam_instance_profile_names[0]
  name_prefix                 = module.eks.cluster_id
  key_name                    = "infra-dev-key"
  user_data                   = module.eks.workers_user_data[0]
  security_groups             = [aws_security_group.all_worker_mgmt.id, module.eks.worker_security_group_id]
  root_block_device {
    delete_on_termination = true
    encrypted             = false
    iops                  = 0
    volume_size           = 100
    volume_type           = "gp2"
  }
  ebs_block_device {
    device_name           = "/dev/xvda"
    volume_size           = 100
    volume_type           = "gp2"
    delete_on_termination = true
    encrypted             = false
  }
}

Worker portion used for test:

    {
      name                          = "test"
      asg_desired_capacity          = 1
      subnets                       = data.aws_subnet_ids.private.ids
      kubelet_extra_args            = "--node-labels=cluster=test"
      launch_configuration = aws_launch_configuration.application.name
    },

I think my problem is with calls to child module for data. Opinions welcome.
Maybe I'm missing something pretty obvious.

@szpuni
Copy link
Author

szpuni commented Oct 25, 2019

I think there might be better way of doing this with help of Dynamic block.

variable "ebs" {
  default = ["/dev/sdf"]
}

  dynamic ebs_block_device {
    for_each = var.ebs
    content {
      device_name = ebs_block_device.value
      volume_size = "8"
      delete_on_termination = true
      volume_type = "gp2"
    }

I was goofing around and found that if you run above code with single instance you will get Root and EBS volume. If you give empty list to above then plan will show that EBS will be created but there is only Root device is created in AWS.

This might be a good solution to this problem with small enough changes to code.

Ideas?

@szpuni szpuni closed this Oct 26, 2019
@max-rocket-internet
Copy link
Contributor

I think there might be better way of doing this with help of Dynamic block

Agreed.

@szpuni szpuni deleted the attach-EBS-volumes-to-worker-nodes branch October 29, 2019 10:11
@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, 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 21, 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

Successfully merging this pull request may close these issues.

2 participants