Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions examples/tectonic.aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ aws:
# If name is not provided the installer will construct the name using "name", current AWS region and "baseDomain"
# assetsS3BucketName:

# (optional) Extra AWS tags to be applied to created autoscaling group resources.
# This is a list of maps having the keys `key`, `value` and `propagate_at_launch`.
#
# Example: `[ { key = "foo", value = "bar", propagate_at_launch = true } ]`
# autoScalingGroupExtraTags:

# (optional) AMI override for all nodes. Example: `ami-foobar123`.
# ec2AMIOverride:

Expand Down
1 change: 0 additions & 1 deletion installer/pkg/config/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const (

// AWS converts AWS related config.
type AWS struct {
AutoScalingGroupExtraTags []map[string]string `json:"tectonic_autoscaling_group_extra_tags,omitempty" yaml:"autoScalingGroupExtraTags,omitempty"`
EC2AMIOverride string `json:"tectonic_aws_ec2_ami_override,omitempty" yaml:"ec2AMIOverride,omitempty"`
Endpoints Endpoints `json:"tectonic_aws_endpoints,omitempty" yaml:"endpoints,omitempty"`
Etcd `json:",inline" yaml:"etcd,omitempty"`
Expand Down
127 changes: 55 additions & 72 deletions modules/aws/master-asg/master.tf → modules/aws/master/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,66 +10,7 @@ module "ami" {
release_version = "${var.container_linux_version}"
}

resource "aws_autoscaling_group" "masters" {
name = "${var.cluster_name}-masters"
desired_capacity = "${var.instance_count}"
max_size = "${var.instance_count * 3}"
min_size = "${var.instance_count}"
launch_configuration = "${aws_launch_configuration.master_conf.id}"
vpc_zone_identifier = ["${var.subnet_ids}"]

load_balancers = ["${var.aws_lbs}"]

tags = [
{
key = "Name"
value = "${var.cluster_name}-master"
propagate_at_launch = true
},
{
key = "kubernetes.io/cluster/${var.cluster_name}"
value = "owned"
propagate_at_launch = true
},
{
key = "tectonicClusterID"
value = "${var.cluster_id}"
propagate_at_launch = true
},
"${var.autoscaling_group_extra_tags}",
]

lifecycle {
create_before_destroy = true
}
}

resource "aws_launch_configuration" "master_conf" {
instance_type = "${var.ec2_type}"
image_id = "${coalesce(var.ec2_ami, module.ami.id)}"
name_prefix = "${var.cluster_name}-master-"
security_groups = ["${var.master_sg_ids}"]
iam_instance_profile = "${aws_iam_instance_profile.master_profile.arn}"
associate_public_ip_address = "${var.public_endpoints}"
user_data = "${var.user_data_ign}"

lifecycle {
create_before_destroy = true

# Ignore changes in the AMI which force recreation of the resource. This
# avoids accidental deletion of nodes whenever a new CoreOS Release comes
# out.
ignore_changes = ["image_id"]
}

root_block_device {
volume_type = "${var.root_volume_type}"
volume_size = "${var.root_volume_size}"
iops = "${var.root_volume_type == "io1" ? var.root_volume_iops : 0}"
}
}

resource "aws_iam_instance_profile" "master_profile" {
resource "aws_iam_instance_profile" "master" {
name = "${var.cluster_name}-master-profile"

role = "${var.master_iam_role == "" ?
Expand Down Expand Up @@ -115,34 +56,76 @@ resource "aws_iam_role_policy" "master_policy" {
"Version": "2012-10-17",
"Statement": [
{
"Action": "ec2:*",
"Action": "ec2:Describe*",
"Resource": "*",
"Effect": "Allow"
},
{
"Action": "elasticloadbalancing:*",
"Resource": "*",
"Effect": "Allow"
"Effect": "Allow",
"Action": "ec2:AttachVolume",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "ec2:DetachVolume",
"Resource": "*"
},
{
"Action" : [
"s3:GetObject",
"s3:HeadObject",
"s3:ListBucket",
"s3:PutObject"
"s3:GetObject"
],
"Resource": "arn:${local.arn}:s3:::*",
"Effect": "Allow"
},
{
"Action" : [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeAutoScalingInstances"
],
"Action": "elasticloadbalancing:*",
"Resource": "*",
"Effect": "Allow"
}
]
}
EOF
}

resource "aws_instance" "master" {
count = "${var.instance_count}"
ami = "${coalesce(var.ec2_ami, module.ami.id)}"

iam_instance_profile = "${aws_iam_instance_profile.master.name}"
instance_type = "${var.ec2_type}"
subnet_id = "${element(var.subnet_ids, count.index)}"
user_data = "${var.user_data_ign}"
vpc_security_group_ids = ["${var.master_sg_ids}"]
associate_public_ip_address = "${var.public_endpoints}"

lifecycle {
# Ignore changes in the AMI which force recreation of the resource. This
# avoids accidental deletion of nodes whenever a new CoreOS Release comes
# out.
ignore_changes = ["ami"]
}

tags = "${merge(map(
"Name", "${var.cluster_name}-master-${count.index}",
"kubernetes.io/cluster/${var.cluster_name}", "owned",
"tectonicClusterID", "${var.cluster_id}"
), var.extra_tags)}"

root_block_device {
volume_type = "${var.root_volume_type}"
volume_size = "${var.root_volume_size}"
iops = "${var.root_volume_type == "io1" ? var.root_volume_iops : 0}"
}

volume_tags = "${merge(map(
"Name", "${var.cluster_name}-master-${count.index}-vol",
"kubernetes.io/cluster/${var.cluster_name}", "owned",
"tectonicClusterID", "${var.cluster_id}"
), var.extra_tags)}"
}

