Skip to content

sandbox: expose port with signed preview URL #486

@xiaods

Description

@xiaods

What to build

k8e sandbox expose <session-id> <port> returns a signed, limited, revocable preview URL routed via K8s Service + Ingress to the session pod. From KIP-12 (Part A). Consumes the ingress-class + host-pattern config from #484.

API contract (from KIP-12):

rpc ExposePort(ExposePortRequest) returns (ExposePortResponse);
message ExposePortRequest  { string session_id = 1; int32 port = 2; int32 ttl_seconds = 3; }
message ExposePortResponse { string url = 1; int64 expires_at = 2; }

Flow: gateway labels the session pod k8e.sandbox/session=<sid> at claim time → creates a Service (selector on that label) + Ingress (/p/<sid>/<port>/ prefix) → mints an HMAC-signed token (payload: sid, port, exp; signed with server key) → Ingress external-auth calls gateway /preview/verify to validate token + session-active. Route cleaned up on DestroySession. Requires gateway RBAC for create/delete Services + Ingresses.

Acceptance criteria

  • gateway SA granted create/delete on Services and Ingresses
  • session pod gets a unique k8e.sandbox/session=<sid> label at claim time
  • expose <sid> 8080 returns a preview URL; a server listening on 8080 in-sandbox is reachable through it with a valid token
  • request without / with invalid token → 403 via Ingress external-auth
  • destroy removes the Service + Ingress
  • works against a warm-claimed pod (no cold start)
  • test coverage for token sign/verify + Service selector targeting a single pod

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions