Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #610 from alphagov/per-az-worker-count
Browse files Browse the repository at this point in the history
Tidy config around per-AZ worker counts
  • Loading branch information
Krenair authored Oct 7, 2019
2 parents afe6f39 + 0889347 commit 95f751a
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 27 deletions.
2 changes: 2 additions & 0 deletions hack/lint-terraform-values-output.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ set -eu
--var cluster_domain=x \
--var aws_account_role_arn=x \
--var eks_version=x \
--var minimum_workers_per_az_count=1 \
--var maximum_workers_per_az_count=3 \
)


Expand Down
23 changes: 12 additions & 11 deletions modules/gsp-cluster/main.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
module "k8s-cluster" {
source = "../k8s-cluster"
vpc_id = "${var.vpc_id}"
private_subnet_ids = ["${var.private_subnet_ids}"]
public_subnet_ids = ["${var.public_subnet_ids}"]
cluster_name = "${var.cluster_name}"
worker_count = "${var.worker_count}"
worker_instance_type = "${var.worker_instance_type}"
extra_workers_per_az_count = "${var.extra_workers_per_az_count}"
ci_worker_count = "${var.ci_worker_count}"
ci_worker_instance_type = "${var.ci_worker_instance_type}"
eks_version = "${var.eks_version}"
source = "../k8s-cluster"
vpc_id = "${var.vpc_id}"
private_subnet_ids = ["${var.private_subnet_ids}"]
public_subnet_ids = ["${var.public_subnet_ids}"]
cluster_name = "${var.cluster_name}"
worker_count = "${var.worker_count}"
worker_instance_type = "${var.worker_instance_type}"
minimum_workers_per_az_count = "${var.minimum_workers_per_az_count}"
maximum_workers_per_az_count = "${var.maximum_workers_per_az_count}"
ci_worker_count = "${var.ci_worker_count}"
ci_worker_instance_type = "${var.ci_worker_instance_type}"
eks_version = "${var.eks_version}"

apiserver_allowed_cidrs = ["${concat(
formatlist("%s/32", var.egress_ips),
Expand Down
9 changes: 7 additions & 2 deletions modules/gsp-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ variable "worker_instance_type" {
default = "t3.medium"
}

variable "extra_workers_per_az_count" {
variable "minimum_workers_per_az_count" {
type = "string"
default = "0"
default = "1"
}

variable "maximum_workers_per_az_count" {
type = "string"
default = "5"
}

variable "ci_worker_count" {
Expand Down
6 changes: 3 additions & 3 deletions modules/k8s-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ resource "aws_cloudformation_stack" "worker-nodes-per-az" {
ClusterControlPlaneSecurityGroup = "${aws_security_group.controller.id}"
NodeGroupName = "worker-${element(data.aws_subnet.private_subnets.*.availability_zone, count.index)}"

NodeAutoScalingGroupMinSize = "${var.extra_workers_per_az_count}" # "${var.worker_count / 3}"
NodeAutoScalingGroupDesiredCapacity = "${var.extra_workers_per_az_count}" # "${var.worker_count / 3}"
NodeAutoScalingGroupMaxSize = "${var.extra_workers_per_az_count + 2}" # "${var.worker_count / 3 + 2}"
NodeAutoScalingGroupMinSize = "${var.minimum_workers_per_az_count}"
NodeAutoScalingGroupDesiredCapacity = "${var.minimum_workers_per_az_count}"
NodeAutoScalingGroupMaxSize = "${var.maximum_workers_per_az_count}"

NodeInstanceType = "${var.worker_instance_type}"
NodeInstanceProfile = "${aws_cloudformation_stack.worker-nodes.outputs["NodeInstanceProfile"]}"
Expand Down
9 changes: 7 additions & 2 deletions modules/k8s-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ variable "worker_count" {
default = "3"
}

variable "extra_workers_per_az_count" {
variable "minimum_workers_per_az_count" {
type = "string"
default = "0"
default = "1"
}

variable "maximum_workers_per_az_count" {
type = "string"
default = "5"
}

variable "ci_worker_instance_type" {
Expand Down
3 changes: 2 additions & 1 deletion pipelines/deployer/deployer.defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ disable-destroy: true
config-approvers: []
config-approval-count: 2

extra-workers-per-az-count: 0
minimum-workers-per-az-count: 1
maximum-workers-per-az-count: 5

task-toolbox-image: govsvc/task-toolbox
task-toolbox-tag: latest
Expand Down
19 changes: 12 additions & 7 deletions pipelines/deployer/deployer.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ variable "worker_count" {
default = "3"
}

variable "extra_workers_per_az_count" {
variable "minimum_workers_per_az_count" {
type = "string"
}

variable "maximum_workers_per_az_count" {
type = "string"
}

Expand Down Expand Up @@ -134,12 +138,13 @@ module "gsp-cluster" {
"3.8.110.67/32", # autom8 concourse
]

eks_version = "${var.eks_version}"
worker_instance_type = "${var.worker_instance_type}"
worker_count = "${var.worker_count}"
extra_workers_per_az_count = "${var.extra_workers_per_az_count}"
ci_worker_instance_type = "${var.ci_worker_instance_type}"
ci_worker_count = "${var.ci_worker_count}"
eks_version = "${var.eks_version}"
worker_instance_type = "${var.worker_instance_type}"
worker_count = "${var.worker_count}"
minimum_workers_per_az_count = "${var.minimum_workers_per_az_count}"
maximum_workers_per_az_count = "${var.maximum_workers_per_az_count}"
ci_worker_instance_type = "${var.ci_worker_instance_type}"
ci_worker_count = "${var.ci_worker_count}"

vpc_id = "${module.gsp-network.vpc_id}"
private_subnet_ids = "${module.gsp-network.private_subnet_ids}"
Expand Down
3 changes: 2 additions & 1 deletion pipelines/deployer/deployer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,8 @@ resources:
eks_version: ((eks-version))
worker_instance_type: ((worker-instance-type))
worker_count: ((worker-count))
extra_workers_per_az_count: ((extra-workers-per-az-count))
minimum_workers_per_az_count: ((minimum-workers-per-az-count))
maximum_workers_per_az_count: ((maximum-workers-per-az-count))
enable_nlb: ((enable-nlb))
ci_worker_instance_type: ((ci-worker-instance-type))
ci_worker_count: ((ci-worker-count))
Expand Down

0 comments on commit 95f751a

Please sign in to comment.