Skip to content
Closed
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
30 changes: 15 additions & 15 deletions data/data/aws/master/main.tf → data/data/aws/controlplane/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ locals {
arn = "aws"
}

resource "aws_iam_instance_profile" "master" {
name = "${var.cluster_name}-master-profile"
resource "aws_iam_instance_profile" "control_plane" {
name = "${var.cluster_name}-control-plane-profile"

role = "${aws_iam_role.master_role.name}"
role = "${aws_iam_role.control_plane_role.name}"
}

resource "aws_iam_role" "master_role" {
name = "${var.cluster_name}-master-role"
resource "aws_iam_role" "control_plane_role" {
name = "${var.cluster_name}-control-plane-role"
path = "/"

assume_role_policy = <<EOF
Expand All @@ -31,9 +31,9 @@ EOF
tags = "${var.tags}"
}

resource "aws_iam_role_policy" "master_policy" {
name = "${var.cluster_name}_master_policy"
role = "${aws_iam_role.master_role.id}"
resource "aws_iam_role_policy" "control_plane_policy" {
name = "${var.cluster_name}_control_plane_policy"
role = "${aws_iam_role.control_plane_role.id}"

policy = <<EOF
{
Expand Down Expand Up @@ -66,16 +66,16 @@ resource "aws_iam_role_policy" "master_policy" {
EOF
}

resource "aws_instance" "master" {
resource "aws_instance" "control_plane" {
count = "${var.instance_count}"
ami = "${var.ec2_ami}"

iam_instance_profile = "${aws_iam_instance_profile.master.name}"
iam_instance_profile = "${aws_iam_instance_profile.control_plane.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}"]
vpc_security_group_ids = ["${var.control_plane_sg_ids}"]

lifecycle {
# Ignore changes in the AMI which force recreation of the resource. This
Expand All @@ -85,7 +85,7 @@ resource "aws_instance" "master" {
}

tags = "${merge(map(
"Name", "${var.cluster_name}-master-${count.index}",
"Name", "${var.cluster_name}-${var.machine_pool_name}-${count.index}",
"clusterid", "${var.cluster_name}"
), var.tags)}"

Expand All @@ -96,13 +96,13 @@ resource "aws_instance" "master" {
}

volume_tags = "${merge(map(
"Name", "${var.cluster_name}-master-${count.index}-vol",
"Name", "${var.cluster_name}-${var.machine_pool_name}-${count.index}-vol",
), var.tags)}"
}

