Skip to main content
Sign In
Platforms

Kubernetes

Deploy production-ready Rivet Engine to Kubernetes with PostgreSQL storage.

Prerequisites

  • Kubernetes cluster
  • kubectl configured
  • Metrics server (required for HPA) — included by default in most distributions (k3d, GKE, EKS, AKS)

Deploy Rivet Engine

Download Manifests

Download the self-host/k8s/engine directory from the Rivet repository:

npx giget@latest gh:rivet-dev/rivet/self-host/k8s/engine rivet-k8s
cd rivet-k8s

Configure Engine

In 02-engine-configmap.yaml, set public_url to your engine’s external URL.

Configure PostgreSQL

In 11-postgres-secret.yaml, update the PostgreSQL password. See Using a Managed PostgreSQL Service for external databases.

Configure Admin Token

Generate a secure admin token and save it somewhere safe:

openssl rand -hex 32

Create the namespace and store the token as a Kubernetes secret:

kubectl create namespace rivet-engine
kubectl -n rivet-engine create secret generic rivet-secrets --from-literal=admin-token=YOUR_TOKEN_HERE

Deploy

# Apply all manifests
kubectl apply -f .

# Wait for all pods to be ready
kubectl -n rivet-engine wait --for=condition=ready pod -l app=nats --timeout=300s
kubectl -n rivet-engine wait --for=condition=ready pod -l app=postgres --timeout=300s
kubectl -n rivet-engine wait --for=condition=ready pod -l app=rivet-engine --timeout=300s

# Verify all pods are running
kubectl -n rivet-engine get pods

Access the Engine

Visit /ui on your public_url to access the dashboard.

Deploy RivetKit App

Create Kubernetes Manifests

Create these two manifest files:

Setup Environment

Put the following in rivetkit-secrets.yaml:

apiVersion: v1
kind: Secret
metadata:
  name: rivetkit-secrets
  namespace: your-namespace
type: Opaque
stringData:
  RIVET_ENDPOINT: http://my-app:your-admin-token@your-engine.example.com
  RIVET_PUBLIC_ENDPOINT: http://my-app@your-engine.example.com

Apply Manifests

kubectl apply -f rivetkit-secrets.yaml
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml

Configure RivetKit URL in Dashboard

After the service is deployed and reachable from the public internet:

  1. Open the Rivet Engine dashboard in your browser.
  2. Enter your admin token when prompted.
  3. Create a namespace (or select an existing namespace) that matches your endpoint namespace (for example, my-app).
  4. In the namespace sidebar, click Overview.
  5. Click Add Provider, then choose Custom.
  6. In the connect modal, select Serverless and click Next.
  7. Go to Confirm Connection, enter your app endpoint (.../api/rivet), then click Add.

Advanced

Using a Managed PostgreSQL Service

If you prefer to use a managed PostgreSQL service (e.g. Amazon RDS, Cloud SQL, Azure Database) instead of the bundled Postgres deployment:

  • Update the postgres.url connection string in 02-engine-configmap.yaml to point to your managed instance
  • Delete the bundled PostgreSQL manifests:
    • 10-postgres-configmap.yaml
    • 11-postgres-secret.yaml
    • 12-postgres-statefulset.yaml
    • 13-postgres-service.yaml

Applying Configuration Updates

When making subsequent changes to 02-engine-configmap.yaml, restart the engine pods to pick up the new configuration:

kubectl apply -f 02-engine-configmap.yaml
kubectl -n rivet-engine rollout restart deployment/rivet-engine

Next Steps