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)
|
public Address GetInternalAddress(string portTag)
|
||||||
{
|
{
|
||||||
var containerAddress = Addresses.Single(a => a.PortTag == portTag);
|
var containerAddress = Addresses.Single(a => a.PortTag == portTag && a.IsInteral);
|
||||||
if (!containerAddress.IsInteral) throw new Exception(portTag + " refers to an external port");
|
|
||||||
return containerAddress.Address;
|
return containerAddress.Address;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace KubernetesWorkflow
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
internal RunnerLocation RunnerLocation { get; set; }
|
internal RunnerLocation RunnerLocation { get; set; }
|
||||||
|
|
||||||
public Port GetServicePorts(ContainerRecipe recipe, string tag)
|
public Port GetInternalServicePorts(ContainerRecipe recipe, string tag)
|
||||||
{
|
{
|
||||||
if (InternalService != null)
|
if (InternalService != null)
|
||||||
{
|
{
|
||||||
|
@ -37,13 +37,18 @@ namespace KubernetesWorkflow
|
||||||
if (p != null) return p;
|
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)
|
if (ExternalService != null)
|
||||||
{
|
{
|
||||||
var p = ExternalService.GetServicePortForRecipeAndTag(recipe, tag);
|
var p = ExternalService.GetServicePortForRecipeAndTag(recipe, tag);
|
||||||
if (p != null) return p;
|
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)
|
public Port[] GetServicePortsForContainer(ContainerRecipe recipe)
|
||||||
|
|
|
@ -151,6 +151,7 @@ namespace KubernetesWorkflow
|
||||||
foreach (var exposedPort in recipe.ExposedPorts)
|
foreach (var exposedPort in recipe.ExposedPorts)
|
||||||
{
|
{
|
||||||
result.Add(new ContainerAddress(exposedPort.Tag, GetContainerExternalAddress(startResult, recipe, exposedPort.Tag), false));
|
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)
|
foreach (var internalPort in recipe.InternalPorts)
|
||||||
{
|
{
|
||||||
|
@ -162,7 +163,7 @@ namespace KubernetesWorkflow
|
||||||
|
|
||||||
private static Address GetContainerExternalAddress(StartResult startResult, ContainerRecipe recipe, string tag)
|
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(
|
return new Address(
|
||||||
startResult.Cluster.HostAddress,
|
startResult.Cluster.HostAddress,
|
||||||
|
@ -172,7 +173,7 @@ namespace KubernetesWorkflow
|
||||||
private Address GetContainerInternalAddress(StartResult startResult, ContainerRecipe recipe, string tag)
|
private Address GetContainerInternalAddress(StartResult startResult, ContainerRecipe recipe, string tag)
|
||||||
{
|
{
|
||||||
var serviceName = startResult.InternalService!.Name;
|
var serviceName = startResult.InternalService!.Name;
|
||||||
var port = startResult.GetServicePorts(recipe, tag);
|
var port = startResult.GetInternalServicePorts(recipe, tag);
|
||||||
return new Address(
|
return new Address(
|
||||||
$"http://{serviceName}",
|
$"http://{serviceName}",
|
||||||
port.Number);
|
port.Number);
|
||||||
|
|
Loading…
Reference in New Issue