resource "aws_elb_attachment" "masters" {
count = "${length(var.aws_lbs) * var.instance_count}"
elb = "${var.aws_lbs[count.index / var.instance_count]}"
instance = "${aws_instance.master.*.id[count.index % var.instance_count]}"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
output "aws_launch_configuration" {
value = "${aws_launch_configuration.master_conf.id}"
}

output "subnet_ids" {
value = "${var.subnet_ids}"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
variable "autoscaling_group_extra_tags" {
description = "Extra AWS tags to be applied to created autoscaling group resources."
type = "list"
default = []
}

variable "base_domain" {
type = "string"
description = "Domain on which the ELB records will be created"
Expand Down
115 changes: 43 additions & 72 deletions modules/aws/worker-asg/worker.tf → modules/aws/worker/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,70 +10,7 @@ module "ami" {
release_version = "${var.container_linux_version}"
}

resource "aws_launch_configuration" "worker_conf" {
instance_type = "${var.ec2_type}"
image_id = "${coalesce(var.ec2_ami, module.ami.id)}"
name_prefix = "${var.cluster_name}-worker-"
security_groups = ["${var.sg_ids}"]
iam_instance_profile = "${aws_iam_instance_profile.worker_profile.arn}"
user_data = "${var.user_data_ign}"

lifecycle {
create_before_destroy = true

# Ignore changes in the AMI which force recreation of the resource. This
# avoids accidental deletion of nodes whenever a new CoreOS Release comes
# out.
ignore_changes = ["image_id"]
}

root_block_device {
volume_type = "${var.root_volume_type}"
volume_size = "${var.root_volume_size}"
iops = "${var.root_volume_type == "io1" ? var.root_volume_iops : 0}"
}
}

resource "aws_autoscaling_group" "workers" {
name = "${var.cluster_name}-workers"
desired_capacity = "${var.instance_count}"
max_size = "${var.instance_count * 3}"
min_size = "${var.instance_count}"
launch_configuration = "${aws_launch_configuration.worker_conf.id}"
vpc_zone_identifier = ["${var.subnet_ids}"]

tags = [
{
key = "Name"
value = "${var.cluster_name}-worker"
propagate_at_launch = true
},
{
key = "kubernetes.io/cluster/${var.cluster_name}"
value = "owned"
propagate_at_launch = true
},
{
key = "tectonicClusterID"
value = "${var.cluster_id}"
propagate_at_launch = true
},
"${var.autoscaling_group_extra_tags}",
]

lifecycle {
create_before_destroy = true
}
}

resource "aws_autoscaling_attachment" "workers" {
count = "${length(var.load_balancers)}"

autoscaling_group_name = "${aws_autoscaling_group.workers.name}"
elb = "${var.load_balancers[count.index]}"
}

resource "aws_iam_instance_profile" "worker_profile" {
resource "aws_iam_instance_profile" "worker" {
name = "${var.cluster_name}-worker-profile"

role = "${var.worker_iam_role == "" ?
Expand Down Expand Up @@ -144,16 +81,50 @@ resource "aws_iam_role_policy" "worker_policy" {
],
"Resource": "arn:${local.arn}:s3:::*",
"Effect": "Allow"
},
{
"Action" : [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeAutoScalingInstances"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
EOF
}

resource "aws_instance" "worker" {
count = "${var.instance_count}"
ami = "${coalesce(var.ec2_ami, module.ami.id)}"

iam_instance_profile = "${aws_iam_instance_profile.worker.name}"
instance_type = "${var.ec2_type}"
subnet_id = "${element(var.subnet_ids, count.index)}"
user_data = "${var.user_data_ign}"
vpc_security_group_ids = ["${var.sg_ids}"]

lifecycle {
# Ignore changes in the AMI which force recreation of the resource. This
# avoids accidental deletion of nodes whenever a new CoreOS Release comes
# out.
ignore_changes = ["image_id"]
}

tags = "${merge(map(
"Name", "${var.cluster_name}-worker-${count.index}",
"kubernetes.io/cluster/${var.cluster_name}", "owned",
"tectonicClusterID", "${var.cluster_id}"
), var.extra_tags)}"

root_block_device {
volume_type = "${var.root_volume_type}"
volume_size = "${var.root_volume_size}"
iops = "${var.root_volume_type == "io1" ? var.root_volume_iops : 0}"
}

volume_tags = "${merge(map(
"Name", "${var.cluster_name}-master-${count.index}-vol",
"kubernetes.io/cluster/${var.cluster_name}", "owned",
"tectonicClusterID", "${var.cluster_id}"
), var.extra_tags)}"
}

