reshapr-container-poc

yada/reshapr-container-poc Checked 10 hours ago

reShapr MCP gateway stack on apple/container: scripts, K8s cluster manifest and test findings

Proof of concept: run the reShapr MCP runtime stack on apple/container (Linux containers as lightweight VMs on macOS), without Docker or Compose. reshapr run --engine apple (merged in reshaprio/reshapr#620, shipped in reShapr 1.2.0) starts the stack on apple/container from the release compose files. apple/container itself has no compose, restart policy, healthcheck or host-gateway, so this repo keeps a script equivalent (what the CLI does not cover: hardened mode, configurable ports, verify.sh, container cluster) and records what works and what does not. Results: docs/FINDINGS.md.

Summary extracted from the README.

reshapr-container-poc

Proof of concept: run the reShapr MCP runtime stack on apple/container (Linux containers as lightweight VMs on macOS), without Docker or Compose.

reshapr run --engine apple (merged in reshaprio/reshapr#620, shipped in reShapr 1.2.0) starts the stack on apple/container from the release compose files. apple/container itself has no compose, restart policy, healthcheck or host-gateway, so this repo keeps a script equivalent (what the CLI does not cover: hardened mode, configurable ports, verify.sh, container cluster) and records what works and what does not. Results: docs/FINDINGS.md.

Script What it does
scripts/up.sh postgres, control plane and gateway with container run, gated by readiness loops; --ui adds the web UI
scripts/verify.sh imports Open-Meteo and runs MCP initialize, tools/list, tools/call through the gateway, result printed with jq
scripts/down.sh removes the three containers
scripts/k8s-cluster.yaml 2-gateway clustered stack for container cluster create (DNS_PING, encrypted JGroups)

Status

Validated on macOS 27.2 (arm64), container 1.7.1, reShapr 1.1.0 and 1.1.1 (re-validated on 1.1.1 on 2026-11-14: T1-T2, T4-T8 pass, see docs/FINDINGS.md). On reShapr 1.2.0 (2026-11-19): T7 re-checked, and reshapr run --release 1.2.0 --engine apple started the stack to ready in 10 warm starts (benchmark for the reshapr.io blog):

Done
T1-T5 native arm64 images, stack ready in ~18 s, MCP end to end (make verify), hardened run (--read-only --cap-drop ALL)
T6-T7 duplicate alias rejected; 2 gateways form one cluster inside a container cluster and both serve tools/list (session sharing not proven, see T7)
T3, T9 sudo DNS: <name>.test and host.container.internal pass; reshapr run --engine apple merged (PR #620) and shipped in reShapr 1.2.0
T8 agent in its own container VM reaches tools through the gateway, 401 on the admin API; limit: no egress allow-list
Extras opt-in web UI (make up-ui), make usage page

Next steps

  1. Done: reshapr run --engine apple (T9), merged in PR #620 and shipped in reShapr 1.2.0. Next: evaluate replacing the scripts/up.sh launch logic with reshapr run --engine apple (check ports, 127.0.0.1 binding, hardening flags; keep up.sh for what it cannot do).
  2. Done: the sudo DNS checks (<name>.test and host.container.internal both pass) and the docker-compose-cluster.yml failure on Docker (F8), fixed upstream in #621 (keystore-init container, not re-tested here). Checked on main and tested on a container cluster (2026-11-14): scripts/k8s-cluster.yaml still needs a shared keystore Secret, now created by a one-shot keystore-gen Job in the same file. The #621 fix only touched install/docker-compose-cluster.yml. A per-pod init container (copied from upstream's idea) does not work on Kubernetes: each replica generates a different AES key, and the second gateway never joins (GMS ... JOIN ... timed out; see F11 in docs/FINDINGS.md).
  3. Done: T8, an agent in its own container VM reaches the tools through the gateway and gets 401 on the admin API. Limit: no egress allow-list in container, so the agent could also call the backend directly (see docs/FINDINGS.md).
  4. Upstream issues. Filed: reShapr #619 (--engine apple, done), #621 (cluster keystore, done). Filed: reShapr #628 (gateway discovery retry, open). Commented on apple/container #1809 (sudo DNS dependency, shared aliases / multi-A answers). No new issue needed; a configurable host alias is not needed (--engine apple handles it). Minor, not filed: kubeconfig by IP, healthcheck/restart. Follow #628 and #1809.
  5. Done: egress allow-list gap (T8) reported as a comment on apple/container discussion #719; related #1320. No new issue filed (the topic exists). Follow the maintainers' reply; they want use cases and UX rather than a pfctl-based command.
  6. Done: docs on reshapr.io, issue #86 closed and PR #87 (apple/container local development guide) merged.

Prerequisites

Apple silicon, macOS 26+, container 1.7+ (container system start), the reShapr CLI (npm i -g @reshapr/reshapr-cli), curl. No sudo is needed for anything here. Optional, with sudo: container system dns create test adds <name>.test resolution, and dns create host.container.internal --localhost <ip> lets containers reach host services (its rule is lost on reboot).

Note: reshapr run --engine apple (T9) needs reShapr 1.2.0 or later (1.1.1 predates #620). The make up stack does not need it; it is validated on the 1.1.0 and 1.1.1 images (1.1.1 is the default).

Quick start

make up        # ports 5555 / 7777 on 127.0.0.1 (override: RESHAPR_CTRL_HOST_PORT, RESHAPR_GATEWAY_HOST_PORT)
make verify    # uses an isolated HOME (.state/home), your reshapr CLI session is untouched
make down

Web UI (opt-in, like reshapr run --ui): make up-ui or ./scripts/up.sh --ui serves http://127.0.0.1:3333 (override: RESHAPR_UI_HOST_PORT, RESHAPR_UI_IMAGE; login admin / password).

Hardened control plane: RESHAPR_EXTRA_RUN_ARGS="--read-only --cap-drop ALL --tmpfs /tmp" make up.

Containers are wired by IP (container ls) so no sudo is needed. <name>.test names also work, but only after sudo container system dns create test, because in-container lookups go through the macOS resolver.

Clustered gateways (container cluster)

container cluster create --name rs --shared-image-store
container cluster list --nodes                     # node IP
# the kubeconfig uses rs.test (needs sudo DNS); use the node IP instead:
K="kubectl --server https://<node-ip>:6443 --insecure-skip-tls-verify"
$K apply -f scripts/k8s-cluster.yaml   # includes a one-shot Job that creates the shared keystore Secret (retry once if the namespace is not ready yet)
$K -n reshapr rollout restart deploy/gateway   # gateways do not retry discovery if the control plane was not ready yet

The keystore-gen Job generates one JCEKS key with keytool (proxy image) and creates the reshapr-cluster-keystore Secret with registry.k8s.io/kubectl, so every gateway mounts the same key. Gateways wait in ContainerCreating until the Secret exists. To regenerate: $K -n reshapr delete job keystore-gen secret reshapr-cluster-keystore, then apply again. Do not generate the key per pod: replicas would get different keys and never join (F11).

changeit and the demo tokens/keys are throwaway values, do not reuse them.

License

Apache-2.0