Skip to main content

Gateway Auto-Registration Guide

This guide explains how to configure and deploy STOA gateways with automatic registration to the Control Plane.

ADR Reference

This feature is defined in ADR-036: Gateway Auto-Registration.

Overview​

STOA gateways can automatically register with the Control Plane at startup, eliminating the need for manual registration via API calls. This provides an "Apple ecosystem" experience where gateways appear in the Console UI within seconds of deployment.

Key benefits:

  • Zero-config deployment (2 environment variables)
  • Automatic re-registration on restart
  • Real-time health visibility via heartbeat
  • Self-healing (gateway recovery is automatic)

Architecture​

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Control Plane API β”‚
β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Gateway Internal β”‚ β”‚ Gateway Health Worker β”‚ β”‚
β”‚ β”‚ /v1/internal/gateways β”‚ Marks stale gateways OFFLINE β”‚ β”‚
β”‚ β”‚ - /register β”‚ β”‚ (90s timeout) β”‚ β”‚
β”‚ β”‚ - /{id}/heartbeat β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚ - /{id}/config β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”‚ HTTPS (X-Gateway-Key header)
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ STOA Gateway β”‚ β”‚ STOA Sidecar β”‚
β”‚ (edge-mcp) β”‚ β”‚ + Kong β”‚
β”‚ β”‚ β”‚ β”‚
β”‚ 1. Register β”‚ β”‚ ext_authz β”‚
β”‚ 2. Heartbeat β”‚ β”‚ ↓ β”‚
β”‚ (30s) β”‚ β”‚ Policy/Meter β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Quick Start​

Tier 1: STOA Native Gateway​

Deploy a STOA gateway with automatic registration:

# Minimal registration configuration (not a complete Ready deployment)
export STOA_CONTROL_PLANE_URL="https://api.<YOUR_DOMAIN>"
export STOA_CONTROL_PLANE_API_KEY="<GATEWAY_API_KEY>"

# Start the gateway
./stoa-gateway
Registration is not readiness

The two variables above configure registration only. STOA_POLICY_BOOT_TENANTS defaults to an empty list, so this example leaves /ready returning HTTP 503 even if registration succeeds. Before starting a gateway that must become Ready, also set STOA_POLICY_BOOT_TENANTS="<TENANT_ID>" (comma-separated for multiple existing tenants) and configure policy-loading dependencies: reachable Control Plane and Keycloak services, a Keycloak service client using private_key_jwt with a mounted signing key, and authorization to read the tenants' tool permissions. The registration API key or a Keycloak client secret alone cannot authenticate these policy reads. A complete, fresh tool policy must load, and a configured policy trust set must load successfully. See Startup Policy and Readiness for the Helm extraEnv setting and signing-key configuration. All other readiness checks must also pass.

The gateway will:

  1. Derive identity from hostname + mode + environment
  2. Call POST /v1/internal/gateways/register
  3. Start heartbeat loop (every 30 seconds)
  4. Appear in Console UI at /gateways

Tier 2: Sidecar mode​

A same-pod companion is a second container that answers POST /authz. Registration uses the same Control Plane variables as any other STOA process. The repository does not ship a Kong, Envoy, or webMethods plugin, and KONG_PLUGINS / KONG_EXT_AUTHZ_URL are not a demonstrated Kong configuration. The host must send the JSON body in Companion usage.

# Illustrative co-location only. The host container must call
# POST http://127.0.0.1:8081/authz itself. Pin the image digest
# your release uses; do not rely on a floating tag.
apiVersion: apps/v1
kind: Deployment
metadata:
name: host-with-stoa-sidecar
spec:
selector:
matchLabels:
app: host-with-stoa-sidecar
template:
metadata:
labels:
app: host-with-stoa-sidecar
spec:
containers:
- name: gateway
image: <your-gateway-image>
- name: stoa-sidecar
image: ghcr.io/stoa-platform/stoa-gateway
env:
- name: STOA_GATEWAY_MODE
value: "sidecar"
- name: STOA_PORT
value: "8081"
- name: STOA_CONTROL_PLANE_URL
value: "https://api.<YOUR_DOMAIN>"
- name: STOA_CONTROL_PLANE_API_KEY
valueFrom:
secretKeyRef:
name: stoa-sidecar-secrets
key: STOA_CONTROL_PLANE_API_KEY
ports:
- containerPort: 8081

