From ae85956e41ae3147acdd7c135a65d554d3530b2d Mon Sep 17 00:00:00 2001 From: Zied ABID Date: Mon, 27 Jun 2016 13:32:17 +0200 Subject: [PATCH] create new implementation --- contrib/terraform/aws/autoscale/as.tf | 84 +++++++++++ contrib/terraform/aws/autoscale/elb.tf | 28 ++++ contrib/terraform/aws/autoscale/iam.tf | 137 ++++++++++++++++++ contrib/terraform/aws/autoscale/lc.tf | 39 +++++ .../aws/autoscale/variables.tf.sample | 42 ++++++ 5 files changed, 330 insertions(+) create mode 100644 contrib/terraform/aws/autoscale/as.tf create mode 100644 contrib/terraform/aws/autoscale/elb.tf create mode 100644 contrib/terraform/aws/autoscale/iam.tf create mode 100644 contrib/terraform/aws/autoscale/lc.tf create mode 100644 contrib/terraform/aws/autoscale/variables.tf.sample diff --git a/contrib/terraform/aws/autoscale/as.tf b/contrib/terraform/aws/autoscale/as.tf new file mode 100644 index 000000000..bb4c0f916 --- /dev/null +++ b/contrib/terraform/aws/autoscale/as.tf @@ -0,0 +1,84 @@ +resource "aws_autoscaling_group" "masters" { + availability_zones = ["${split(",", var.av_zones)}"] + vpc_zone_identifier = ["${split(",", var.masters.subnets)}"] + name = "k8s-as-masters" + max_size = 2 + min_size = 2 + desired_capacity = 2 + health_check_grace_period = 300 + health_check_type = "ELB" + launch_configuration = "${aws_launch_configuration.lc-masters.name}" + load_balancers = ["${aws_elb.elb-masters.name}"] + + tag { + key = "Name" + value = "k8s-master" + propagate_at_launch = true + } + tag { + key = "role" + value = "master" + propagate_at_launch = true + } + tag { + key = "env" + value = "${var.env}" + propagate_at_launch = true + } +} + +resource "aws_autoscaling_group" "etcd" { + availability_zones = ["${split(",", var.av_zones)}"] + vpc_zone_identifier = ["${split(",", var.nodes.subnets)}"] + name = "k8s-as-etcd" + max_size = 3 + min_size = 3 + desired_capacity = 3 + health_check_type = "EC2" + health_check_grace_period = 300 + launch_configuration = "${aws_launch_configuration.lc-etcd.name}" + + tag { + key = "Name" + value = "k8s-etcd" + propagate_at_launch = true + } + tag { + key = "role" + value = "etcd" + propagate_at_launch = true + } + tag { + key = "env" + value = "${var.env}" + propagate_at_launch = true + } +} + +resource "aws_autoscaling_group" "nodes" { + availability_zones = ["${split(",", var.av_zones)}"] + vpc_zone_identifier = ["${split(",", var.nodes.subnets)}"] + name = "k8s-as-nodes" + max_size = 10 + min_size = 2 + desired_capacity = 3 + health_check_grace_period = 300 + health_check_type = "ELB" + launch_configuration = "${aws_launch_configuration.lc-nodes.name}" + + tag { + key = "Name" + value = "k8s-node" + propagate_at_launch = true + } + tag { + key = "role" + value = "node" + propagate_at_launch = true + } + tag { + key = "env" + value = "${var.env}" + propagate_at_launch = true + } +} diff --git a/contrib/terraform/aws/autoscale/elb.tf b/contrib/terraform/aws/autoscale/elb.tf new file mode 100644 index 000000000..9f80d7144 --- /dev/null +++ b/contrib/terraform/aws/autoscale/elb.tf @@ -0,0 +1,28 @@ +resource "aws_elb" "elb-masters" { + name = "k8s-masters-elb" + availability_zones = ["${split(",", var.av_zones)}"] + + listener { + instance_port = 80 + instance_protocol = "http" + lb_port = 80 + lb_protocol = "http" + } + + health_check { + healthy_threshold = 2 + unhealthy_threshold = 2 + timeout = 3 + target = "HTTP:80${var.masters.check}" + interval = 30 + } + + cross_zone_load_balancing = true + idle_timeout = 300 + connection_draining = true + connection_draining_timeout = 300 + + tags { + Name = "elb-k8s-api" + } +} diff --git a/contrib/terraform/aws/autoscale/iam.tf b/contrib/terraform/aws/autoscale/iam.tf new file mode 100644 index 000000000..3f0b9934a --- /dev/null +++ b/contrib/terraform/aws/autoscale/iam.tf @@ -0,0 +1,137 @@ +resource "aws_iam_instance_profile" "masters" { + name = "masters" + roles = ["${aws_iam_role.masters.name}"] +} + +resource "aws_iam_role" "masters" { + name = "masters" + path = "/" + assume_role_policy = <