Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single AZ Support #93

Merged
merged 4 commits into from
Apr 27, 2022
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
8 changes: 6 additions & 2 deletions eks-service-definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ provision:
required: false
type: array
details: "A list of the desired AWS Compute types that the nodes will be launched with (e.g. [\"m5.large\"])"
- field_name: single_az
required: false
type: boolean
details: "Specify whether the managed node group should span only a single availability zone"

computed_inputs:
- name: instance_name
Expand Down Expand Up @@ -89,9 +93,9 @@ provision:
type: array
default: ["m5.large"]
overwrite: true
- name: install_vpc_cni
- name: single_az
type: boolean
default: true
default: false
overwrite: true

outputs:
Expand Down
9 changes: 5 additions & 4 deletions terraform/modules/provision-aws/eks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ module "eks" {
launch_template_name = "${local.cluster_name}-lt"
name = "${local.cluster_name}"
ami_id = data.aws_ami.gsa-ise.id
subnet_ids = var.single_az ? [module.vpc.private_subnets[0]] : module.vpc.private_subnets

enable_bootstrap_user_data = true
bootstrap_extra_args = "--container-runtime dockerd"
Expand Down Expand Up @@ -309,10 +310,10 @@ data "template_file" "kubeconfig" {

resource "local_sensitive_file" "kubeconfig" {
# Only create the file if requested; it's not needed by provisioners
count = var.write_kubeconfig ? 1 : 0
content = data.template_file.kubeconfig.rendered
filename = local.kubeconfig_name
file_permission = "0600"
count = var.write_kubeconfig ? 1 : 0
content = data.template_file.kubeconfig.rendered
filename = local.kubeconfig_name
file_permission = "0600"
}


Expand Down
5 changes: 5 additions & 0 deletions terraform/modules/provision-aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ variable "write_kubeconfig" {
type = bool
default = false
}

variable "single_az" {
type = bool
default = false
}
18 changes: 18 additions & 0 deletions terraform/modules/provision-k8s/k8s-persistent-storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,22 @@ resource "kubernetes_storage_class" "ebs-sc" {
# https://docs.aws.amazon.com/eks/latest/userguide/storage-classes.html
storage_provisioner = "kubernetes.io/aws-ebs"
allow_volume_expansion = true

# Ensure volumes are created in the correct topology (specifically availability zone)
# https://kubernetes.io/docs/concepts/storage/storage-classes/#volume-binding-mode
volume_binding_mode = "WaitForFirstConsumer"

# The following code uses an optional nested block to define EBS volume parameters
# References:
# - https://codeinthehole.com/tips/conditional-nested-blocks-in-terraform/
# - https://medium.com/@business_99069/terraform-0-12-conditional-block-7d166e4abcbf
allowed_topologies {
dynamic "match_label_expressions" {
for_each = var.single_az ? [1] : []
content {
key = "topology.ebs.csi.aws.com/zone"
values = ["${var.region}a"]
}
}
}
}