Skip to content

Allow for IPv6 clusters #23

Description

@snapydziuba

Problem

We run an IPv6-only cluster, which needed some patches to deploy it.

As the sandbox API currently defaults to an IPv4-only bind address:

bind_address: `0.0.0.0:${process.env.PORT ?? 2000}`,

Startup then parses it with:
const [address, port] = config.bind_address.split(':');

This stores bind config as a single host:port string and splits on :, which is incompatible with IPv6 addresses like :: or ::1.
And thus fails for our Service as they are IPv6, while the sandbox API only listens on 0.0.0.0.

Proposed Fix

Add explicit bind host and bind port config:

bind_host: process.env.SANDBOX_BIND_HOST ?? '::'
bind_port: Number(process.env.PORT ?? 2000)

Default SANDBOX_BIND_HOST to IPv6: ::
As the default IPv6 listener also covers IPv4.
This ofc would also need a Helm Chart change to expose this, or an enable_ipv6 flag to set :: to keep 0.0.0.0 as default

Current Workaround

As we had to patch the start-direct-sandbox.sh anyways i just did:

# PATCH: API hardcodes 0.0.0.0; cluster is IPv6-only. Bind to :: instead.
if [ -f "$ROOTFS/sandbox_api/.build/index.js" ]; then
    sed -i 's|let\[c,i\]=G\.bind_address\.split(":"),n=pQ()|let c="::",i=Number(process.env.PORT??2000),n=pQ()|g' \
        "$ROOTFS/sandbox_api/.build/index.js" \
        && echo "[sandbox] Patched sandbox API bind address to ::" \
        || echo "[sandbox] WARNING: could not patch bind address"
fi

If PRs are welcome i would gladly implement this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions