Skip to content

Commit

Permalink
platform/aws: add bootstrap node and step for joining it (#2924)
Browse files Browse the repository at this point in the history
  • Loading branch information
enxebre authored and mxinden committed Feb 27, 2018
1 parent 6a41c28 commit e5c8b41
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 2 deletions.
15 changes: 15 additions & 0 deletions modules/aws/master-asg/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output "aws_launch_configuration" {
value = "${aws_launch_configuration.master_conf.id}"
}

output "subnet_ids" {
value = "${var.subnet_ids}"
}

output "aws_lbs" {
value = "${var.aws_lbs}"
}

output "cluster_id" {
value = "${var.cluster_id}"
}
15 changes: 15 additions & 0 deletions modules/aws/worker-asg/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output "aws_launch_configuration" {
value = "${aws_launch_configuration.worker_conf.id}"
}

output "subnet_ids" {
value = "${var.subnet_ids}"
}

output "aws_lbs" {
value = "${var.load_balancers}"
}

output "cluster_id" {
value = "${var.cluster_id}"
}
4 changes: 2 additions & 2 deletions platforms/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ module "masters" {
ign_tectonic_path_unit_id = "${data.ignition_systemd_unit.tectonic_path_unit.id}"
ign_tectonic_service_id = "${data.ignition_systemd_unit.tectonic_service.id}"
ign_update_ca_certificates_dropin_id = "${module.ignition_masters.update_ca_certificates_dropin_id}"
instance_count = "${var.tectonic_master_count}"
instance_count = "1"
master_iam_role = "${var.tectonic_aws_master_iam_role_name}"
master_sg_ids = "${concat(var.tectonic_aws_master_extra_sg_ids, list(module.vpc.master_sg_id))}"
private_endpoints = "${var.tectonic_aws_private_endpoints}"
Expand Down Expand Up @@ -227,7 +227,7 @@ module "workers" {
ign_s3_puller_id = "${module.ignition_workers.s3_puller_id}"
ign_systemd_default_env_id = "${local.tectonic_http_proxy_enabled ? module.ignition_workers.systemd_default_env_id : ""}"
ign_update_ca_certificates_dropin_id = "${module.ignition_workers.update_ca_certificates_dropin_id}"
instance_count = "${var.tectonic_worker_count}"
instance_count = "0"
load_balancers = "${var.tectonic_aws_worker_load_balancers}"
root_volume_iops = "${var.tectonic_aws_worker_root_volume_iops}"
root_volume_size = "${var.tectonic_aws_worker_root_volume_size}"
Expand Down
33 changes: 33 additions & 0 deletions platforms/aws/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Masters
output "aws_launch_configuration_masters" {
value = "${module.masters.aws_launch_configuration}"
}

output "subnet_ids_masters" {
value = "${module.masters.subnet_ids}"
}

output "aws_lbs_masters" {
value = "${module.masters.aws_lbs}"
}

output "cluster_id_masters" {
value = "${module.masters.cluster_id}"
}

output "cluster_id" {
value = "${module.masters.cluster_id}"
}

# Workers
output "aws_launch_configuration_workers" {
value = "${module.workers.aws_launch_configuration}"
}

output "subnet_ids_workers" {
value = "${module.workers.subnet_ids}"
}

output "aws_lbs_workers" {
value = "${module.workers.aws_lbs}"
}
1 change: 1 addition & 0 deletions steps/joining/config.tf
17 changes: 17 additions & 0 deletions steps/joining/inputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// This could be encapsulated as a data source
data "terraform_remote_state" "bootstrap" {
backend = "local"

config {
path = "${path.module}/../../${var.tectonic_cluster_name}/bootstrap.tfstate"
}
}

locals {
aws_launch_configuration_masters = "${data.terraform_remote_state.bootstrap.aws_launch_configuration_masters}"
subnet_ids_masters = "${data.terraform_remote_state.bootstrap.subnet_ids_masters}"
aws_lbs_masters = "${data.terraform_remote_state.bootstrap.aws_lbs_masters}"
cluster_id = "${data.terraform_remote_state.bootstrap.cluster_id}"
aws_launch_configuration_workers = "${data.terraform_remote_state.bootstrap.aws_launch_configuration_workers}"
subnet_ids_workers = "${data.terraform_remote_state.bootstrap.subnet_ids_workers}"
}
39 changes: 39 additions & 0 deletions steps/joining/masters.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
provider "aws" {
region = "${var.tectonic_aws_region}"
profile = "${var.tectonic_aws_profile}"
version = "1.7.0"
}

resource "aws_autoscaling_group" "masters" {
name = "${var.tectonic_cluster_name}-masters"
desired_capacity = "${var.tectonic_master_count}"
max_size = "${var.tectonic_master_count * 3}"
min_size = "${var.tectonic_master_count}"
launch_configuration = "${local.aws_launch_configuration_masters}"
vpc_zone_identifier = ["${local.subnet_ids_masters}"]

load_balancers = ["${local.aws_lbs_masters}"]

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

lifecycle {
create_before_destroy = true
}
}
1 change: 1 addition & 0 deletions steps/joining/variables.tf
31 changes: 31 additions & 0 deletions steps/joining/workers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
resource "aws_autoscaling_group" "workers" {
name = "${var.tectonic_cluster_name}-workers"
desired_capacity = "${var.tectonic_worker_count}"
max_size = "${var.tectonic_worker_count * 3}"
min_size = "${var.tectonic_worker_count}"
launch_configuration = "${local.aws_launch_configuration_workers}"
vpc_zone_identifier = ["${local.subnet_ids_workers}"]

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

lifecycle {
create_before_destroy = true
}
}

0 comments on commit e5c8b41

Please sign in to comment.