Terraform-aws-eks: [Feature Request] Spot for Managed Node Groups

Created on 19 Nov 2020  Â·  10Comments  Â·  Source: terraform-aws-modules/terraform-aws-eks

I have issues

The documentation shows an example of how to create a spot fleet using a workergroup launch template.

Is it possible to do the same as a nodeGroup instead ?

I'm submitting a...

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

What is the current behavior?

The documentation shows how to create a spot fleet using launch templates.

worker_groups_launch_template = [
    {
      name                    = "spot-1"
      override_instance_types = ["m5.large", "m5a.large", "m5d.large", "m5ad.large"]
      spot_instance_pools     = 4
      asg_max_size            = 5
      asg_desired_capacity    = 5
      kubelet_extra_args      = "--node-labels=node.kubernetes.io/lifecycle=spot"
      public_ip               = true
    },
  ]

What's the expected behavior?

I'd like to have a nodegroup that manages a spot fleet instead, so it appears in the EKS console or when I do aws eks list-nodegroups

Environment details

  • Affected module version: 13.1.0
  • OS: Linux
  • Terraform version: 0.13.5
enhancement kinaws kinterraform-provider

Most helpful comment

Updating that spot for managed node groups has just been released! Would be cool if this gets supported.

Here's the blog post: https://aws.amazon.com/blogs/containers/amazon-eks-now-supports-provisioning-and-managing-ec2-spot-instances-in-managed-node-groups/

All 10 comments

This is not yet available in EKS. AWS is working on it. From https://github.com/aws/containers-roadmap/issues/583, it sounds like the feature is coming soon.

Updating that spot for managed node groups has just been released! Would be cool if this gets supported.

Here's the blog post: https://aws.amazon.com/blogs/containers/amazon-eks-now-supports-provisioning-and-managing-ec2-spot-instances-in-managed-node-groups/

I've tweaked the module locally and think I could propose a change.
It would involve the following:

  • Add a "capacity_type" attribute to the nodegroup map. It can take 2 values "ON_DEMAND" (default) or "SPOT" (see https://aws.amazon.com/blogs/containers/amazon-eks-now-supports-provisioning-and-managing-ec2-spot-instances-in-managed-node-groups/ and https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_node_group#capacity_type)
  • change the expression of the "instance_types" attribute in node_groups.tf to accept values from another attribute of the nodegroup map (e.g. we could add a "instance_types" attribute that takes a list of strings

@antonbabenko let me know if you'd like me to submit a PR.

FWIW, it seems that if you're using a Launch Template (custom userdata) and a Managed Node Group, you still can't request Spot instances that way.

FWIW, it seems that if you're using a Launch Template (custom userdata) and a Managed Node Group, you still can't request Spot instances that way.

I'm on the latest version of the aws provider 3.20.0 and I was able to launch spot instances using a aws_eks_node_group resource and a aws_launch_teamplate resource. That said, I didn't try setting a custom user data script.

Was it a pool of mixed spot & ondemand? I realised my experience is about a mixed pool of both in the same node group.

Was it a pool of mixed spot & ondemand? I realised my experience is about a mixed pool of both in the same node group.

I only tried with spot. For what it's worth, an eks managed node group can either have a capacity type of spot or ondemand. From the docs

Capacity type – Select a capacity type. For more information about choosing a capacity type, see Managed node group capacity types. You cannot mix different capacity types within the same node group. If you want to use both capacity types, create separate node groups, each with their own capacity and instance types.

Source https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html

Excited about using spot on managed node groups. Would be great to be able to configure this using this module soon!

I'm kinda stuck at this point as well; I'd love to be able to setup managed nodegroups with SPOT. Any idea when we might get a PR on this? I'd like to help contribute as well as soon as I'm comfortable with golang!

I have a working version. I can submit a PR for review tomorrow.

On Mon, Dec 21, 2020, 8:56 PM joelfogue notifications@github.com wrote:

I'm kinda stuck at this point as well; I'd love to be able to setup
managed nodegroups with SPOT. Any idea when we might get a PR on this? I'd
like to help contribute as well as soon as I'm comfortable with golang!

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/terraform-aws-modules/terraform-aws-eks/issues/1107#issuecomment-749293442,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AABO544AP2ZUTVQ46YA63ATSV74EZANCNFSM4T2UBTIQ
.

Was this page helpful?
0 / 5 - 0 ratings