docs(deploy): redesign EKS documentation, rename k8s to eks, and add scalable deployment feature

This commit is contained in:
yiling
2026-10-18 19:04:36 +08:00
parent 4841a49373
commit 561d84c529
15 changed files with 257 additions and 328 deletions
+234
View File
@@ -0,0 +1,234 @@
# Shumai on AWS EKS with Graviton3 Spot & Autoscaling
This directory contains a complete, production-ready Kubernetes deployment example demonstrating how to run Shumai on **Amazon Elastic Kubernetes Service (AWS EKS)** with horizontal autoscaling for compute-heavy media processing.
---
## Architecture Overview
```text
[ User / Internet ]
│
┌────────────────────┴────────────────────┐
│ (Port 80/3000) │ (Port 3900)
▼ ▼
┌───────────────────────┐ ┌───────────────────────┐
│ shumai-server (ELB) │ │ garage-public (ELB) │
└───────────┬───────────┘ └───────────┬───────────┘
│ │ Direct Browser Uploads
│ ▼ (Presigned URLs)
┌───────────────────┼─────────────────────────────────────────────────────────────────┐
│ General Workload Node (c7g.large Spot, ~$0.029/hr) │
│ │ │
│ ▼ │
│ ┌───────────────────────┐ DBOS Tasks ┌───────────────────────────┐ │
│ │ shumai-server ├─────────────────►│ shumai-postgres │ │
│ │ (SHUMAI_WORKERS=agent)│ (transcode_queue)│ (pgvector:pg18) │ │
│ └───────────┬───────────┘ └─────────────┬─────────────┘ │
│ │ │ │
│ │ │ Task Polling │
│ ▼ ▼ │
│ ┌───────────────────────┐ ┌───────────────────────────┐ │
│ │ garage-s3 │◄─────────────────┤ shumai-transcode │ │
│ │ (dxflrs/garage) │ Fetch Source / │ (Worker Pod 1) │ │
│ └───────────────────────┘ Write Proxies └───────────────────────────┘ │
└────────────────────────────────────────────────────────────────┬────────────────────┘
│ HPA Target: 70% CPU
▼
┌─────────────────────────────────────────────────────────────────────────────────────┐
│ Transcode Compute Pool (c7g.xlarge Graviton3 Spot, ~$0.06/hr, 1 Pod per Node) │
│ │
│ ┌──────────────────────────┐ ┌──────────────────────────┐ ┌────────────────────┐ │
│ │ shumai-transcode │ │ shumai-transcode │ │ shumai-transcode │ │
│ │ (Worker Pod 2) │ │ (Worker Pod 3) │ │ (Worker Pod N) │ │
│ └──────────────────────────┘ └──────────────────────────┘ └────────────────────┘ │
│ ▲ ▲ ▲ │
│ │ │ │ │
│ ┌────────┴─────────────────┐ ┌─────────┴────────────────┐ ┌─────────┴──────────┐ │
│ │ Node: c7g.xlarge (Spot) │ │ Node: c7g.xlarge (Spot) │ │Node: c7g.xlarge │ │
│ └──────────────────────────┘ └──────────────────────────┘ └────────────────────┘ │
│ │
│ Cluster Autoscaler: Dynamically provisions / terminates c7g.xlarge nodes │
└─────────────────────────────────────────────────────────────────────────────────────┘
```
---
## Core Design Principles
### 1. Compute Tiering & Why Graviton3 (`c7g.xlarge`)
Media transcoding with FFmpeg is one of the most CPU-intensive workloads in modern web applications. To achieve maximum throughput at minimum cost, this deployment separates system services from media encoding:
- **General System Node (`shumai-general-spot`)**: A single 2 vCPU / 4 GiB RAM (`c7g.large` Spot) node (~$0.029/hr) runs the Web UI, API, PostgreSQL, and Garage S3.
- **Dedicated Transcode Pool (`shumai-transcode-spot`)**: High-performance 4 vCPU / 8 GiB RAM (`c7g.xlarge` Spot) instances dedicated exclusively to media encoding.
**Why choose AWS Graviton3 (`c7g.xlarge`)?**
AWS Graviton3 ARM64 processors feature dedicated Neoverse V1 cores with native FP16 and SVE (Scalable Vector Extension) vector units. As detailed in AWS's benchmark study, [Optimized Video Encoding with FFmpeg on AWS Graviton Processors](https://aws.amazon.com/cn/blogs/opensource/optimized-video-encoding-with-ffmpeg-on-aws-graviton-processors/), Graviton processors deliver **up to 25–40% better performance** and higher frames-per-second per dollar compared to x86 equivalents. Coupled with AWS EC2 Spot instances, `c7g.xlarge` costs only **~$0.06/hour** (a ~60% discount over On-Demand).
### 2. In-Cluster S3 vs. Native Amazon S3
> [!NOTE]
> **Why Garage is included in this example**:
> We include **Garage S3** (`dxflrs/garage`) on EBS gp3 to demonstrate a **100% self-contained, fully self-hosted deployment** that boots without requiring an external cloud storage account or pre-existing S3 buckets.
> [!TIP]
> **Production Recommendation**:
> If you are deploying on AWS, you should consider using **native Amazon S3 directly** (e.g. by setting `S3_BUCKET: my-prod-bucket`). Real Amazon S3 provides virtually infinite capacity, 11 9s durability, global availability, and eliminates the operational overhead of managing in-cluster storage volumes.
When running Garage in-cluster, Shumai utilizes **Split-Horizon S3 Resolution**:
- **Internal Traffic (`AWS_ENDPOINT_URL_S3`)**: Points to `http://garage.shumai.svc.cluster.local:3900`. Backend server and worker pods stream source files and upload transcoded HLS chunks over private cluster networking with **zero AWS data transfer fees** and microsecond latency.
- **Public Client Traffic (`AWS_PUBLIC_ENDPOINT_URL_S3`)**: Points to the public LoadBalancer (`http://<garage-public-elb>:3900`) for generating presigned upload/download URLs so end-user browsers can stream and upload files directly.
### 3. Task Orchestration via DBOS Transact
All video and document transcoding jobs are enqueued to `transcode_queue` inside PostgreSQL via **DBOS Transact**. Transcode workers are completely stateless and consume jobs from the queue. Each worker pod uses the Kubernetes Downward API (`POD_NAME`) to obtain a unique, collision-free executor ID.
---
## Autoscaling Mechanics
Autoscaling operates across two coordinated layers:
```mermaid
flowchart LR
Upload[Video Uploads Spike] --> HPA[HPA detects CPU > 70%]
HPA --> ScalePods[Scale Pods 1 to 5]
ScalePods --> Pending[Pods Enter Pending: 3000m CPU needed]
Pending --> CA[Cluster Autoscaler launches c7g.xlarge Spot nodes]
CA --> Ready[1 Pod scheduled per dedicated c7g.xlarge Node]
```
1. **Horizontal Pod Autoscaler (HPA)**:
- Configured in [`shumai-transcode-hpa.yaml`](./shumai-transcode-hpa.yaml) targeting **70% CPU utilization** of the pod's `3000m` CPU request (= 2.1 vCPUs).
- When a video transcode starts, FFmpeg consumes ~3.5 cores, immediately exceeding 70% and prompting HPA to scale out worker pods (up to 5 replicas).
2. **1:1 Dedicated Pod-to-Node Allocation**:
- In [`shumai-transcode.yaml`](./shumai-transcode.yaml), worker pods request `cpu: 3000m` and `memory: 4Gi` with limits at `cpu: 3900m` and `memory: 6Gi`.
- Because a `c7g.xlarge` instance has `3920m` allocatable CPU, **strictly 1 transcode pod can fit per node**, giving FFmpeg unrestricted access to all 4 physical cores without CPU throttling.
- Additional pods enter `Pending` state, which immediately triggers the **Kubernetes Cluster Autoscaler** to scale up the AWS Auto Scaling Group (`shumai-transcode-spot`).
3. **Graceful Scale-Down & Task Safety**:
- **5-Minute HPA Stabilization Window** (`stabilizationWindowSeconds: 300`): Once the queue is clear and CPU drops to 0%, HPA holds replicas for 5 minutes to avoid pod thrashing if new uploads arrive.
- **5-Minute Termination Grace Period** (`terminationGracePeriodSeconds: 300`): When Kubernetes terminates a worker, it sends `SIGTERM`. The worker stops taking new jobs, drains the active FFmpeg transcode step, uploads proxies to S3, and exits cleanly.
- **10-Minute Node Cooldown**: Cluster Autoscaler waits for idle nodes to be unneeded for 10 minutes (`scale-down-unneeded-time=10m`) before cordoning, draining, and terminating the EC2 Spot instance.
---
## Step-by-Step Deployment Guide
### Prerequisites
- [AWS CLI](https://aws.amazon.com/cli/) installed and configured (`aws configure`).
- [`eksctl`](https://eksctl.io/) installed.
- [`kubectl`](https://kubernetes.io/docs/tasks/tools/) installed.
### Step 1: Provision the EKS Cluster
Create the cluster using the declarative [`eks/eks-cluster.yaml`](./eks-cluster.yaml) configuration:
```bash
eksctl create cluster -f eks/eks-cluster.yaml
```
This provisions:
- An EKS 1.31 control plane in a dedicated VPC across multiple AZs.
- `shumai-general-spot`: 1x `c7g.large` Spot instance (labeled `workload: general`).
- `shumai-transcode-spot`: Autoscaling `c7g.xlarge` Spot instances (min: 1, max: 5, labeled `workload: transcode`).
- AWS EBS CSI Driver with IAM OIDC roles.
### Step 2: Deploy the Shumai Stack
Deploy all components with Kustomize:
```bash
kubectl apply -k eks/
```
Verify that all initial pods reach `Running` state:
```bash
kubectl get pods -n shumai -o wide
```
### Step 3: Configure Public Access & S3 Endpoint
Retrieve the external LoadBalancer hostnames created by AWS:
```bash
kubectl get svc -n shumai
```
```text
NAME TYPE EXTERNAL-IP PORT(S)
shumai-server LoadBalancer k8s-shumai-xxx.us-east-1.elb.amazonaws.com 80:31234/TCP,3000:31235/TCP
garage-public LoadBalancer k8s-garage-xxx.us-east-1.elb.amazonaws.com 3900:31236/TCP
```
#### Option A: Quick Testing (Automated 1-Liner)
Inject the public Garage ELB hostname into `shumai-server`:
```bash
GARAGE_ELB=$(kubectl get svc garage-public -n shumai -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
kubectl set env deployment/shumai-server -n shumai AWS_PUBLIC_ENDPOINT_URL_S3="http://${GARAGE_ELB}:3900"
```
#### Option B: Production with Custom Domains
In production, point DNS records (e.g. Route 53) to your load balancers:
- Web App: `https://shumai.mycompany.com`
- S3 Storage: `https://s3.mycompany.com`
Set `AWS_PUBLIC_ENDPOINT_URL_S3: https://s3.mycompany.com` in [`eks/config.yaml`](./config.yaml) and apply once.
#### Option C: Native Amazon S3
If using real AWS S3, set `STORAGE_BACKEND: s3`, provide `S3_BUCKET`, and omit `AWS_PUBLIC_ENDPOINT_URL_S3` (native AWS S3 endpoints resolve globally).
### Step 4: Deploy Kubernetes Cluster Autoscaler
Deploy the official Cluster Autoscaler to enable automated node provisioning:
```bash
curl -s https://raw.githubusercontent.com/kubernetes/autoscaler/master/cluster-autoscaler/cloudprovider/aws/examples/cluster-autoscaler-autodiscover.yaml \
| sed 's/<YOUR CLUSTER NAME>/shumai-eks/g' \
| kubectl apply -f -
# Pin autoscaler to the general workload node
kubectl patch deployment cluster-autoscaler -n kube-system -p '{"spec":{"template":{"spec":{"nodeSelector":{"workload":"general"}}}}}'
```
### Step 5: Test Horizontal Autoscaling
1. Open `http://<shumai-server-elb>` in your browser and log in with your credentials.
2. Upload a batch of 10–20 video files simultaneously.
3. Watch the workers scale up horizontally:
```bash
kubectl get hpa -n shumai -w
kubectl get pods -n shumai -l app=shumai-transcode -o wide
kubectl get nodes -L node.kubernetes.io/instance-type,workload
```
4. Observe that each worker consumes ~3 vCPUs on its dedicated `c7g.xlarge` instance.
5. Once all jobs complete, observe HPA scaling back down to 1 pod and Cluster Autoscaler terminating idle EC2 Spot instances.
### Step 6: Cluster Teardown & Cost Cleanup
When you are finished testing, delete all resources to prevent ongoing cloud charges:
```bash
# 1. Delete Kubernetes namespace to release ELB load balancers and EBS volumes
kubectl delete namespace shumai
# 2. Delete the EKS cluster and CloudFormation stacks
eksctl delete cluster -f eks/eks-cluster.yaml --wait
```
---
## Portability to Generic Kubernetes
While this directory is configured for AWS EKS, the exact same architecture applies directly to any Kubernetes environment:
- **Google Kubernetes Engine (GKE)**: Use `tau T2A` ARM64 instances for transcode workers and standard persistent disks (`pd-balanced`).
- **Azure Kubernetes Service (AKS)**: Use `Dpsv5` ARM64 Spot node pools.
- **Local (Minikube / Docker Desktop / Kind)**: Use the same manifests without node selectors or Cluster Autoscaler. Access services via `kubectl port-forward`:
```bash
kubectl port-forward -n shumai svc/shumai-server 3000:3000
kubectl port-forward -n shumai svc/garage 3900:3900
```
+29
View File
@@ -0,0 +1,29 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: shumai-config
namespace: shumai
data:
# S3 Storage Configuration (Garage S3)
STORAGE_BACKEND: 's3'
AWS_ENDPOINT_URL_S3: 'http://garage.shumai.svc.cluster.local:3900'
S3_BUCKET: 'shumai'
S3_REGION: 'garage'
S3_FORCE_PATH_STYLE: 'true'
# Server & Worker Configuration
SHUMAI_SERVER_PORT: '3000'
CONCURRENCY_TRANSCODE: '1'
---
apiVersion: v1
kind: Secret
metadata:
name: shumai-secret
namespace: shumai
type: Opaque
stringData:
DATABASE_URL: 'postgresql://shumai:shumai_password@shumai-postgres.shumai.svc.cluster.local:5432/shumai_db?schema=public'
BETTER_AUTH_SECRET: 'qSxs9DxzHDZBbeeTNPEwBuspYwipBqz5Gk5XdBjNhWw='
S3_ACCESS_KEY_ID: 'GKshumaiaccesskeyid001'
S3_SECRET_ACCESS_KEY: 'shumaisecretaccesskey00000000000000001'
GARAGE_ADMIN_TOKEN: 'admin-secret-token'
+50
View File
@@ -0,0 +1,50 @@
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: shumai-eks
region: us-east-1
version: '1.31'
iam:
withOIDC: true
addons:
- name: aws-ebs-csi-driver
wellKnownPolicies:
ebsCSIController: true
managedNodeGroups:
# General system workload: Web UI, REST API, DBOS PostgreSQL, and Garage S3
- name: shumai-general-spot
instanceType: c7g.large # 2 vCPU, 4 GiB RAM (2c4g Spot, ~$0.029/hr)
spot: true
minSize: 1
maxSize: 2
desiredCapacity: 1
amiFamily: AmazonLinux2023
volumeSize: 50
volumeType: gp3
labels:
workload: general
iam:
withAddonPolicies:
autoScaler: true
ebs: true
# Transcoding compute pool: High-CPU media processing
- name: shumai-transcode-spot
instanceType: c7g.xlarge # 4 vCPU, 8 GiB RAM (Graviton3 Spot, ~$0.06/hr)
spot: true
minSize: 1
maxSize: 5
desiredCapacity: 1
amiFamily: AmazonLinux2023
volumeSize: 50
volumeType: gp3
labels:
workload: transcode
iam:
withAddonPolicies:
autoScaler: true
ebs: true
+237
View File
@@ -0,0 +1,237 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: garage-config
namespace: shumai
data:
garage.toml: |
metadata_dir = "/var/lib/garage/meta"
data_dir = "/var/lib/garage/data"
db_engine = "sqlite"
replication_factor = 1
rpc_bind_addr = "0.0.0.0:3901"
rpc_secret = "c7d7e35b7501a91e5cfb3874026315579930f367fa3b7e4a1e94cf67484a86cf"
[s3_api]
s3_region = "garage"
api_bind_addr = "0.0.0.0:3900"
root_domain = ".s3.garage"
[admin]
api_bind_addr = "0.0.0.0:3903"
admin_token = "admin-secret-token"
---
apiVersion: v1
kind: Service
metadata:
name: garage
namespace: shumai
labels:
app: garage
spec:
ports:
- port: 3900
name: s3-api
- port: 3901
name: rpc
- port: 3903
name: admin
selector:
app: garage
---
apiVersion: v1
kind: Service
metadata:
name: garage-public
namespace: shumai
labels:
app: garage
spec:
type: LoadBalancer
ports:
- port: 3900
targetPort: 3900
name: s3-api
selector:
app: garage
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: garage
namespace: shumai
spec:
serviceName: garage
replicas: 1
selector:
matchLabels:
app: garage
template:
metadata:
labels:
app: garage
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: eks.amazonaws.com/nodegroup
operator: In
values:
- shumai-general-spot
- matchExpressions:
- key: workload
operator: In
values:
- general
containers:
- name: garage
image: dxflrs/garage:v2.4.1
imagePullPolicy: IfNotPresent
command: ['/garage', 'server']
ports:
- containerPort: 3900
name: s3-api
- containerPort: 3901
name: rpc
- containerPort: 3903
name: admin
volumeMounts:
- name: config
mountPath: /etc/garage.toml
subPath: garage.toml
- name: garage-meta
mountPath: /var/lib/garage/meta
- name: garage-data
mountPath: /var/lib/garage/data
volumes:
- name: config
configMap:
name: garage-config
volumeClaimTemplates:
- metadata:
name: garage-meta
spec:
accessModes: ['ReadWriteOnce']
resources:
requests:
storage: 1Gi
- metadata:
name: garage-data
spec:
accessModes: ['ReadWriteOnce']
resources:
requests:
storage: 10Gi
---
apiVersion: batch/v1
kind: Job
metadata:
name: garage-init
namespace: shumai
spec:
backoffLimit: 10
template:
metadata:
labels:
app: garage-init
spec:
restartPolicy: OnFailure
containers:
- name: init
image: alpine:3.20
env:
- name: S3_BUCKET
valueFrom:
configMapKeyRef:
name: shumai-config
key: S3_BUCKET
- name: S3_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: shumai-secret
key: S3_ACCESS_KEY_ID
- name: S3_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: shumai-secret
key: S3_SECRET_ACCESS_KEY
- name: GARAGE_ADMIN_TOKEN
valueFrom:
secretKeyRef:
name: shumai-secret
key: GARAGE_ADMIN_TOKEN
command:
- /bin/sh
- -c
- |
set -e
apk add --no-cache curl jq aws-cli >/dev/null 2>&1
echo "Waiting for Garage Admin API to respond..."
until curl -s -f -H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" http://garage:3903/v2/GetClusterStatus >/dev/null 2>&1; do
sleep 2
done
echo "Garage Admin API is online. Retrieving cluster status..."
STATUS=$(curl -s -H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" http://garage:3903/v2/GetClusterStatus)
NODE_ID=$(echo "$STATUS" | jq -r '.nodes[0].id // empty')
if [ -z "$NODE_ID" ]; then
echo "Error: Node ID not found"
exit 1
fi
echo "Discovered Node ID: $NODE_ID"
ROLE=$(echo "$STATUS" | jq -r '.nodes[0].role // empty')
if [ -z "$ROLE" ] || [ "$ROLE" = "null" ]; then
echo "Assigning layout role to node..."
curl -s -f -X POST http://garage:3903/v2/UpdateClusterLayout \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"roles\": [{\"id\": \"$NODE_ID\", \"zone\": \"dc1\", \"capacity\": 10737418240, \"tags\": []}]}" >/dev/null
echo "Applying cluster layout (version 1)..."
curl -s -f -X POST http://garage:3903/v2/ApplyClusterLayout \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"version": 1}' >/dev/null || true
fi
echo "Importing S3 Access Key..."
curl -s -f -X POST http://garage:3903/v2/ImportKey \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"name\": \"shumai-key\", \"accessKeyId\": \"${S3_ACCESS_KEY_ID}\", \"secretAccessKey\": \"${S3_SECRET_ACCESS_KEY}\"}" >/dev/null || true
echo "Creating S3 bucket '${S3_BUCKET}'..."
BUCKET_RESP=$(curl -s -X POST http://garage:3903/v2/CreateBucket \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"globalAlias\": \"${S3_BUCKET}\"}")
echo "$BUCKET_RESP"
BUCKET_ID=$(echo "$BUCKET_RESP" | jq -r '.id // empty')
if [ -z "$BUCKET_ID" ]; then
# Fetch existing bucket ID if already created
BUCKET_ID=$(curl -s -H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" "http://garage:3903/v2/GetBucketInfo?globalAlias=${S3_BUCKET}" | jq -r '.id // empty')
fi
if [ -n "$BUCKET_ID" ]; then
echo "Granting bucket permissions for key on bucket ID $BUCKET_ID..."
curl -s -f -X POST http://garage:3903/v2/AllowBucketKey \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"bucketId\": \"${BUCKET_ID}\", \"accessKeyId\": \"${S3_ACCESS_KEY_ID}\", \"permissions\": {\"read\": true, \"write\": true, \"owner\": true}}" >/dev/null || true
fi
echo "Configuring S3 bucket CORS for web uploads..."
AWS_ACCESS_KEY_ID=${S3_ACCESS_KEY_ID} \
AWS_SECRET_ACCESS_KEY=${S3_SECRET_ACCESS_KEY} \
AWS_DEFAULT_REGION=garage \
aws --endpoint-url http://garage:3900 s3api put-bucket-cors \
--bucket "${S3_BUCKET}" \
--cors-configuration '{"CORSRules":[{"AllowedHeaders":["*"],"AllowedMethods":["GET","PUT","POST","DELETE","HEAD"],"AllowedOrigins":["*"],"ExposeHeaders":["ETag"],"MaxAgeSeconds":3000}]}' || true
echo "✅ Garage S3 storage cluster initialized successfully!"
+11
View File
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- config.yaml
- postgres.yaml
- garage.yaml
- shumai-server.yaml
- shumai-transcode.yaml
- shumai-transcode-hpa.yaml
+4
View File
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: shumai
+78
View File
@@ -0,0 +1,78 @@
apiVersion: v1
kind: Service
metadata:
name: shumai-postgres
namespace: shumai
labels:
app: shumai-postgres
spec:
ports:
- port: 5432
name: postgres
selector:
app: shumai-postgres
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: shumai-postgres
namespace: shumai
spec:
serviceName: shumai-postgres
replicas: 1
selector:
matchLabels:
app: shumai-postgres
template:
metadata:
labels:
app: shumai-postgres
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: eks.amazonaws.com/nodegroup
operator: In
values:
- shumai-general-spot
- matchExpressions:
- key: workload
operator: In
values:
- general
containers:
- name: postgres
image: pgvector/pgvector:pg18
ports:
- containerPort: 5432
name: postgres
env:
- name: POSTGRES_USER
value: 'shumai'
- name: POSTGRES_PASSWORD
value: 'shumai_password'
- name: POSTGRES_DB
value: 'shumai_db'
- name: PGDATA
value: '/var/lib/postgresql/18/docker/pgdata'
readinessProbe:
exec:
command:
- sh
- -c
- pg_isready -U shumai -d shumai_db
initialDelaySeconds: 5
periodSeconds: 5
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql/18/docker
volumeClaimTemplates:
- metadata:
name: postgres-data
spec:
accessModes: ['ReadWriteOnce']
resources:
requests:
storage: 5Gi
+86
View File
@@ -0,0 +1,86 @@
apiVersion: v1
kind: Service
metadata:
name: shumai-server
namespace: shumai
labels:
app: shumai-server
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 3000
name: http
- port: 3000
targetPort: 3000
name: http-alt
selector:
app: shumai-server
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: shumai-server
namespace: shumai
labels:
app: shumai-server
spec:
replicas: 1
selector:
matchLabels:
app: shumai-server
template:
metadata:
labels:
app: shumai-server
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: eks.amazonaws.com/nodegroup
operator: In
values:
- shumai-general-spot
- matchExpressions:
- key: workload
operator: In
values:
- general
containers:
- name: server
image: shumaione/shumai:latest
imagePullPolicy: IfNotPresent
env:
- name: SHUMAI_WORKERS
value: 'agent'
# For cloud deployments, set to your public S3 / Garage LoadBalancer endpoint
- name: AWS_PUBLIC_ENDPOINT_URL_S3
value: 'http://localhost:3900'
envFrom:
- configMapRef:
name: shumai-config
- secretRef:
name: shumai-secret
ports:
- containerPort: 3000
name: http
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 2000m
memory: 2Gi
readinessProbe:
httpGet:
path: /
port: 3000
initialDelaySeconds: 10
periodSeconds: 5
livenessProbe:
tcpSocket:
port: 3000
initialDelaySeconds: 15
periodSeconds: 10
+39
View File
@@ -0,0 +1,39 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: shumai-transcode-hpa
namespace: shumai
labels:
app: shumai-transcode
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: shumai-transcode
minReplicas: 1
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
behavior:
scaleUp:
stabilizationWindowSeconds: 0
selectPolicy: Max
policies:
- type: Percent
value: 100
periodSeconds: 15
- type: Pods
value: 2
periodSeconds: 15
scaleDown:
stabilizationWindowSeconds: 300
selectPolicy: Min
policies:
- type: Pods
value: 1
periodSeconds: 60
+55
View File
@@ -0,0 +1,55 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: shumai-transcode
namespace: shumai
labels:
app: shumai-transcode
spec:
replicas: 1
selector:
matchLabels:
app: shumai-transcode
template:
metadata:
labels:
app: shumai-transcode
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: eks.amazonaws.com/nodegroup
operator: In
values:
- shumai-transcode-spot
- matchExpressions:
- key: workload
operator: In
values:
- transcode
terminationGracePeriodSeconds: 300
containers:
- name: worker
image: shumaione/shumai-transcode:latest
imagePullPolicy: IfNotPresent
env:
# Downward API: Injects the unique pod name so DbosExecutor assigns a unique,
# deterministic executor ID per worker replica across pod restarts.
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
envFrom:
- configMapRef:
name: shumai-config
- secretRef:
name: shumai-secret
resources:
requests:
cpu: 3000m
memory: 4Gi
limits:
cpu: 3900m
memory: 6Gi