/authz trusts the JSON user and does not validate a token. The process binds 0.0.0.0 and STOA_PORT. Putting the containers in one pod does not, by itself, prove the host calls localhost. See Companion usage. GitOps sync to the gateway admin API is stoa-connect.

Control Plane Configuration​

1. Create Gateway API Keys​

Configure the Control Plane to accept gateway registrations:

# Create Kubernetes secret with API keys
kubectl create secret generic stoa-gateway-api-keys \
--namespace stoa-system \
--from-literal=GATEWAY_API_KEYS="<GATEWAY_API_KEY>,<SECOND_GATEWAY_API_KEY>"

Key format: Any string, but we recommend the format gw_{environment}_{random}.

Key rotation: Multiple keys are supported (comma-separated). Add a new key before removing the old one.

2. Deploy Control Plane with Keys​

Patch the Control Plane deployment:

kubectl patch deployment stoa-control-plane-api -n stoa-system \
--type='json' \
-p='[{"op": "add", "path": "/spec/template/spec/containers/0/env/-", "value": {"name": "GATEWAY_API_KEYS", "valueFrom": {"secretKeyRef": {"name": "stoa-gateway-api-keys", "key": "GATEWAY_API_KEYS"}}}}]'

The stoa-platform chart does not deploy the Control Plane API or expose a controlPlane.env setting. Configure GATEWAY_API_KEYS in your existing Control Plane deployment.

Gateway Configuration Reference​

Environment Variables​

VariableRequiredDefaultDescription
STOA_CONTROL_PLANE_URLYes-Control Plane API URL
STOA_CONTROL_PLANE_API_KEYYes-Shared secret for authentication
STOA_GATEWAY_MODENoedge-mcpGateway mode: edge-mcp, sidecar, proxy, shadow
STOA_ENVIRONMENTNodevEnvironment identifier for grouping

The chart comment also lists connect, but the Rust runtime does not accept it for STOA_GATEWAY_MODE. Use edge-mcp, sidecar, proxy, or shadow for stoaGateway.mode.

The Rust gateway registers with tenant_id: null (platform-wide); STOA_TENANT_ID is not a supported runtime setting and does not provide tenant isolation.

Registration Payload​

The gateway sends this payload at startup:

{
"hostname": "<GATEWAY_HOSTNAME>",
"mode": "edge-mcp",
"version": "0.1.0",
"environment": "prod",
"capabilities": ["rest", "mcp", "sse", "oidc", "rate_limiting"],
"admin_url": "http://<GATEWAY_HOSTNAME>:8080",
"tenant_id": null
}

Heartbeat Payload​

Every 30 seconds:

{
"uptime_seconds": 3600,
"routes_count": 15,
"policies_count": 5,
"requests_total": 10000,
"error_rate": 0.01
}

Identity Derivation​

Gateway identity is deterministic: {hostname}-{mode_normalized}-{environment}

Mode normalization removes underscores only; the hyphen in edge-mcp is preserved.

HostnameModeEnvironmentDerived Name
stoa-gw-abc123edge-mcpprodstoa-gw-abc123-edge-mcp-prod
kong-sidecar-xyzsidecarstagingkong-sidecar-xyz-sidecar-staging

This enables:

  • Idempotent registration: Same gateway restarts update rather than duplicate
  • Clear naming: Easy to identify in Console UI
  • Environment filtering: Group gateways by environment

Helm Chart Configuration​

STOA Gateway (Tier 1)​

Set stoaGateway.secretName to an existing Kubernetes Secret. To populate it from Vault instead, enable the optional ExternalSecret as shown below; this requires External Secrets Operator and an existing ClusterSecretStore named vault-backend:

# values.yaml
stoaGateway:
enabled: true
replicas: 2