resource "aws_elb_attachment" "workers" {
count = "${length(var.load_balancers) * var.instance_count}"
elb = "${var.load_balancers[count.index / var.instance_count]}"
instance = "${aws_instance.worker.*.id[count.index % var.instance_count]}"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
output "aws_launch_configuration" {
value = "${aws_launch_configuration.worker_conf.id}"
}

output "subnet_ids" {
value = "${var.subnet_ids}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ variable "extra_tags" {
default = {}
}

variable "autoscaling_group_extra_tags" {
description = "Extra AWS tags to be applied to created autoscaling group resources."
type = "list"
default = []
}

variable "region" {
type = "string"

Expand Down
39 changes: 19 additions & 20 deletions steps/joining_workers/aws/workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,24 @@ module "container_linux" {
}

module "workers" {
source = "../../../modules/aws/worker-asg"
source = "../../../modules/aws/worker"

autoscaling_group_extra_tags = "${var.tectonic_autoscaling_group_extra_tags}"
cluster_id = "${var.tectonic_cluster_id}"
cluster_name = "${var.tectonic_cluster_name}"
container_linux_channel = "${var.tectonic_container_linux_channel}"
container_linux_version = "${module.container_linux.version}"
ec2_type = "${var.tectonic_aws_worker_ec2_type}"
extra_tags = "${var.tectonic_aws_extra_tags}"
instance_count = "${var.tectonic_worker_count}"
load_balancers = "${var.tectonic_aws_worker_load_balancers}"
region = "${var.tectonic_aws_region}"
root_volume_iops = "${var.tectonic_aws_worker_root_volume_iops}"
root_volume_size = "${var.tectonic_aws_worker_root_volume_size}"
root_volume_type = "${var.tectonic_aws_worker_root_volume_type}"
sg_ids = "${concat(var.tectonic_aws_worker_extra_sg_ids, list(local.sg_id))}"
subnet_ids = "${local.subnet_ids}"
worker_iam_role = "${var.tectonic_aws_worker_iam_role_name}"
ec2_ami = "${var.tectonic_aws_ec2_ami_override}"
base_domain = "${var.tectonic_base_domain}"
user_data_ign = "${file("${path.cwd}/${var.tectonic_ignition_worker}")}"
cluster_id = "${var.tectonic_cluster_id}"
cluster_name = "${var.tectonic_cluster_name}"
container_linux_channel = "${var.tectonic_container_linux_channel}"
container_linux_version = "${module.container_linux.version}"
ec2_type = "${var.tectonic_aws_worker_ec2_type}"
extra_tags = "${var.tectonic_aws_extra_tags}"
instance_count = "${var.tectonic_worker_count}"
load_balancers = "${var.tectonic_aws_worker_load_balancers}"
region = "${var.tectonic_aws_region}"
root_volume_iops = "${var.tectonic_aws_worker_root_volume_iops}"
root_volume_size = "${var.tectonic_aws_worker_root_volume_size}"
root_volume_type = "${var.tectonic_aws_worker_root_volume_type}"
sg_ids = "${concat(var.tectonic_aws_worker_extra_sg_ids, list(local.sg_id))}"
subnet_ids = "${local.subnet_ids}"
worker_iam_role = "${var.tectonic_aws_worker_iam_role_name}"
ec2_ami = "${var.tectonic_aws_ec2_ami_override}"
base_domain = "${var.tectonic_base_domain}"
user_data_ign = "${file("${path.cwd}/${var.tectonic_ignition_worker}")}"
}
Loading