Skip to content

Commit

Permalink
Set variables and var names to be more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
dj-maisy committed Jan 21, 2025
1 parent 5d3861f commit fad570c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
18 changes: 9 additions & 9 deletions terraform/deployments/cluster-infrastructure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ locals {
secrets_prefix = "govuk"
monitoring_namespace = "monitoring"

main_managed_node_group = {
main = {
x86_managed_node_group = {
x86 = {
name_prefix = var.cluster_name
# TODO: set iam_role_permissions_boundary
# TODO: apply provider default_tags to instances; might need to set launch_template_tags.
desired_size = var.workers_size_desired
max_size = var.workers_size_max
min_size = var.workers_size_min
instance_types = var.workers_instance_types
desired_size = var.x86_workers_size_desired
max_size = var.x86_workers_size_max
min_size = var.x86_workers_size_min
instance_types = var.x86_workers_instance_types
update_config = { max_unavailable = 1 }
block_device_mappings = {
xvda = {
Expand Down Expand Up @@ -64,7 +64,7 @@ locals {
min_size = var.arm_workers_size_min
instance_types = var.arm_workers_instance_types
update_config = { max_unavailable = 1 }
block_device_mappings = local.main_managed_node_group.main.block_device_mappings
block_device_mappings = local.x86_managed_node_group.main.block_device_mappings
taints = {
arch = {
key = "arch"
Expand All @@ -79,7 +79,7 @@ locals {
}
}

eks_managed_node_groups = merge(local.main_managed_node_group, var.enable_arm_workers ? local.arm_managed_node_group : {})
eks_managed_node_groups = merge(var.enable_x86_workers ? local.x86_managed_node_group : {}, var.enable_arm_workers ? local.arm_managed_node_group : {})
}

provider "aws" {
Expand Down Expand Up @@ -193,7 +193,7 @@ module "eks" {

eks_managed_node_group_defaults = {
ami_type = "AL2023_x86_64_STANDARD"
capacity_type = var.workers_default_capacity_type
capacity_type = var.x86_workers_default_capacity_type
subnet_ids = [for s in aws_subnet.eks_private : s.id]
create_security_group = false
create_iam_role = false
Expand Down
16 changes: 11 additions & 5 deletions terraform/deployments/cluster-infrastructure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,31 +87,37 @@ variable "arm_workers_size_max" {
default = 12
}

variable "workers_instance_types" {
variable "enable_x86_workers" {
type = bool
description = "Whether to enable the x86/AMD64 Managed Node Group"
default = true
}

variable "x86_workers_instance_types" {
type = list(string)
description = "List of instance types for the managed node group, in order of preference. The second and subsequent preferences are only relevant when using spot instances."
default = ["r7i.large", "r7a.large", "m7i-flex.xlarge", "m6a.xlarge", "m6i.xlarge"]
}

variable "workers_default_capacity_type" {
variable "x86_workers_default_capacity_type" {
type = string
description = "Default capacity type for managed node groups: SPOT or ON_DEMAND."
default = "ON_DEMAND"
}

variable "workers_size_desired" {
variable "x86_workers_size_desired" {
type = number
description = "Desired capacity of managed node autoscale group."
default = 0
}

variable "workers_size_min" {
variable "x86_workers_size_min" {
type = number
description = "Min capacity of managed node autoscale group."
default = 0
}

variable "workers_size_max" {
variable "x86_workers_size_max" {
type = number
description = "Max capacity of managed node autoscale group."
default = 6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module "variable-set-integration" {
govuk_environment = "integration"
force_destroy = true
enable_arm_workers = true
enable_x86_workers = true

publishing_service_domain = "integration.publishing.service.gov.uk"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ module "variable-set-production" {
}

govuk_environment = "production"
enable_x86_workers = true

publishing_service_domain = "publishing.service.gov.uk"

workers_instance_types = ["m6i.8xlarge", "m6a.8xlarge"]
x86_workers_instance_types = ["m6i.8xlarge", "m6a.8xlarge"]

workers_size_desired = 6
workers_size_min = 3
workers_size_max = 12
x86_workers_size_desired = 6
x86_workers_size_min = 3
x86_workers_size_max = 12

frontend_memcached_node_type = "cache.r6g.large"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module "variable-set-staging" {

govuk_environment = "staging"
enable_arm_workers = true
enable_x86_workers = true

publishing_service_domain = "staging.publishing.service.gov.uk"

Expand Down

0 comments on commit fad570c

Please sign in to comment.