From fad570cc1eadbc3ee91888ce29bc7bb366ac4117 Mon Sep 17 00:00:00 2001 From: David Mays Date: Tue, 21 Jan 2025 16:24:46 +0000 Subject: [PATCH] Set variables and var names to be more consistent --- .../deployments/cluster-infrastructure/main.tf | 18 +++++++++--------- .../cluster-infrastructure/variables.tf | 16 +++++++++++----- .../tfc-configuration/variables-integration.tf | 1 + .../tfc-configuration/variables-production.tf | 9 +++++---- .../tfc-configuration/variables-staging.tf | 1 + 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/terraform/deployments/cluster-infrastructure/main.tf b/terraform/deployments/cluster-infrastructure/main.tf index 42e2ab862..7f1db2feb 100644 --- a/terraform/deployments/cluster-infrastructure/main.tf +++ b/terraform/deployments/cluster-infrastructure/main.tf @@ -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 = { @@ -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" @@ -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" { @@ -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 diff --git a/terraform/deployments/cluster-infrastructure/variables.tf b/terraform/deployments/cluster-infrastructure/variables.tf index 980f7131b..66f2e0e57 100644 --- a/terraform/deployments/cluster-infrastructure/variables.tf +++ b/terraform/deployments/cluster-infrastructure/variables.tf @@ -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 diff --git a/terraform/deployments/tfc-configuration/variables-integration.tf b/terraform/deployments/tfc-configuration/variables-integration.tf index 27aec474f..1185b99d4 100644 --- a/terraform/deployments/tfc-configuration/variables-integration.tf +++ b/terraform/deployments/tfc-configuration/variables-integration.tf @@ -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" diff --git a/terraform/deployments/tfc-configuration/variables-production.tf b/terraform/deployments/tfc-configuration/variables-production.tf index 17612a0d8..a37e25172 100644 --- a/terraform/deployments/tfc-configuration/variables-production.tf +++ b/terraform/deployments/tfc-configuration/variables-production.tf @@ -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" diff --git a/terraform/deployments/tfc-configuration/variables-staging.tf b/terraform/deployments/tfc-configuration/variables-staging.tf index 5ee25890f..4fa53d3ce 100644 --- a/terraform/deployments/tfc-configuration/variables-staging.tf +++ b/terraform/deployments/tfc-configuration/variables-staging.tf @@ -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"