diff --git a/Framework/KubernetesWorkflow/ContainerRecipe.cs b/Framework/KubernetesWorkflow/ContainerRecipe.cs index 6bac0ff..ed89d78 100644 --- a/Framework/KubernetesWorkflow/ContainerRecipe.cs +++ b/Framework/KubernetesWorkflow/ContainerRecipe.cs @@ -67,6 +67,12 @@ public int Number { get; } public string Tag { get; } + + public override string ToString() + { + if (string.IsNullOrEmpty(Tag)) return $"untagged-port={Number}"; + return $"{Tag}={Number}"; + } } public class EnvVar diff --git a/Framework/KubernetesWorkflow/K8sController.cs b/Framework/KubernetesWorkflow/K8sController.cs index 2cbb358..6a02950 100644 --- a/Framework/KubernetesWorkflow/K8sController.cs +++ b/Framework/KubernetesWorkflow/K8sController.cs @@ -572,10 +572,9 @@ namespace KubernetesWorkflow var readback = client.Run(c => c.ReadNamespacedService(serviceSpec.Metadata.Name, K8sNamespace)); foreach (var r in containerRecipes) { - if (r.ExposedPorts.Any()) + foreach (var port in r.ExposedPorts) { - var firstExposedPort = r.ExposedPorts.First(); - var portName = GetNameForPort(r, firstExposedPort); + var portName = GetNameForPort(r, port); var matchingServicePorts = readback.Spec.Ports.Where(p => p.Name == portName); if (matchingServicePorts.Any()) diff --git a/Framework/KubernetesWorkflow/RunningPod.cs b/Framework/KubernetesWorkflow/RunningPod.cs index f4282ba..1e139f3 100644 --- a/Framework/KubernetesWorkflow/RunningPod.cs +++ b/Framework/KubernetesWorkflow/RunningPod.cs @@ -19,12 +19,10 @@ public Port[] GetServicePortsForContainerRecipe(ContainerRecipe containerRecipe) { - if (PortMapEntries.Any(p => p.ContainerNumber == containerRecipe.Number)) - { - return PortMapEntries.Single(p => p.ContainerNumber == containerRecipe.Number).Ports; - } - - return Array.Empty(); + return PortMapEntries + .Where(p => p.ContainerNumber == containerRecipe.Number) + .SelectMany(p => p.Ports) + .ToArray(); } }