Shumai Kubernetes Deployment & Autoscaling Example
This directory contains a complete, production-ready Kubernetes example demonstrating how to run Shumai in a decoupled, horizontally scalable architecture powered by DBOS Transact and Garage S3 (dxflrs/garage).
Architecture Overview
[ User / Ingress ]
│
▼ (Port 3000)
┌───────────────────────────────┐
│ shumai-server (Deployment) │
│ SHUMAI_WORKERS=agent │
└───────┬───────────────┬───────┘
│ │
DBOS Task Submissions │ │ Direct S3 Uploads/Reads
(Queue: transcode_queue)│ │
▼ ▼
┌──────────────────────┐ ┌───────────────┐
│ shumai-postgres │ │ garage-s3 │
│ (pgvector:pg18) │ │ (dxflrs/garage)│
└──────────┬───────────┘ └───────▲───────┘
│ │
DBOS Queue │ │ Fetch source video
Polling │ │ Store transcoded proxies
▼ │
┌──────────────────────┐ │
│ shumai-transcode ├─────────┘
│ (1..5 Autoscaled Pods)
└──────────────────────┘
▲
│ CPU Utilization Target (70%)
┌──────────────────────┐
│ shumai-transcode-hpa │
│ (min: 1, max: 5) │
└──────────────────────┘
shumai-server: Serves the Web dashboard and REST API, while processing agent workflows. It setsSHUMAI_WORKERS=agentso that all video and media transcoding tasks are delegated directly to thetranscode_queuein PostgreSQL.shumai-transcode: Dedicated stateless worker pool consuming tasks fromtranscode_queue. Each replica uses the Kubernetes Downward API to setPOD_NAMEfor unique, collision-free DBOS executor identity.garage: Lightweight distributed S3-compatible object storage (dxflrs/garage) providing high-performance shared storage for original and transcoded media files without requiring external cloud storage.shumai-postgres: PostgreSQL database withpgvector:pg18running both application persistence and DBOS workflow queues.shumai-transcode-hpa:HorizontalPodAutoscaler(autoscaling/v2) that monitors transcode worker CPU utilization and scales the pool between 1 and 5 replicas.
Quickstart: Deploy to Kubernetes
Prerequisites
- A Kubernetes cluster (e.g. Docker Desktop, Minikube, Kind, or managed cloud Kubernetes).
kubectlconfigured with cluster access.metrics-serverinstalled in your cluster (required by HPA to read CPU metrics).
1. Deploy the Entire Stack
Run a single command using Kustomize:
kubectl apply -k k8s/
2. Monitor Pod Status
Watch until all components are running and initialized:
kubectl get pods -n shumai -w
Expected output:
NAME READY STATUS RESTARTS AGE
garage-0 1/1 Running 0 1m
garage-init-xxxxx 0/1 Completed 0 45s
shumai-postgres-0 1/1 Running 0 1m
shumai-server-xxxxxxxxxx-xxxxx 1/1 Running 0 1m
shumai-transcode-yyyyyyyyyy-yyyyy 1/1 Running 0 1m
3. Check Autoscaling Status
Inspect the HorizontalPodAutoscaler:
kubectl get hpa -n shumai
You should see:
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
shumai-transcode-hpa Deployment/shumai-transcode 0%/70% 1 5 1 1m
4. Access the Dashboard & S3 Storage
In Kubernetes, the services are created as internal ClusterIP services by default. To interact with the stack from your local machine:
Step A: Port-forward the Web Server
Forward port 3000 to access the web application:
kubectl port-forward -n shumai svc/shumai-server 3000:3000
Open your browser to http://localhost:3000.
Step B: Port-forward In-Cluster S3 Storage (Garage)
Shumai generates direct client-to-S3 presigned URLs configured via AWS_PUBLIC_ENDPOINT_URL_S3 (http://localhost:3900). To allow your browser to upload and stream media files directly:
kubectl port-forward -n shumai svc/garage 3900:3900
Note
Production Environments: In production cloud clusters (AWS EKS, GKE, self-hosted), you would configure an Ingress controller (e.g.
ingress-nginxor AWS ALB) with a public domain or pointAWS_ENDPOINT_URL_S3to an external cloud S3/R2 bucket.
Testing Transcoding & Horizontal Autoscaling
- Upload one or more video files in the Shumai Web UI.
- Observe the
shumai-transcodeworker pod picking up the transcode tasks in its logs:kubectl logs -n shumai -l app=shumai-transcode -f - When multiple heavy video transcoding jobs run concurrently, CPU utilization increases past 70%, triggering the HPA to scale up additional worker pods:
kubectl get hpa -n shumai -w - Once transcoding completes, the HPA will hold replicas for a 300-second stabilization window before cleanly scaling back down to 1 pod.