ebs optimization of instances now possible

This commit is contained in:
brandoconnor
2018-06-08 04:00:12 -07:00
parent c2db74bf08
commit 0ec5df4cae
8 changed files with 133 additions and 14 deletions

View File

@@ -13,6 +13,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
- `workers_ami_id` is now made optional. If not specified, the module will source the latest AWS supported EKS AMI instead. - `workers_ami_id` is now made optional. If not specified, the module will source the latest AWS supported EKS AMI instead.
- added ability to specify extra userdata code to execute after the second to configure and start kube services. - added ability to specify extra userdata code to execute after the second to configure and start kube services.
- When `configure_kubectl_session` is set to true the current shell will be configured to talk to the kubernetes cluster using config files output from the module. - When `configure_kubectl_session` is set to true the current shell will be configured to talk to the kubernetes cluster using config files output from the module.
- EBS optimization used whenever possible for the given instance type.
## [[v0.1.1](https://github.com/terraform-aws-modules/terraform-aws-eks/compare/v0.1.0...v0.1.1)] - 2018-06-07] ## [[v0.1.1](https://github.com/terraform-aws-modules/terraform-aws-eks/compare/v0.1.0...v0.1.1)] - 2018-06-07]

View File

@@ -71,3 +71,8 @@ data template_file config_map_aws_auth {
role_arn = "${aws_iam_role.workers.arn}" role_arn = "${aws_iam_role.workers.arn}"
} }
} }
module "ebs_optimized" {
source = "modules/util/ebs_optimized/"
instance_type = "${var.workers_instance_type}"
}

View File

@@ -6,19 +6,6 @@ This set of templates serves a few purposes. It:
2. serves as the test infrastructure for CI on the project. 2. serves as the test infrastructure for CI on the project.
3. provides a simple way to play with the Kubernetes cluster you create. 3. provides a simple way to play with the Kubernetes cluster you create.
## testing with kubectl
Once converged, `kubeconfig` and `config-map-aws-auth.yml` should be in this directory.
Ensure you have a recent version of `kubectl` on your PATH ([instructions here](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl))
```bash
curl -o heptio-authenticator-aws https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-06-05/bin/darwin/amd64/heptio-authenticator-aws
mv heptio-authenticator-aws ~/go/bin/
kubectl apply -f examples/eks_test_fixture/config-map-aws-auth.yaml --kubeconfig examples/eks_test_fixture/kubeconfig
# configmap "aws-auth" created
kubectl get nodes --watch --kubeconfig examples/eks_test_fixture/kubeconfig
```
## IAM Permissions ## IAM Permissions
The following IAM policy is the minimum needed to execute the module from the test suite. The following IAM policy is the minimum needed to execute the module from the test suite.

View File

@@ -0,0 +1,114 @@
/**
# terraform_util_ebs_optimized
A terraform module to return true or false based on if an instance type supports the EBS optmized flag.
*/
locals {
ebs_optimized_types = {
"c4.large" = true
"c4.xlarge" = true
"c4.2xlarge" = true
"c4.4xlarge" = true
"c4.8xlarge" = true
"c5.large" = true
"c5.xlarge" = true
"c5.2xlarge" = true
"c5.4xlarge" = true
"c5.9xlarge" = true
"c5.18xlarge" = true
"c5d.large" = true
"c5d.xlarge" = true
"c5d.2xlarge" = true
"c5d.4xlarge" = true
"c5d.9xlarge" = true
"c5d.18xlarge" = true
"d2.xlarge" = true
"d2.2xlarge" = true
"d2.4xlarge" = true
"d2.8xlarge" = true
"f1.2xlarge" = true
"f1.16xlarge" = true
"g3.4xlarge" = true
"g3.8xlarge" = true
"g3.16xlarge" = true
"h1.2xlarge" = true
"h1.4xlarge" = true
"h1.8xlarge" = true
"h1.16xlarge" = true
"i3.large" = true
"i3.xlarge" = true
"i3.2xlarge" = true
"i3.4xlarge" = true
"i3.8xlarge" = true
"i3.16xlarge" = true
"i3.metal" = true
"m4.large" = true
"m4.xlarge" = true
"m4.2xlarge" = true
"m4.4xlarge" = true
"m4.10xlarge" = true
"m4.16xlarge" = true
"m5.large" = true
"m5.xlarge" = true
"m5.2xlarge" = true
"m5.4xlarge" = true
"m5.12xlarge" = true
"m5.24xlarge" = true
"m5d.large" = true
"m5d.xlarge" = true
"m5d.2xlarge" = true
"m5d.4xlarge" = true
"m5d.12xlarge" = true
"m5d.24xlarge" = true
"p2.xlarge" = true
"p2.8xlarge" = true
"p2.16xlarge" = true
"p3.2xlarge" = true
"p3.8xlarge" = true
"p3.16xlarge" = true
"r4.large" = true
"r4.xlarge" = true
"r4.2xlarge" = true
"r4.4xlarge" = true
"r4.8xlarge" = true
"r4.16xlarge" = true
"x1.16xlarge" = true
"x1.32xlarge" = true
"x1e.xlarge" = true
"x1e.2xlarge" = true
"x1e.4xlarge" = true
"x1e.8xlarge" = true
"x1e.16xlarge" = true
"x1e.32xlarge" = true
"c5.large" = true
"c5.xlarge" = true
"c5.2xlarge" = true
"c5d.large" = true
"c5d.xlarge" = true
"c5d.2xlarge" = true
"m5.large" = true
"m5.xlarge" = true
"m5.2xlarge" = true
"m5d.large" = true
"m5d.xlarge" = true
"m5d.2xlarge" = true
"c1.xlarge" = true
"c3.xlarge" = true
"c3.2xlarge" = true
"c3.4xlarge" = true
"g2.2xlarge" = true
"i2.xlarge" = true
"i2.2xlarge" = true
"i2.4xlarge" = true
"m1.large" = true
"m1.xlarge" = true
"m2.2xlarge" = true
"m2.4xlarge" = true
"m3.xlarge" = true
"m3.2xlarge" = true
"r3.xlarge" = true
"r3.2xlarge" = true
"r3.4xlarge" = true
}
}

View File

@@ -0,0 +1,4 @@
output "answer" {
description = "Returns true or false depending on if the instance type is able to be EBS optimized."
value = "${lookup(local.ebs_optimized_types, var.instance_type, false)}"
}

View File

@@ -0,0 +1,3 @@
variable "instance_type" {
description = "Instance type to evaluate if EBS optimized is an option."
}

View File

@@ -27,6 +27,11 @@ variable "configure_kubectl_session" {
default = false default = false
} }
variable "ebs_optimized_workers" {
description = "If left at default of true, will use ebs optimization if available on the given instance type."
default = true
}
variable "subnets" { variable "subnets" {
description = "A list of subnets to associate with the cluster's underlying instances." description = "A list of subnets to associate with the cluster's underlying instances."
type = "list" type = "list"

View File

@@ -23,7 +23,7 @@ resource "aws_launch_configuration" "workers" {
instance_type = "${var.workers_instance_type}" instance_type = "${var.workers_instance_type}"
security_groups = ["${aws_security_group.workers.id}"] security_groups = ["${aws_security_group.workers.id}"]
user_data_base64 = "${base64encode(data.template_file.userdata.rendered)}" user_data_base64 = "${base64encode(data.template_file.userdata.rendered)}"
ebs_optimized = false ebs_optimized = "${var.ebs_optimized_workers ? module.ebs_optimized.answer : false}"
lifecycle { lifecycle {
create_before_destroy = true create_before_destroy = true