diff --git a/README.md b/README.md index 395f8dc..3b9b7de 100644 --- a/README.md +++ b/README.md @@ -103,11 +103,13 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a | subnets | A list of subnets to associate with the cluster's underlying instances. | list | - | yes | | tags | A map of tags to add to all resources. | string | `` | no | | vpc_id | VPC id where the cluster and other resources will be deployed. | string | - | yes | -| workers_ami_id | AMI ID for the eks workers. If none is provided, Terraform will search for the latest version of their EKS optimized worker AMI. | string | `` | no | -| workers_asg_desired_capacity | Desired worker capacity in the autoscaling group. | string | `1` | no | -| workers_asg_max_size | Maximum worker capacity in the autoscaling group. | string | `3` | no | -| workers_asg_min_size | Minimum worker capacity in the autoscaling group. | string | `1` | no | -| workers_instance_type | Size of the workers instances. | string | `m4.large` | no | +| worker_groups | A list of maps defining worker autoscaling groups | list of maps | - | no | +| worker_groups.name | Name of the worker group | string | `nodes` | yes +| worker_groups.ami_id | AMI ID for the eks workers. If none is provided, Terraform will search for the latest version of their EKS optimized worker AMI. | string | `` | no | +| worker_groups.asg_desired_capacity | Desired worker capacity in the autoscaling group. | string | `1` | no | +| worker_groups.asg_max_size | Maximum worker capacity in the autoscaling group. | string | `3` | no | +| worker_groups.asg_min_size | Minimum worker capacity in the autoscaling group. | string | `1` | no | +| worker_groups.instance_type | Size of the workers instances. | string | `m4.large` | no | ## Outputs diff --git a/data.tf b/data.tf index c25327c..1af66ee 100644 --- a/data.tf +++ b/data.tf @@ -1,15 +1,5 @@ data "aws_region" "current" {} -data "aws_ami" "eks_worker" { - filter { - name = "name" - values = ["eks-worker-*"] - } - - most_recent = true - owners = ["602401143452"] # Amazon -} - data "aws_iam_policy_document" "workers_assume_role_policy" { statement { sid = "EKSWorkerAssumeRole" @@ -40,19 +30,6 @@ data "aws_iam_policy_document" "cluster_assume_role_policy" { } } -data template_file userdata { - template = "${file("${path.module}/templates/userdata.sh.tpl")}" - - vars { - region = "${data.aws_region.current.name}" - max_pod_count = "${lookup(local.max_pod_per_node, var.workers_instance_type)}" - cluster_name = "${var.cluster_name}" - endpoint = "${aws_eks_cluster.this.endpoint}" - cluster_auth_base64 = "${aws_eks_cluster.this.certificate_authority.0.data}" - additional_userdata = "${var.additional_userdata}" - } -} - data template_file kubeconfig { template = "${file("${path.module}/templates/kubeconfig.tpl")}" @@ -71,8 +48,3 @@ data template_file config_map_aws_auth { role_arn = "${aws_iam_role.workers.arn}" } } - -module "ebs_optimized" { - source = "./modules/tf_util_ebs_optimized" - instance_type = "${var.workers_instance_type}" -} diff --git a/local.tf b/local.tf index d66ba13..f6e07c1 100644 --- a/local.tf +++ b/local.tf @@ -1,66 +1,4 @@ locals { - # Mapping from the node type that we selected and the max number of pods that it can run - # Taken from https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-06-05/amazon-eks-nodegroup.yaml - max_pod_per_node = { - c4.large = 29 - c4.xlarge = 58 - c4.2xlarge = 58 - c4.4xlarge = 234 - c4.8xlarge = 234 - c5.large = 29 - c5.xlarge = 58 - c5.2xlarge = 58 - c5.4xlarge = 234 - c5.9xlarge = 234 - c5.18xlarge = 737 - i3.large = 29 - i3.xlarge = 58 - i3.2xlarge = 58 - i3.4xlarge = 234 - i3.8xlarge = 234 - i3.16xlarge = 737 - m3.medium = 12 - m3.large = 29 - m3.xlarge = 58 - m3.2xlarge = 118 - m4.large = 20 - m4.xlarge = 58 - m4.2xlarge = 58 - m4.4xlarge = 234 - m4.10xlarge = 234 - m5.large = 29 - m5.xlarge = 58 - m5.2xlarge = 58 - m5.4xlarge = 234 - m5.12xlarge = 234 - m5.24xlarge = 737 - p2.xlarge = 58 - p2.8xlarge = 234 - p2.16xlarge = 234 - p3.2xlarge = 58 - p3.8xlarge = 234 - p3.16xlarge = 234 - r3.xlarge = 58 - r3.2xlarge = 58 - r3.4xlarge = 234 - r3.8xlarge = 234 - r4.large = 29 - r4.xlarge = 58 - r4.2xlarge = 58 - r4.4xlarge = 234 - r4.8xlarge = 234 - r4.16xlarge = 737 - t2.small = 8 - t2.medium = 17 - t2.large = 35 - t2.xlarge = 44 - t2.2xlarge = 44 - x1.16xlarge = 234 - x1.32xlarge = 234 - } - - asg_tags = ["${null_resource.tags_as_list_of_maps.*.triggers}"] - # More information: https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-06-05/amazon-eks-nodegroup.yaml config_map_aws_auth = <