From ad88560061801adccd3a70524deda38a1258112e Mon Sep 17 00:00:00 2001 From: benbierens Date: Mon, 6 Nov 2023 16:38:32 +0100 Subject: [PATCH] Creates internal service ports for external ports from container recipe. --- Framework/KubernetesWorkflow/K8sController.cs | 2 +- Framework/KubernetesWorkflow/RunningContainers.cs | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Framework/KubernetesWorkflow/K8sController.cs b/Framework/KubernetesWorkflow/K8sController.cs index a642eef..9e74a6c 100644 --- a/Framework/KubernetesWorkflow/K8sController.cs +++ b/Framework/KubernetesWorkflow/K8sController.cs @@ -647,7 +647,7 @@ namespace KubernetesWorkflow private RunningService? CreateInternalService(ContainerRecipe[] recipes) { - return CreateService(recipes, r => r.InternalPorts, "ClusterIP", "int"); + return CreateService(recipes, r => r.InternalPorts.Concat(r.ExposedPorts).ToArray(), "ClusterIP", "int"); } private RunningService? CreateExternalService(ContainerRecipe[] recipes) diff --git a/Framework/KubernetesWorkflow/RunningContainers.cs b/Framework/KubernetesWorkflow/RunningContainers.cs index 27653f8..f49f1af 100644 --- a/Framework/KubernetesWorkflow/RunningContainers.cs +++ b/Framework/KubernetesWorkflow/RunningContainers.cs @@ -48,13 +48,18 @@ namespace KubernetesWorkflow public Address GetAddress(string portTag) { - var containerAddress = Addresses.Single(a => a.PortTag == portTag); - if (containerAddress.IsInteral && RunningContainers.StartResult.RunnerLocation == RunnerLocation.ExternalToCluster) + var addresses = Addresses.Where(a => a.PortTag == portTag).ToArray(); + if (!addresses.Any()) throw new Exception("No addresses found for portTag: " + portTag); + + var location = RunningContainers.StartResult.RunnerLocation; + if (location == RunnerLocation.InternalToCluster) { - throw new Exception("Attempt to access a container address created from an Internal port, " + - "while runner is located external to the cluster."); + return addresses.Single(a => a.IsInteral).Address; + } + else + { + return addresses.Single(a => !a.IsInteral).Address; } - return containerAddress.Address; } public Address GetInternalAddress(string portTag)