# Control Plane connection
controlPlaneUrl: "http://stoa-control-plane-api.stoa-system.svc.cluster.local:80"

# Secret keys: STOA_CONTROL_PLANE_API_KEY, STOA_KEYCLOAK_CLIENT_SECRET
# STOA_CONTROL_PLANE_API_KEY is required for auto-registration.
# Without it, the gateway skips registration and runs in standalone mode.
secretName: stoa-gateway-secrets

# ExternalSecret (Vault-backed) β€” syncs secrets from Vault into K8s Secret
externalSecret:
enabled: true
refreshInterval: 1h
secretStoreRef: vault-backend
vaultPath: "<VAULT_GATEWAY_PATH>" # Must contain both STOA_* properties listed above

The deployment template injects the secret as an environment variable:

- name: STOA_CONTROL_PLANE_API_KEY
valueFrom:
secretKeyRef:
name: stoa-gateway-secrets
key: STOA_CONTROL_PLANE_API_KEY
optional: true # Gateway runs standalone if missing
Required Vault Key

Replace <VAULT_GATEWAY_PATH> with a Vault path containing STOA_CONTROL_PLANE_API_KEY and STOA_KEYCLOAK_CLIENT_SECRET. The ExternalSecret uses those exact names for both Vault properties and Kubernetes Secret keys. Missing properties prevent successful secret synchronization; without STOA_CONTROL_PLANE_API_KEY, the gateway skips auto-registration.

STOA sidecar (Tier 2)​

The platform chart renders the same-pod pod only when both flags below are true. stoaSidecar.enabled defaults to false. The chart appends EXT_AUTHZ_URL=http://localhost:8081/authz on the target container. It reads secret key STOA_CONTROL_PLANE_API_KEY (optional: true). stoaSidecar.image is ghcr.io/stoa-platform/stoa-gateway pinned by digest in values.yaml, which is the published gateway image. The unpublished light build profile is not what the chart runs.

stoaSidecar:
enabled: true
mainGateway:
enabled: true
image:
repository: "<your-gateway-repository>"
digest: "<your-gateway-digest>"

The chart also injects Keycloak variables and policyEnabled. POST /authz does not validate tokens and does not evaluate Control Plane or OPA policies. Supply the target image yourself. This documentation does not name a webMethods image. Details and limits: Companion usage and webMethods and the companion.

Console UI​

After registration, gateways appear at Console > Gateways with automatic 30-second polling (via TanStack React Query). No manual refresh needed.

ColumnDescription
NameDerived instance name
Typestoa, stoa_sidecar, webmethods, etc.
StatusONLINE, OFFLINE, DEGRADED
Environmentdev, staging, prod
Live IndicatorPulsing green dot if heartbeat received within 90s
CapabilitiesFeature badges

Status Indicators​

StatusMeaningVisual
ONLINEHeartbeat received within 90sPulsing green dot
OFFLINENo heartbeat for > 90sGray dot
DEGRADEDInstance status reported as degraded by the Control PlaneYellow status badge

Gateway Detail Panel​

Click a gateway card to open the detail panel showing heartbeat metrics:

MetricSourceExample
Uptimehealth_details.uptime_seconds1h 30m
Routeshealth_details.routes_count15
Policieshealth_details.policies_count5
Requestshealth_details.requests_total10,000
Error Ratehealth_details.error_rate2.0%
Registered Athealth_details.registered_at2026-02-06

Each accepted heartbeat sets the instance status to ONLINE. An error rate above 5% highlights the Error Rate metric in the detail panel; it does not set the instance status to DEGRADED.

Deep Readiness Probe​

The gateway's /ready endpoint checks required policy state, Control Plane connectivity when configured, and OIDC provider reachability when authentication is enabled before reporting readiness.

If a check fails, the endpoint returns 503 SERVICE UNAVAILABLE with a descriptive message:

  • NOT READY: Control Plane unreachable
  • NOT READY: OIDC provider unreachable

This prevents Kubernetes from routing traffic to gateways that cannot enforce policies or validate tokens.

