Skip to content

Commit

Permalink
feat: Add support for t-shirt-sized deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
Nigel Foucha committed May 23, 2024
1 parent 170e031 commit 84193a6
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 8 deletions.
59 changes: 54 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,50 @@ locals {
fqdn = var.subdomain == null ? var.domain_name : "${var.subdomain}.${var.domain_name}"
url_prefix = var.ssl ? "https" : "http"
url = "${local.url_prefix}://${local.fqdn}"

# Specifications for t-shirt sized deployments
deployment_size = {
small = {
db = "Standard_E2ds_v4",
node_count = 2,
node_instance = "Standard_E2s_v5",
cache_sku_name = "Standard",
cache_family = "C",
cache_capacity = 3,
},
medium = {
db = "Standard_E4ds_v4",
node_count = 2,
node_instance = "Standard_E4s_v5",
cache_sku_name = "Standard",
cache_family = "C",
cache_capacity = 3,
},
large = {
db = "Standard_E8ds_v4",
node_count = 2,
node_instance = "Standard_E8s_v5",
cache_sku_name = "Standard",
cache_family = "C",
cache_capacity = 4,
},
xlarge = {
db = "Standard_E16ds_v4",
node_count = 3,
node_instance = "Standard_E8s_v5",
cache_sku_name = "Standard",
cache_family = "C",
cache_capacity = 4,
},
xxlarge = {
db = "Standard_E32ds_v4",
node_count = 3,
node_instance = "Standard_E16s_v5",
cache_sku_name = "Standard",
cache_family = "C",
cache_capacity = 5,
}
}
}

resource "azurerm_resource_group" "default" {
Expand Down Expand Up @@ -39,8 +83,8 @@ module "database" {
database_private_dns_zone_id = module.networking.database_private_dns_zone.id
database_subnet_id = module.networking.database_subnet.id

sku_name = var.database_sku_name
deletion_protection = var.deletion_protection
sku_name = coalesce(try(local.deployment_size[var.size].db, null), var.database_sku_name)

tags = {
"customer-ns" = var.namespace,
Expand All @@ -56,6 +100,12 @@ module "redis" {
resource_group_name = azurerm_resource_group.default.name
location = azurerm_resource_group.default.location

# Use the t-shirt sized deployment specifications if size is defined;
# if not, use the value of the corresponding variable that may have been manually defined;
# use the default value if neither has been defined
sku_name = coalesce(try(local.deployment_size[var.size].cache_sku_name, null), var.redis_sku_name)
family = coalesce(try(local.deployment_size[var.size].cache_family, null), var.redis_family)
capacity = coalesce(try(local.deployment_size[var.size].cache_capacity, null), var.redis_capacity)
depends_on = [module.networking]
}

Expand Down Expand Up @@ -105,12 +155,11 @@ module "app_aks" {
identity = module.identity.identity
location = azurerm_resource_group.default.location
namespace = var.namespace
node_pool_vm_count = var.kubernetes_node_count
node_pool_vm_size = var.kubernetes_instance_type
public_subnet = module.networking.public_subnet
resource_group = azurerm_resource_group.default

tags = var.tags
node_pool_vm_size = coalesce(try(local.deployment_size[var.size].node_instance, null), var.kubernetes_instance_type)
node_pool_vm_count = coalesce(try(local.deployment_size[var.size].node_count, null), var.kubernetes_node_count)
tags = var.tags
}

locals {
Expand Down
2 changes: 1 addition & 1 deletion modules/networking/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ resource "azurerm_subnet_network_security_group_association" "public" {
count = length(var.allowed_ip_ranges) > 0 ? 1 : 0
subnet_id = azurerm_subnet.public.id
network_security_group_id = azurerm_network_security_group.default.0.id
depends_on = [ azurerm_network_security_rule.default ]
depends_on = [azurerm_network_security_rule.default]
}
2 changes: 1 addition & 1 deletion modules/networking/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ variable "tags" {

variable "allowed_ip_ranges" {
description = "allowed public IP addresses or CIDR ranges."
type = list(string)
type = list(string)
}
23 changes: 22 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,22 @@ variable "create_redis" {
default = false
}

variable "redis_sku_name" {
type = string
default = "Standard"
description = "Specifies the SKU Name for this Redis instance"
}

variable "redis_family" {
type = string
default = "C"
}

variable "redis_capacity" {
type = number
default = 2
}

##########################################
# External Bucket #
##########################################
Expand Down Expand Up @@ -188,7 +204,7 @@ variable "kubernetes_node_count" {
variable "allowed_ip_ranges" {
description = "allowed public IP addresses or CIDR ranges."
type = list(string)
default = []
default = []
}


Expand All @@ -210,3 +226,8 @@ variable "parquet_wandb_env" {
default = {}
}

variable "size" {
description = "Deployment size for the instance"
type = string
default = null
}

0 comments on commit 84193a6

Please sign in to comment.