diff --git a/nullplatform/container_orchestration/eks/main.tf b/nullplatform/container_orchestration/eks/main.tf index 6a3842cac..cb3747b30 100644 --- a/nullplatform/container_orchestration/eks/main.tf +++ b/nullplatform/container_orchestration/eks/main.tf @@ -33,6 +33,11 @@ locals { var.service_account_name != "" ? { service_account_name = var.service_account_name } : {}, ) + traffic_manager = merge( + var.traffic_manager_version != "" ? { version = var.traffic_manager_version } : {}, + var.traffic_manager_port != null ? { port = var.traffic_manager_port } : {}, + ) + attributes = merge( { cluster = local.cluster @@ -41,7 +46,7 @@ locals { length(local.network) > 0 ? { network = local.network } : {}, length(local.resource_management) > 0 ? { resource_management = local.resource_management } : {}, length(local.security) > 0 ? { security = local.security } : {}, - var.traffic_manager_version != "" ? { traffic_manager = { version = var.traffic_manager_version } } : {}, + length(local.traffic_manager) > 0 ? { traffic_manager = local.traffic_manager } : {}, length(var.object_modifiers) > 0 ? { object_modifiers = { modifiers = var.object_modifiers } } : {}, ) } diff --git a/nullplatform/container_orchestration/eks/tests/eks.tftest.hcl b/nullplatform/container_orchestration/eks/tests/eks.tftest.hcl index 681d1b40f..fb53d0ae5 100644 --- a/nullplatform/container_orchestration/eks/tests/eks.tftest.hcl +++ b/nullplatform/container_orchestration/eks/tests/eks.tftest.hcl @@ -196,6 +196,29 @@ run "with_traffic_manager" { condition = strcontains(nullplatform_provider_config.eks_config.attributes, "latest") error_message = "Attributes should contain traffic manager version" } + + assert { + condition = !strcontains(nullplatform_provider_config.eks_config.attributes, "\"port\"") + error_message = "Attributes should not contain traffic manager port when not set" + } +} + +run "with_traffic_manager_port" { + command = plan + + variables { + traffic_manager_port = 10080 + } + + assert { + condition = strcontains(nullplatform_provider_config.eks_config.attributes, "\"port\":10080") + error_message = "Attributes should contain the traffic manager port" + } + + assert { + condition = strcontains(nullplatform_provider_config.eks_config.attributes, "\"version\":\"latest\"") + error_message = "Setting the port must not drop the traffic manager version" + } } run "with_object_modifiers" { diff --git a/nullplatform/container_orchestration/eks/variables.tf b/nullplatform/container_orchestration/eks/variables.tf index 61934b2c7..4ac57957b 100644 --- a/nullplatform/container_orchestration/eks/variables.tf +++ b/nullplatform/container_orchestration/eks/variables.tf @@ -117,6 +117,17 @@ variable "traffic_manager_version" { default = "latest" } +variable "traffic_manager_port" { + description = "Port the traffic manager sidecar binds inside the pod. Defaults to 80 when unset. Set a different port (10080 recommended) when the cluster does not allow pod-to-pod traffic on port 80, which surfaces as a healthy pod that receives no traffic because kubelet probes are node-local and bypass the filtering. Open the port for pod-to-pod traffic before setting this value" + type = number + default = null + nullable = true + validation { + condition = var.traffic_manager_port == null || (var.traffic_manager_port >= 1 && var.traffic_manager_port <= 65535) + error_message = "traffic_manager_port must be between 1 and 65535." + } +} + variable "object_modifiers" { description = "List of modifications to dynamically modify k8s objects" type = list(object({