trying with podIP for internal addresses.

This commit is contained in:
benbierens 2023-10-23 16:12:45 +02:00
parent b3ba39b2e5
commit eb70fe612b
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
2 changed files with 10 additions and 10 deletions

View File

@ -145,7 +145,7 @@ namespace KubernetesWorkflow
result.Add(new ContainerPort( result.Add(new ContainerPort(
exposedPort, exposedPort,
GetContainerExternalAddress(pod, servicePorts, exposedPort), GetContainerExternalAddress(pod, servicePorts, exposedPort),
GetContainerInternalAddress(exposedPort))); GetContainerInternalAddress(pod, exposedPort)));
} }
foreach (var internalPort in recipe.InternalPorts) foreach (var internalPort in recipe.InternalPorts)
{ {
@ -154,7 +154,7 @@ namespace KubernetesWorkflow
result.Add(new ContainerPort( result.Add(new ContainerPort(
internalPort, internalPort,
new Address(string.Empty, 0), new Address(string.Empty, 0),
GetContainerInternalAddress(internalPort))); GetContainerInternalAddress(pod, internalPort)));
} }
} }
@ -170,12 +170,15 @@ namespace KubernetesWorkflow
servicePort.Number); servicePort.Number);
} }
private Address GetContainerInternalAddress(Port port) private Address GetContainerInternalAddress(RunningPod pod, Port port)
{ {
var serviceName = "service-" + numberSource.WorkflowNumber; //var serviceName = "service-" + numberSource.WorkflowNumber;
//return new Address(
// $"http://{serviceName}.{k8sNamespace}.svc.cluster.local",
// port.Number);
return new Address( return new Address(
$"http://{serviceName}.{k8sNamespace}.svc.cluster.local", $"http://{pod.PodInfo.Ip}",
port.Number); port.Number);
} }

View File

@ -17,12 +17,9 @@ namespace CodexContractsPlugin
{ {
var config = startupConfig.Get<CodexContractsContainerConfig>(); var config = startupConfig.Get<CodexContractsContainerConfig>();
var containerPort = config.GethNode.StartResult.Container.GetContainerPort(GethContainerRecipe.HttpPortTag); var address = config.GethNode.StartResult.Container.GetAddress(GethContainerRecipe.HttpPortTag);
var ip = config.GethNode.StartResult.Container.Pod.PodInfo.Ip; AddEnvVar("DISTTEST_NETWORK_URL", address.ToString());
var port = containerPort.InternalAddress.Port;
AddEnvVar("DISTTEST_NETWORK_URL", $"http://{ip}:{port}");
AddEnvVar("HARDHAT_NETWORK", "codexdisttestnetwork"); AddEnvVar("HARDHAT_NETWORK", "codexdisttestnetwork");
AddEnvVar("KEEP_ALIVE", "1"); AddEnvVar("KEEP_ALIVE", "1");
} }