Split sor-host into dedicated gateway and workers deployments
Before: 3 pods ran ENABLED_SERVICES=all — gateway, auth, and every
business-logic service co-hosted. This defeated the purpose of the
gateway pattern and prevented independent scaling.
After:
sor-gateway (2 replicas) — ENABLED_SERVICES=gateway,auth
• WebSocket edge, accepts client connections
• Auth co-located (JWT validation is a localhost gRPC call, no network hop)
• Lighter resource footprint: 150m/128Mi request, 500m/512Mi limit
• Ingress at hub.aeternalisgames.com → sor-gateway:80
sor-workers (3 replicas) — ENABLED_SERVICES=chat,collection,bazaar,
content,versioning,matchmaking,game
• Subscribes to NATS, handles all business-logic messages
• Holds DB connection pools for all schemas
• Internal only — no ingress
• Heavier resources: 300m/384Mi request, 1000m/1Gi limit
configmap.yaml: removed ENABLED_SERVICES=all and Services__Auth (each
deployment now sets these directly in its own env block)
ingress.yaml: hub.aeternalisgames.com backend sor-host → sor-gateway
ArgoCD prune=true will delete the old sor-host Deployment + Service
from the cluster on next sync.
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -4,22 +4,19 @@ metadata:
|
|||||||
name: sor-config
|
name: sor-config
|
||||||
namespace: stone-server
|
namespace: stone-server
|
||||||
data:
|
data:
|
||||||
# ── SOR.Host ────────────────────────────────────────────────────────────────
|
# ── Shared config (all pods) ─────────────────────────────────────────────────
|
||||||
ENABLED_SERVICES: "all"
|
# ENABLED_SERVICES and Services__Auth are NOT set here — each deployment sets
|
||||||
|
# them directly in its own env block so gateway and workers are independently
|
||||||
|
# configured without a shared ConfigMap override.
|
||||||
ASPNETCORE_URLS: "http://+:8080"
|
ASPNETCORE_URLS: "http://+:8080"
|
||||||
ASPNETCORE_ENVIRONMENT: "Production"
|
ASPNETCORE_ENVIRONMENT: "Production"
|
||||||
|
|
||||||
# WebSocket gateway settings
|
# WebSocket / gateway settings (consumed only by pods running the gateway service)
|
||||||
WebSocket__Path: "/ws"
|
WebSocket__Path: "/ws"
|
||||||
Gateway__AuthTimeoutMs: "10000"
|
Gateway__AuthTimeoutMs: "10000"
|
||||||
Gateway__MaxMessagesPerSecond: "20"
|
Gateway__MaxMessagesPerSecond: "20"
|
||||||
|
|
||||||
# gRPC: gateway calls auth at this address.
|
# NATS message bus
|
||||||
# In single-pod (ENABLED_SERVICES=all) mode both run in the same process on the same port.
|
|
||||||
Services__Auth: "http://localhost:8080"
|
|
||||||
|
|
||||||
# NATS message bus — update to your NATS service address.
|
|
||||||
# TODO: replace with your actual NATS service URL.
|
|
||||||
Nats__Url: "nats://nats.stone-server.svc.cluster.local:4222"
|
Nats__Url: "nats://nats.stone-server.svc.cluster.local:4222"
|
||||||
|
|
||||||
# ── SOR.Admin ───────────────────────────────────────────────────────────────
|
# ── SOR.Admin ───────────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: sor-gateway
|
||||||
|
namespace: stone-server
|
||||||
|
labels:
|
||||||
|
app: sor-gateway
|
||||||
|
spec:
|
||||||
|
replicas: 2
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: sor-gateway
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: sor-gateway
|
||||||
|
spec:
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: harbor-credentials
|
||||||
|
|
||||||
|
containers:
|
||||||
|
- name: sor-gateway
|
||||||
|
image: registry.aeternalisgames.com/sor/sor-server:latest
|
||||||
|
ports:
|
||||||
|
- containerPort: 8080
|
||||||
|
|
||||||
|
# ── Shared non-secret config ───────────────────────────────────────
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: sor-config
|
||||||
|
|
||||||
|
# ── Gateway-specific overrides + secrets ───────────────────────────
|
||||||
|
env:
|
||||||
|
# This pod runs only the WebSocket gateway and the auth gRPC service.
|
||||||
|
# Auth is co-located so JWT validation has no extra network hop.
|
||||||
|
- name: ENABLED_SERVICES
|
||||||
|
value: "gateway,auth"
|
||||||
|
|
||||||
|
# Auth gRPC is in the same process — call ourselves.
|
||||||
|
- name: Services__Auth
|
||||||
|
value: "http://localhost:8080"
|
||||||
|
|
||||||
|
# Postgres — Identity schema only (auth needs it for account lookups).
|
||||||
|
- name: ConnectionStrings__Default
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: sor-app-secrets
|
||||||
|
key: ConnectionStrings__Default
|
||||||
|
|
||||||
|
# Redis — used by gateway for client push delivery.
|
||||||
|
- name: ConnectionStrings__Redis
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: redis-credentials
|
||||||
|
key: connection-string
|
||||||
|
|
||||||
|
# CDN — not used by gateway/auth, but included to keep secret binding uniform.
|
||||||
|
- name: Cdn__PublicBaseUrl
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: sor-app-secrets
|
||||||
|
key: Cdn__PublicBaseUrl
|
||||||
|
- name: Cdn__EndpointUrl
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: sor-app-secrets
|
||||||
|
key: Cdn__EndpointUrl
|
||||||
|
- name: Cdn__AccessKey
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: sor-app-secrets
|
||||||
|
key: Cdn__AccessKey
|
||||||
|
- name: Cdn__SecretKey
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: sor-app-secrets
|
||||||
|
key: Cdn__SecretKey
|
||||||
|
- name: Cdn__BucketName
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: sor-app-secrets
|
||||||
|
key: Cdn__BucketName
|
||||||
|
|
||||||
|
# ── Health checks ──────────────────────────────────────────────────
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /health
|
||||||
|
port: 8080
|
||||||
|
initialDelaySeconds: 15
|
||||||
|
periodSeconds: 30
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 3
|
||||||
|
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /health
|
||||||
|
port: 8080
|
||||||
|
initialDelaySeconds: 10
|
||||||
|
periodSeconds: 10
|
||||||
|
timeoutSeconds: 3
|
||||||
|
failureThreshold: 3
|
||||||
|
|
||||||
|
# ── Resources ─────────────────────────────────────────────────────
|
||||||
|
# Lighter than workers: no business-logic DB connections.
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: "150m"
|
||||||
|
memory: "128Mi"
|
||||||
|
limits:
|
||||||
|
cpu: "500m"
|
||||||
|
memory: "512Mi"
|
||||||
@@ -1,54 +1,56 @@
|
|||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: sor-host
|
name: sor-workers
|
||||||
namespace: stone-server
|
namespace: stone-server
|
||||||
labels:
|
labels:
|
||||||
app: sor-host
|
app: sor-workers
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 3
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: sor-host
|
app: sor-workers
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: sor-host
|
app: sor-workers
|
||||||
spec:
|
spec:
|
||||||
# Pull images from Harbor using the harbor-credentials secret.
|
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: harbor-credentials
|
- name: harbor-credentials
|
||||||
|
|
||||||
containers:
|
containers:
|
||||||
- name: sor-host
|
- name: sor-workers
|
||||||
# CI updates this image tag on every push to master.
|
|
||||||
image: registry.aeternalisgames.com/sor/sor-server:latest
|
image: registry.aeternalisgames.com/sor/sor-server:latest
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
|
|
||||||
# ── Non-secret config from ConfigMap ──────────────────────────────
|
# ── Shared non-secret config ───────────────────────────────────────
|
||||||
envFrom:
|
envFrom:
|
||||||
- configMapRef:
|
- configMapRef:
|
||||||
name: sor-config
|
name: sor-config
|
||||||
|
|
||||||
# ── Secrets injected as individual env vars ────────────────────────
|
# ── Workers-specific overrides + secrets ───────────────────────────
|
||||||
env:
|
env:
|
||||||
# Postgres — from the sor-app-secrets Secret (see deploy/secrets/).
|
# Business-logic services only — no WebSocket, no auth gRPC.
|
||||||
|
# These pods subscribe to NATS and handle all game/store/social messages.
|
||||||
|
- name: ENABLED_SERVICES
|
||||||
|
value: "chat,collection,bazaar,content,versioning,matchmaking,game"
|
||||||
|
|
||||||
|
# Postgres — all schemas (chat, collection, bazaar, catalog, game, identity).
|
||||||
- name: ConnectionStrings__Default
|
- name: ConnectionStrings__Default
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: sor-app-secrets
|
name: sor-app-secrets
|
||||||
key: ConnectionStrings__Default
|
key: ConnectionStrings__Default
|
||||||
|
|
||||||
# Redis — from the pre-existing redis-credentials Secret.
|
# Redis — used by services for client push delivery (IClientPush).
|
||||||
# TODO: verify the key name matches your redis-credentials secret.
|
|
||||||
- name: ConnectionStrings__Redis
|
- name: ConnectionStrings__Redis
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: redis-credentials
|
name: redis-credentials
|
||||||
key: connection-string
|
key: connection-string
|
||||||
|
|
||||||
# CDN (Ceph RadosGW S3-compatible)
|
# CDN — used by content and bazaar services for asset URLs.
|
||||||
- name: Cdn__PublicBaseUrl
|
- name: Cdn__PublicBaseUrl
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
@@ -95,10 +97,11 @@ spec:
|
|||||||
failureThreshold: 3
|
failureThreshold: 3
|
||||||
|
|
||||||
# ── Resources ─────────────────────────────────────────────────────
|
# ── Resources ─────────────────────────────────────────────────────
|
||||||
|
# Heavier than gateway: holds DB connection pools for all service schemas.
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
cpu: "250m"
|
cpu: "300m"
|
||||||
memory: "256Mi"
|
memory: "384Mi"
|
||||||
limits:
|
limits:
|
||||||
cpu: "1000m"
|
cpu: "1000m"
|
||||||
memory: "1Gi"
|
memory: "1Gi"
|
||||||
@@ -43,7 +43,7 @@ spec:
|
|||||||
pathType: Prefix
|
pathType: Prefix
|
||||||
backend:
|
backend:
|
||||||
service:
|
service:
|
||||||
name: sor-host
|
name: sor-gateway
|
||||||
port:
|
port:
|
||||||
number: 80
|
number: 80
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: sor-host
|
name: sor-gateway
|
||||||
namespace: stone-server
|
namespace: stone-server
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
app: sor-host
|
app: sor-gateway
|
||||||
ports:
|
ports:
|
||||||
- name: http
|
- name: http
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: sor-workers
|
||||||
|
namespace: stone-server
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: sor-workers
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
protocol: TCP
|
||||||
|
port: 80
|
||||||
|
targetPort: 8080
|
||||||
|
type: ClusterIP
|
||||||
Reference in New Issue
Block a user