Config Fetch​

The Control Plane exposes a configuration endpoint for registered gateways:

GET /v1/internal/gateways/{id}/config
Header: X-Gateway-Key: <GATEWAY_API_KEY>

The response includes:

  • pending_deployments β€” API deployments targeted at this gateway
  • pending_policies β€” Rate limiting, access control, and governance policies

The Rust gateway registration lifecycle registers the instance and sends heartbeats. It does not automatically poll this endpoint or apply its pending deployments and policies.

Troubleshooting​

Gateway Not Appearing in Console​

  1. Check gateway logs for registration errors:

    kubectl logs -n stoa-system deployment/stoa-gateway | grep -i register
  2. Verify Control Plane has API keys configured:

    kubectl describe secret stoa-gateway-api-keys -n stoa-system
  3. Check Control Plane logs:

    kubectl logs -n stoa-system deployment/stoa-control-plane-api | grep -i gateway
  4. Test registration endpoint manually:

    curl -X POST "${STOA_CONTROL_PLANE_URL}/v1/internal/gateways/register" \
    -H "X-Gateway-Key: <GATEWAY_API_KEY>" \
    -H "Content-Type: application/json" \
    -d '{
    "hostname": "<GATEWAY_HOSTNAME>",
    "mode": "edge-mcp",
    "version": "0.1.0",
    "environment": "dev",
    "capabilities": ["rest"],
    "admin_url": "http://<GATEWAY_HOSTNAME>:8080"
    }'

Gateway Shows OFFLINE​

  1. Check heartbeat is being sent:

    kubectl logs -n stoa-system deployment/stoa-gateway | grep heartbeat
  2. Verify network connectivity to Control Plane:

    kubectl exec -n stoa-system deployment/stoa-gateway -- \
    curl --fail --silent --show-error http://stoa-control-plane-api.stoa-system.svc.cluster.local:80/health/live

Registration Returns 503​

Cause: GATEWAY_API_KEYS not configured in Control Plane.

Fix:

kubectl create secret generic stoa-gateway-api-keys \
--namespace stoa-system \
--from-literal=GATEWAY_API_KEYS="<GATEWAY_API_KEY>"

kubectl patch deployment stoa-control-plane-api -n stoa-system \
--type='json' \
-p='[{"op": "add", "path": "/spec/template/spec/containers/0/env/-", "value": {"name": "GATEWAY_API_KEYS", "valueFrom": {"secretKeyRef": {"name": "stoa-gateway-api-keys", "key": "GATEWAY_API_KEYS"}}}}]'

kubectl rollout status deployment/stoa-control-plane-api -n stoa-system

Registration Returns 401​

Cause: Gateway API key doesn't match any key in GATEWAY_API_KEYS.

Fix: Check that the Secret contains GATEWAY_API_KEYS, then compare its value with the gateway credential through your secret manager without printing either value:

kubectl describe secret stoa-gateway-api-keys -n stoa-system

Security Considerations​

API Key Management​

  • Never commit keys to Git: Use Kubernetes Secrets or external secrets manager
  • Use environment-specific keys: Different keys for dev, staging, prod
  • Rotate keys periodically: Add new key β†’ update gateways β†’ remove old key
  • Audit registrations: Check Control Plane logs for unexpected registrations

Network Security​

  • Internal endpoints (/v1/internal/*) should NOT be exposed via public ingress
  • Use Kubernetes NetworkPolicies to restrict which pods can call the internal API
  • Consider mTLS for high-security deployments (future enhancement)

Key Rotation Procedure​

  1. Add new key to Control Plane (comma-separated)
  2. Restart Control Plane to pick up new key
  3. Update gateways to use new key
  4. Remove old key after all gateways updated

Cookies and privacy

With your permission, we use cookies to measure visits and understand navigation to improve the site.

Learn more

Google Analytics measures visits and useful clicks. Microsoft Clarity provides masked interaction replays. No advertising use. Your choice is saved for six months. You can change or withdraw it at any time using the β€œCookies” button.

Read the audience measurement details