Deployment
Rivergate is self-hosted. Use Docker Compose to evaluate it locally and Helm to run it on Kubernetes against your own PostgreSQL and Redis.
Topology
| Component | Notes |
|---|---|
| API | Stateless; run as many replicas as you need behind a load balancer. |
| Worker | Runs audit checkpoints, key rotation, lease expiry and revocation, and replacement schedules. Scale and permission it independently. |
| Dashboard | Static assets served by their own container; proxies /api, /auth and /health to the API so browser sessions stay same-origin. |
| PostgreSQL | The durable store. Use a managed or externally operated instance for production. |
| Redis | Required for readiness and sign-in flow state. Holds nothing durable. |
| Key material | Root-key files for API and worker; audit signing key for the worker only. |
Migrations are not run at application startup. Compose runs a one-shot migration service first; Helm runs a pre-install and pre-upgrade migration job.
Docker Compose (local)
The Compose stack in rivergate-deployment is for development and evaluation. It runs the API, worker, dashboard, PostgreSQL and Redis with named volumes, health checks, a private network, non-root application containers and loopback-bound ports. It is not a high-availability profile.
make -C rivergate-deployment up # initialize credentials on first run, start everything
make -C rivergate-deployment bootstrap-admin
make -C rivergate-deployment down
See the Quickstart for the full walkthrough.
Helm on Kubernetes
Two charts live in rivergate-helm:
rivergate— the API, worker, migration job and dashboard, against external PostgreSQL and Redis.rivergate-operator— the namespaced Operator, its CRDs and RBAC. See Kubernetes Operator.
Prepare
- Publish versioned application and dashboard images. The API image contains
rivergate-server,rivergate-workerandrivergate-migrate. - Provision PostgreSQL and Redis. The chart defaults to PostgreSQL
verify-fulland Redis TLS. - Create the database Secret named by
database.existingSecret, containing runtimeusernameandpassword, and a separately privilegedmigration_usernameandmigration_password. - Create the Redis Secret named by
redis.existingSecret, with its configured password key. - Create the root-key Secret named by
keyMaterial.rootKeySecret, holding the exact active marker and versioned root-key files. - Create the audit signing Secret named by
keyMaterial.auditSigningKeySecret. - Decide
publicURL, hosts, image tags, TLS ingress and anyhost:portentries for dynamic credential targets.
Never pass passwords, root keys or audit signing keys through --set, values files, ConfigMaps or source control. Use Kubernetes Secrets with etcd encryption, or an external secret or CSI provider.
Install
helm upgrade --install rivergate ./charts/rivergate \
--namespace rivergate --create-namespace \
--set publicURL=https://rivergate.example.com \
--set ingress.enabled=true \
--set ingress.host=rivergate.example.com \
--set ingress.tls.secretName=rivergate-tls
To review manifests first:
helm lint charts/rivergate
helm template rivergate charts/rivergate --namespace rivergate
What the chart does
- Separate ServiceAccounts for API, worker, migration and dashboard, with Kubernetes API token automount disabled.
- Root-key and signing-key Secret volumes mount only into non-root init containers, which copy the files into memory-backed volumes with owner-only permissions. The root-key directory is then mounted read-only into the API and worker. The dashboard, migration job and Operator never receive root keys. The signing key reaches the worker only.
- Metrics and worker health Services are
ClusterIP. The chart does not create PostgreSQL, Redis or TLS material for you.
Configuration reference
Configuration comes from an optional JSON file named by RIVERGATE_CONFIG_FILE, validated at startup. Environment variables override file values. Validation errors name fields, never values. Passwords are read from files, never inline.
| Setting | Purpose |
|---|---|
RIVERGATE_ENV | development, test or production. Production tightens TLS requirements. |
HTTP_ADDR | API listen address. |
DASHBOARD_URL | Public dashboard origin; used for redirects and cookies. |
WORKER_HEALTH_ADDR · WORKER_HEALTH_URL | Worker health listener, and the URL the API uses to read it. The URL must be HTTPS if set; leave empty unless you front the worker with an internal TLS proxy. |
METRICS_ADDR · WORKER_METRICS_ADDR | Private Prometheus listeners for the API and worker. |
LOG_LEVEL · LOG_FORMAT | Structured logging (json by default). |
ROOT_KEY_DIR | Directory of versioned root-key files. Required by API and worker. |
AUDIT_SIGNING_KEY_FILE | Ed25519 signing key for the worker. |
AUDIT_CHECKPOINT_INTERVAL | Checkpoint cadence as a Go duration. Default 5m. |
DATABASE_HOST · DATABASE_PORT · DATABASE_NAME · DATABASE_USER | PostgreSQL connection. |
DATABASE_PASSWORD_FILE | Path to the password file. |
DATABASE_SSLMODE | Production requires verify-ca or verify-full. |
REDIS_ADDR · REDIS_DB · REDIS_TLS · REDIS_PASSWORD_FILE | Redis connection. |
DYNAMIC_CREDENTIAL_ALLOWED_TARGETS | Exact host:port list for dynamic PostgreSQL targets. Set on API and worker. |
HTTP_READ_HEADER_TIMEOUT · HTTP_READ_TIMEOUT · HTTP_WRITE_TIMEOUT · HTTP_IDLE_TIMEOUT · SHUTDOWN_TIMEOUT | Server timeouts as Go durations. |
OTEL_EXPORTER_OTLP_* | Optional OpenTelemetry export. See Observability. |
An example file is config.example.json.
Database
- Run migrations with the dedicated migration credentials, using the Helm hook or
go run ./cmd/migrateoutside Kubernetes, before starting the API or worker. - Use a restricted runtime database user for the API and worker. Rivergate does not create grants or row-level security policies for you.
- Schema rollback is not automatic. Take a verified database backup and a root-key recovery copy before every upgrade.
- Size connection pools so the maximum across all replicas stays within the database’s limit with headroom.
Scaling and availability
- API replicas are stateless and share PostgreSQL, Redis and key-provider access. Add replicas for throughput and availability.
- The worker’s state transitions are idempotent and checkpointed in PostgreSQL, so a restart resumes where it stopped. Keep it running: lease expiry and revocation depend on it.
- Use readiness to keep unhealthy replicas out of service and liveness to detect stuck processes. Avoid readiness settings that restart pods on a brief dependency blip.
- During a database or Redis failover, expect temporary dependency errors. Rivergate does not acknowledge reads whose audit is uncertain.
- Set termination grace long enough to drain requests.
Networking and TLS
- Terminate TLS at the public URL. Use verified TLS for PostgreSQL and Redis.
- Do not expose the metrics listeners or the worker health listener publicly. Metrics endpoints are unauthenticated: scrape them only from an authorized monitoring namespace.
- Restrict API and worker egress to PostgreSQL, Redis, your identity provider and any allowlisted dynamic credential targets.
- Redact OIDC callback query strings from ingress and access logs.
Upgrading
- Back up PostgreSQL and the root-key and signing-key directories (see Backup and recovery).
- Review release notes and chart values changes.
- Apply Operator CRD changes first if they changed (see Operator upgrades).
- Run
helm upgrade; the migration job runs before the new pods. - Verify readiness, sign-in, a secret read and audit integrity.
When rotating the active root key, preserve every old version still needed to unwrap stored keys, update the root-key Secret, and roll both the API and worker pods. The key directory is copied once per pod, so a Secret update does not refresh a running pod. See root key rotation.