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

feat: add gp3/io2 support for etcd and master nodes #106

Merged
2 changes: 1 addition & 1 deletion examples/aws-eks-distro/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {

provider "aws" {
region = var.aws_region
version = "~>3.13.0"
version = "~>v3.29.0"
}

provider "external" {
Expand Down
2 changes: 1 addition & 1 deletion examples/etcd-cluster/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {

provider "aws" {
region = var.aws_region
version = "~>3.13.0"
version = "~>v3.29.0"
}

provider "external" {
Expand Down
2 changes: 1 addition & 1 deletion examples/iam-auth-and-irsa/example/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {

provider "aws" {
region = var.aws_region
version = "~>3.13.0"
version = "~>v3.29.0"
}

provider "local" {
Expand Down
2 changes: 1 addition & 1 deletion examples/iam-auth-and-irsa/k8s-cluster/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {

provider "aws" {
region = var.aws_region
version = "~>3.13.0"
version = "~>v3.29.0"
}

provider "external" {
Expand Down
2 changes: 1 addition & 1 deletion examples/kubernetes-cluster/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {

provider "aws" {
region = var.aws_region
version = "~>3.13.0"
version = "~>v3.29.0"
}

provider "external" {
Expand Down
2 changes: 2 additions & 0 deletions modules/aws/elastikube/etcd.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module "etcd" {
instance_config = var.etcd_instance_config
containers = var.override_containers

instance_volume_config = var.etcd_instance_volume_config

subnet_ids = var.private_subnet_ids
master_security_group_id = module.master.master_sg_id
zone_id = aws_route53_zone.private.zone_id
Expand Down
27 changes: 27 additions & 0 deletions modules/aws/elastikube/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,33 @@ variable "etcd_instance_config" {
}
}

variable "etcd_instance_volume_config" {
type = object({
root = object({
type = string
iops = number
throughput = number
})
data = object({
type = string
iops = number
throughput = number
})
})
default = {
root = {
type = "gp2"
iops = 0
throughput = 0
}
data = {
type = "gp2"
iops = 0
throughput = 0
}
}
}

variable "ssh_key" {
description = "The key name that should be used for the instances."
type = string
Expand Down
28 changes: 28 additions & 0 deletions modules/aws/kube-etcd/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ locals {
client_port = 2379
peer_port = 2380
node_exporter_port = 9100

iops_by_type = {
root = {
"gp3": max(3000, var.instance_volume_config.root.iops),
"io1": max(100, var.instance_volume_config.root.iops),
"io2": max(100, var.instance_volume_config.root.iops),
}
data = {
"gp3": max(3000, var.instance_volume_config.data.iops),
"io1": max(100, var.instance_volume_config.data.iops),
"io2": max(100, var.instance_volume_config.data.iops),
}
}
throughput_by_type = {
root = {
"gp3": max(125, var.instance_volume_config.root.throughput),
}
data = {
"gp3": max(125, var.instance_volume_config.data.throughput),
}
}
}

data "aws_availability_zones" "available" {
Expand Down Expand Up @@ -35,6 +56,10 @@ resource "aws_ebs_volume" "etcd" {
count = var.instance_config["count"]
availability_zone = data.aws_subnet.etcd[count.index].availability_zone
size = var.instance_config["data_volume_size"]
type = var.instance_volume_config.data.type
iops = lookup(local.iops_by_type.data, var.instance_volume_config.data.type, null)
# aws_ebs_volume always checks the range of throughput.(125 ~ 1000)
throughput = lookup(local.throughput_by_type.data, var.instance_volume_config.data.type, null)

tags = merge(var.extra_tags, map(
"Name", "${var.name}-etcd-${count.index}",
Expand Down Expand Up @@ -67,6 +92,9 @@ resource "aws_instance" "etcd" {

root_block_device {
volume_size = var.instance_config["root_volume_size"]
volume_type = var.instance_volume_config.root.type
iops = lookup(local.iops_by_type.root, var.instance_volume_config.root.type, null)
throughput = lookup(local.throughput_by_type.root, var.instance_volume_config.root.type, null)
}

volume_tags = merge(var.extra_tags, map(
Expand Down
28 changes: 28 additions & 0 deletions modules/aws/kube-etcd/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,34 @@ variable "instance_config" {
})
}

variable "instance_volume_config" {
type = object({
root = object({
type = string
iops = number
throughput = number
})
data = object({
type = string
iops = number
throughput = number
})
})

default = {
root = {
type = "gp2"
iops = 0
throughput = 0
}
data = {
type = "gp2"
iops = 0
throughput = 0
}
}
}

variable "ssh_key" {
description = "The key name that should be used for the instances."
type = string
Expand Down
16 changes: 15 additions & 1 deletion modules/aws/kube-master/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ locals {

extra_tags_keys = keys(var.extra_tags)
extra_tags_values = values(var.extra_tags)

iops_by_type = {
root = {
"gp3": max(3000, var.instance_config["root_volume_iops"]),
"io1": max(100, var.instance_config["root_volume_iops"]),
"io2": max(100, var.instance_config["root_volume_iops"]),
}
}
throughput_by_type = {
root = {
"gp3": 125,
}
}
}

data "aws_subnet" "subnet" {
Expand Down Expand Up @@ -87,7 +100,8 @@ resource "aws_launch_template" "master" {
ebs {
volume_type = var.instance_config["root_volume_type"]
volume_size = var.instance_config["root_volume_size"]
iops = var.instance_config["root_volume_type"] == "io1" ? var.instance_config["root_volume_iops"] : var.instance_config["root_volume_type"] == "gp2" ? 0 : min(10000, max(100, 3 * var.instance_config["root_volume_size"]))
iops = lookup(local.iops_by_type.root, var.instance_config["root_volume_type"], null)
throughput = lookup(local.throughput_by_type.root, var.instance_config["root_volume_type"], null)
}
}

Expand Down