Skip to content

Ports and hosts emitted with wrong coordinates depending on deployment #61

Description

@martypitt

Ports and hosts are emitted with wrong coordinates depending on deployment

Nebula always emits host-mapped (external) ports and a host derived from TestContainers' container.host, then patches the host after the fact by string-replacing it with the consumer's HTTP Host header (updateHostReferences). This breaks depending on where the consumer sits relative to the spawned containers, and forces workarounds (/etc/hosts entry mapping nebula → localhost, TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal, host-networking).

The real variable isn't where Nebula runs — it's where the consumer reaches the containers from:

Consumer vantage point Host Port
Host machine (dev CLI, Linux host-mode compose) localhost mapped/external port
Inside nebula_network (Orbital in compose) container network alias (componentName) internal port

If the compose deployment emits in-network coordinates, Orbital talks to containers directly over nebula_network and the host.docker.internal / host-networking / /etc/hosts workarounds become unnecessary.

Proposed change

  • Add a connectivity mode flag: --connectivity=host|network (NEBULA_CONNECTIVITY), default host (preserves current CLI behaviour); compose sets network. Wire into NebulaConfig.
  • Add a single coordinate resolver returning (host, port) per mode:
    • HOSTcontainer.host + getMappedPort(internalPort)
    • NETWORKcomponentName (network alias) + internalPort
  • Emit a discrete host + port per component, and rebuild jdbcUrl / bootstrapServers / S3 endpoint from the same resolved endpoint so embedded strings can't drift.
  • Kafka: advertise alias:<internal-port> in network mode vs mapped port in host mode.
  • Remove updateHostReferences / HostNameAwareContainerConfig and the HTTP-host-header rewrite entirely (replaced by mode-driven construction). Removes the need for the /etc/hosts hack.

Notes

  • Nebula's own internal clients (Hikari, Kafka admin) keep using the TestContainers host-mapped path — unchanged. TESTCONTAINERS_HOST_OVERRIDE remains relevant only for Nebula's self-connection on non-Linux compose.
  • Follow-up: in network mode, two stacks sharing a network with the same component name will collide on alias — may need to namespace the alias (${stack}-${componentName}).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions