Get ports explicitly for internal or external endpoints
This commit is contained in:
parent
ad88560061
commit
1412dd84fe
|
@ -64,8 +64,7 @@ namespace KubernetesWorkflow
|
|||
|
||||
public Address GetInternalAddress(string portTag)
|
||||
{
|
||||
var containerAddress = Addresses.Single(a => a.PortTag == portTag);
|
||||
if (!containerAddress.IsInteral) throw new Exception(portTag + " refers to an external port");
|
||||
var containerAddress = Addresses.Single(a => a.PortTag == portTag && a.IsInteral);
|
||||
return containerAddress.Address;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace KubernetesWorkflow
|
|||
[JsonIgnore]
|
||||
internal RunnerLocation RunnerLocation { get; set; }
|
||||
|
||||
public Port GetServicePorts(ContainerRecipe recipe, string tag)
|
||||
public Port GetInternalServicePorts(ContainerRecipe recipe, string tag)
|
||||
{
|
||||
if (InternalService != null)
|
||||
{
|
||||
|
@ -37,13 +37,18 @@ namespace KubernetesWorkflow
|
|||
if (p != null) return p;
|
||||
}
|
||||
|
||||
throw new Exception($"Unable to find internal port by tag '{tag}' for recipe '{recipe.Name}'.");
|
||||
}
|
||||
|
||||
public Port GetExternalServicePorts(ContainerRecipe recipe, string tag)
|
||||
{
|
||||
if (ExternalService != null)
|
||||
{
|
||||
var p = ExternalService.GetServicePortForRecipeAndTag(recipe, tag);
|
||||
if (p != null) return p;
|
||||
}
|
||||
|
||||
throw new Exception($"Unable to find port by tag '{tag}' for recipe '{recipe.Name}'.");
|
||||
throw new Exception($"Unable to find external port by tag '{tag}' for recipe '{recipe.Name}'.");
|
||||
}
|
||||
|
||||
public Port[] GetServicePortsForContainer(ContainerRecipe recipe)
|
||||
|
|
|
@ -151,6 +151,7 @@ namespace KubernetesWorkflow
|
|||
foreach (var exposedPort in recipe.ExposedPorts)
|
||||
{
|
||||
result.Add(new ContainerAddress(exposedPort.Tag, GetContainerExternalAddress(startResult, recipe, exposedPort.Tag), false));
|
||||
result.Add(new ContainerAddress(exposedPort.Tag, GetContainerInternalAddress(startResult, recipe, exposedPort.Tag), true));
|
||||
}
|
||||
foreach (var internalPort in recipe.InternalPorts)
|
||||
{
|
||||
|
@ -162,7 +163,7 @@ namespace KubernetesWorkflow
|
|||
|
||||
private static Address GetContainerExternalAddress(StartResult startResult, ContainerRecipe recipe, string tag)
|
||||
{
|
||||
var port = startResult.GetServicePorts(recipe, tag);
|
||||
var port = startResult.GetExternalServicePorts(recipe, tag);
|
||||
|
||||
return new Address(
|
||||
startResult.Cluster.HostAddress,
|
||||
|
@ -172,7 +173,7 @@ namespace KubernetesWorkflow
|
|||
private Address GetContainerInternalAddress(StartResult startResult, ContainerRecipe recipe, string tag)
|
||||
{
|
||||
var serviceName = startResult.InternalService!.Name;
|
||||
var port = startResult.GetServicePorts(recipe, tag);
|
||||
var port = startResult.GetInternalServicePorts(recipe, tag);
|
||||
return new Address(
|
||||
$"http://{serviceName}",
|
||||
port.Number);
|
||||
|
|
Loading…
Reference in New Issue