kurtosis-tech / kurtosis

A platform for packaging and launching ephemeral backend stacks with a focus on approachability for the average developer.
https://docs.kurtosistech.com/
Apache License 2.0
353 stars 52 forks source link

Make it possible to access public ports within starlark #1861

Open tedim52 opened 10 months ago

tedim52 commented 10 months ago

Background & motivation

Context: https://github.com/kurtosis-tech/ethereum-package/pull/363#discussion_r1404129138

Desired behaviour

An api in starlark that exposes both private and public ports.

How important is this to you?

Painful; the lack of this feature makes using Kurtosis frictionful.

What area of the product does this pertain to?

CLI: the Command Line Interface

mieubrisse commented 10 months ago

Unfortunately this issue as stated isn't possible, because inside the Kurtosis cluster we have no way of resolving "whose public port?"

E.g. if Tedi and I are both connected to the enclave using our CLI, and I'm also connected to the enclave using my SDK, then there are many answers to "who's public port?", and it breaks the determinism of Starlark runs.

Instead, from what I understand of the referenced comment, when we have Traefik as the front door to Kurtosis clusters we could maybe provide future references in Starlark to Traefik-proxied URLs where the service will be running (and these will be less likely to change based on who's accessing). That way NEXT_PUBLIC_BEACON_BASE_URL and NEXT_PUBLIC_EXPLORER_BASE_URL could be set to those values (which would be the same so long as the service exists).

E.g., something like:

ServiceConfig(
    env_vars = {
        "NEXT_PUBLIC_BEACON_BASE_URL": dependency_service.ports["http"].public_url,
    }
)

FWIW we've hit this situation before, with the NEAR Explorer.

tedim52 commented 9 months ago

Makes sense. Definitely need to account for this use case somehow - lots of web based applications are unusable in kurtosis without it.

tedim52 commented 5 months ago

Another example of this: https://discord.com/channels/783719264308953108/1131048810861314169/1226727014854033539

xavier-romero commented 4 months ago

Right now I can access:

service.ip_address
service["port_name"].number

But I'm missing very much that: service["port_name"].public_number

Also, I would need that to be available inside the ServiceConfig itself same than ip_address to be able to set envvars with this value. This breaks many web apps that needs to know its own host/port (I already know the host) and that can not be proxied. I guess that at the same point/with the same logic that you can preallocate the ip_address you should be able to do the same for the port as well !