Sign In
Deploy

Deploying to Kubernetes

Run your backend on any Kubernetes cluster with a simple container image and deployment manifest.

Guide

Prerequisites

  • A Kubernetes cluster with kubectl access (AKS, EKS, GKE, k3s, etc.)
  • Container registry credentials (Docker Hub, GHCR, GCR, etc.)
  • Your backend application repository

Generate Environment Variables

Navigate to Rivet and click Connect > Manual. Copy the environment variables provided, they will be used in later manifests. They should look something like this:

RIVET_API_ENDPOINT=https://api-us-west-1.rivet.dev
RIVET_NAMESPACE=your-namespace-id
RIVET_TOKEN=your-token
Command Line

Package Your App

Create a Dockerfile in your project root:

FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
ENV PORT=8080
CMD ["node", "server.js"]
Dockerfile

Build and Push the Image

docker build -t registry.example.com/your-team/backend:latest .
docker push registry.example.com/your-team/backend:latest
Command Line

Replace registry.example.com/your-team with your registry path. Auth with docker login first if needed.

Deploy to Kubernetes

Create a backend-secrets.yaml for your environment variables:

apiVersion: v1
kind: Secret
metadata:
  name: backend-secrets
type: Opaque
stringData:
  RIVET_API_ENDPOINT: https://api-us-west-1.rivet.dev
  RIVET_NAMESPACE: your-namespace-id
  RIVET_TOKEN: your-token
YAML

Then create a deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: backend
  template:
    metadata:
      labels:
        app: backend
    spec:
      containers:
        - name: backend
          image: registry.example.com/your-team/backend:latest
          envFrom:
            - secretRef:
                name: backend-secrets
YAML
You do not need to expose a container port. Rivet tunnels traffic directly to your backend.

Apply both manifests:

kubectl apply -f backend-secrets.yaml
kubectl apply -f deployment.yaml
Command Line

Add a Service or Ingress if you need external access.

Verify the Runner

Check that the pod is running:

kubectl get pods -l app=backend
Command Line

Your runner should appear as connected on the Rivet dashboard once the pod is ready.

Suggest changes to this page