resource "aws_lb_target_group_attachment" "master" {
resource "aws_lb_target_group_attachment" "control_plane" {
count = "${var.instance_count * var.target_group_arns_length}"

target_group_arn = "${var.target_group_arns[count.index % var.target_group_arns_length]}"
target_id = "${aws_instance.master.*.private_ip[count.index / var.target_group_arns_length]}"
target_id = "${aws_instance.control_plane.*.private_ip[count.index / var.target_group_arns_length]}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ output "cluster_id" {
}

output "ip_addresses" {
value = "${aws_instance.master.*.private_ip}"
value = "${aws_instance.control_plane.*.private_ip}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ variable "kubeconfig_content" {
default = ""
}

variable "master_sg_ids" {
variable "machine_pool_name" {
type = "string"
}

variable "control_plane_sg_ids" {
type = "list"
description = "The security group IDs to be applied to the master nodes."
description = "The security group IDs to be applied to the control plane nodes."
}

variable "root_volume_iops" {
Expand Down
16 changes: 8 additions & 8 deletions data/data/aws/iam/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ locals {
arn = "aws"
}

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

role = "${aws_iam_role.worker_role.name}"
role = "${aws_iam_role.compute_role.name}"
}

resource "aws_iam_role" "worker_role" {
name = "${var.cluster_name}-worker-role"
resource "aws_iam_role" "compute_role" {
name = "${var.cluster_name}-compute-role"
path = "/"

assume_role_policy = <<EOF
Expand All @@ -31,9 +31,9 @@ EOF
tags = "${var.tags}"
}

resource "aws_iam_role_policy" "worker_policy" {
name = "${var.cluster_name}_worker_policy"
role = "${aws_iam_role.worker_role.id}"
resource "aws_iam_role_policy" "compute_policy" {
name = "${var.cluster_name}_compute_policy"
role = "${aws_iam_role.compute_role.id}"

policy = <<EOF
{
Expand Down
26 changes: 13 additions & 13 deletions data/data/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,35 @@ module "bootstrap" {
target_group_arns = "${module.vpc.aws_lb_target_group_arns}"
target_group_arns_length = "${module.vpc.aws_lb_target_group_arns_length}"
vpc_id = "${module.vpc.vpc_id}"
vpc_security_group_ids = "${list(module.vpc.master_sg_id)}"
vpc_security_group_ids = "${list(module.vpc.control_plane_sg_id)}"

tags = "${merge(map(
"Name", "${var.cluster_name}-bootstrap",
), local.tags)}"
}

module "masters" {
source = "./master"
module "controlplane" {
source = "./controlplane"

cluster_id = "${var.cluster_id}"
cluster_name = "${var.cluster_name}"
ec2_type = "${var.aws_master_ec2_type}"
ec2_type = "${var.aws_control_plane_ec2_type}"

tags = "${merge(map(
"kubernetes.io/cluster/${var.cluster_name}", "owned",
), local.tags)}"

instance_count = "${var.master_count}"
master_sg_ids = "${list(module.vpc.master_sg_id)}"
root_volume_iops = "${var.aws_master_root_volume_iops}"
root_volume_size = "${var.aws_master_root_volume_size}"
root_volume_type = "${var.aws_master_root_volume_type}"
instance_count = "${var.control_plane_count}"
machine_pool_name = "${var.control_plane_machine_pool_name}"
control_plane_sg_ids = "${list(module.vpc.control_plane_sg_id)}"
root_volume_iops = "${var.aws_control_plane_root_volume_iops}"
root_volume_size = "${var.aws_control_plane_root_volume_size}"
root_volume_type = "${var.aws_control_plane_root_volume_type}"
subnet_ids = "${module.vpc.private_subnet_ids}"
target_group_arns = "${module.vpc.aws_lb_target_group_arns}"
target_group_arns_length = "${module.vpc.aws_lb_target_group_arns_length}"
ec2_ami = "${var.aws_ec2_ami_override}"
user_data_ign = "${var.ignition_master}"
user_data_ign = "${var.ignition_control_plane}"
}

module "iam" {
Expand All @@ -69,7 +70,6 @@ module "dns" {
api_internal_lb_zone_id = "${module.vpc.aws_lb_api_internal_zone_id}"
base_domain = "${var.base_domain}"
cluster_name = "${var.cluster_name}"
master_count = "${var.master_count}"
private_zone_id = "${local.private_zone_id}"
}

Expand All @@ -88,12 +88,12 @@ module "vpc" {
}

resource "aws_route53_record" "etcd_a_nodes" {
count = "${var.master_count}"
count = "${var.control_plane_count}"
type = "A"
ttl = "60"
zone_id = "${local.private_zone_id}"
name = "${var.cluster_name}-etcd-${count.index}"
records = ["${module.masters.ip_addresses[count.index]}"]
records = ["${module.controlplane.ip_addresses[count.index]}"]
}

resource "aws_route53_record" "etcd_cluster" {
Expand Down
17 changes: 0 additions & 17 deletions data/data/aws/route53/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,6 @@ variable "base_domain" {
type = "string"
}

variable "master_count" {
description = "The number of masters"
type = "string"
}

variable "master_ip_addresses" {
description = "List of string IPs for masters"
type = "list"
default = []
}

variable "worker_ip_addresses" {
description = "List of string IPs for workers"
type = "list"
default = []
}

// AWS specific internal zone variables

variable "private_zone_id" {
Expand Down
16 changes: 8 additions & 8 deletions data/data/aws/variables-aws.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ EOF
default = "1.0"
}

variable "aws_master_ec2_type" {
variable "aws_control_plane_ec2_type" {
type = "string"
description = "Instance size for the master node(s). Example: `m4.large`."
description = "Instance size for the control plane node(s). Example: `m4.large`."
}

variable "aws_ec2_ami_override" {
Expand All @@ -30,21 +30,21 @@ EOF
default = {}
}

variable "aws_master_root_volume_type" {
variable "aws_control_plane_root_volume_type" {
type = "string"
description = "The type of volume for the root block device of master nodes."
description = "The type of volume for the root block device of control plane nodes."
}

variable "aws_master_root_volume_size" {
variable "aws_control_plane_root_volume_size" {
type = "string"
description = "The size of the volume in gigabytes for the root block device of master nodes."
description = "The size of the volume in gigabytes for the root block device of control plane nodes."
}

variable "aws_master_root_volume_iops" {
variable "aws_control_plane_root_volume_iops" {
type = "string"

description = <<EOF
The amount of provisioned IOPS for the root block device of master nodes.
The amount of provisioned IOPS for the root block device of control plane nodes.
Ignored if the volume type is not io1.
EOF
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ resource "aws_lb_listener" "api_internal_services" {
}

resource "aws_lb_listener" "api_external_api" {
count = "${var.public_master_endpoints ? 1 : 0}"

load_balancer_arn = "${aws_lb.api_external.arn}"
protocol = "TCP"
port = "6443"
Expand Down
8 changes: 2 additions & 6 deletions data/data/aws/vpc/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ output "private_subnet_ids" {
value = "${local.private_subnet_ids}"
}

output "master_sg_id" {
value = "${aws_security_group.master.id}"
}

output "worker_sg_id" {
value = "${aws_security_group.worker.id}"
output "control_plane_sg_id" {
value = "${aws_security_group.control_plane.id}"
}

output "api_sg_id" {
Expand Down
Loading