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 support for t-shirt-sized deployments #153

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
48 changes: 41 additions & 7 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,39 @@ module "file_storage" {
locals {
bucket_name = local.use_external_bucket ? var.bucket_name : module.file_storage.0.bucket_name
bucket_queue_name = local.use_internal_queue ? null : module.file_storage.0.bucket_queue_name

deployment_size = {
small = {
db = "r6g.large",
node_count = 2,
node_instance = "r6g.large"
cache = "cache.m6g.large"
},
medium = {
db = "r6g.xlarge",
node_count = 2,
node_instance = "r6g.xlarge"
cache = "cache.m6g.large"
},
large = {
db = "r6g.2xlarge",
node_count = 2,
node_instance = "r6g.2xlarge"
cache = "cache.m6g.xlarge"
},
xlarge = {
db = "r6g.4xlarge",
node_count = 3,
node_instance = "r6g.4xlarge"
cache = "cache.m6g.xlarge"
},
xxlarge = {
db = "r6g.8xlarge",
node_count = 3,
node_instance = "r6g.8xlarge"
cache = "cache.m6g.2xlarge"
}
}
}

module "networking" {
Expand Down Expand Up @@ -69,7 +102,7 @@ module "database" {
database_name = var.database_name
master_username = var.database_master_username

instance_class = var.database_instance_class
instance_class = coalesce(try(local.deployment_size[var.size].db, null), var.database_instance_class)
engine_version = var.database_engine_version
snapshot_identifier = var.database_snapshot_identifier
sort_buffer_size = var.database_sort_buffer_size
Expand Down Expand Up @@ -121,10 +154,11 @@ module "app_eks" {
namespace = var.namespace
kms_key_arn = local.kms_key_arn

instance_types = var.kubernetes_instance_types
map_accounts = var.kubernetes_map_accounts
map_roles = var.kubernetes_map_roles
map_users = var.kubernetes_map_users
instance_types = coalesce(try([local.deployment_size[var.size].node_instance], null), var.kubernetes_instance_types.0)
desired_capacity = coalesce(try(local.deployment_size[var.size].node_count, null), var.kubernetes_node_count)
map_accounts = var.kubernetes_map_accounts
map_roles = var.kubernetes_map_roles
map_users = var.kubernetes_map_users

bucket_kms_key_arn = local.use_external_bucket ? var.bucket_kms_key_arn : local.kms_key_arn
bucket_arn = data.aws_s3_bucket.file_storage.arn
Expand Down Expand Up @@ -179,8 +213,7 @@ module "redis" {
vpc_id = local.network_id
redis_subnet_group_name = local.network_elasticache_subnet_group_name
vpc_subnets_cidr_blocks = module.networking.elasticache_subnet_cidrs
node_type = var.elasticache_node_type

node_type = coalesce(try(local.deployment_size[var.size].cache, null), var.elasticache_node_type)
kms_key_arn = local.kms_key_arn
}

Expand Down Expand Up @@ -267,3 +300,4 @@ module "wandb" {
}
}
}

6 changes: 6 additions & 0 deletions modules/app_eks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,9 @@ variable "service_port" {
type = number
default = 32543
}

variable "desired_capacity" {
description = "Desired number of worker nodes."
type = number
default = 2
}
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ variable "use_internal_queue" {
default = false
}

variable "size" {
type = string
description = "T-shirt size for deployment"
default = "small"
}

##########################################
# Database #
##########################################
Expand Down Expand Up @@ -301,6 +307,12 @@ variable "kubernetes_instance_types" {
default = ["m5.large"]
}

variable "kubernetes_node_count" {
description = "Number of nodes"
type = number
default = 2
}

variable "eks_policy_arns" {
type = list(string)
description = "Additional IAM policy to apply to the EKS cluster"
Expand Down
Loading