Add CI/CD pipeline, Dockerfiles, and k8s/ArgoCD manifests
- Gitea Actions workflow: build sor-host + sor-admin, push to Harbor, auto-update image tags in k8s manifests (GitOps — ArgoCD watches deploy/k8s/) - Dockerfile.host / Dockerfile.admin: multi-stage .NET 8 builds, non-root runtime - deploy/k8s/: configmap, deployments, services, nginx ingress - hub.aeternalisgames.com → sor-host (WebSocket gateway) - admin.aeternalisgames.com → sor-admin (Blazor admin portal) - hub-tls for hub, cert-manager auto-provisions admin-tls - deploy/secrets/: README + *.yaml.template files to populate (gitignored) - deploy/argo/application.yaml: ArgoCD Application (namespace stone-server) - Root .gitignore: excludes deploy/secrets/*.yaml (never commit populated secrets) 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:
@@ -0,0 +1,37 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: sor-server
|
||||
# ArgoCD is typically installed in the argocd namespace.
|
||||
namespace: argocd
|
||||
# Ensure ArgoCD deletes child resources when this Application is deleted.
|
||||
finalizers:
|
||||
- resources-finalizer.argocd.argoproj.io
|
||||
spec:
|
||||
project: default
|
||||
|
||||
source:
|
||||
# TODO: verify this matches your Gitea repository URL.
|
||||
repoURL: https://git.aeternalisgames.com/dingo/SOR.git
|
||||
targetRevision: master
|
||||
# ArgoCD watches this path for changes and syncs when manifests are updated.
|
||||
path: deploy/k8s
|
||||
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: stone-server
|
||||
|
||||
syncPolicy:
|
||||
automated:
|
||||
# Remove resources from the cluster when removed from git.
|
||||
prune: true
|
||||
# Re-apply if someone manually changes the cluster state.
|
||||
selfHeal: true
|
||||
syncOptions:
|
||||
# Namespace already exists — don't try to create it.
|
||||
- CreateNamespace=false
|
||||
# Apply server-side to avoid annotation length limits.
|
||||
- ServerSideApply=true
|
||||
|
||||
# Show health status on the ArgoCD dashboard.
|
||||
revisionHistoryLimit: 5
|
||||
@@ -0,0 +1,26 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: sor-config
|
||||
namespace: stone-server
|
||||
data:
|
||||
# ── SOR.Host ────────────────────────────────────────────────────────────────
|
||||
ENABLED_SERVICES: "all"
|
||||
ASPNETCORE_URLS: "http://+:8080"
|
||||
ASPNETCORE_ENVIRONMENT: "Production"
|
||||
|
||||
# WebSocket gateway settings
|
||||
WebSocket__Path: "/ws"
|
||||
Gateway__AuthTimeoutMs: "10000"
|
||||
Gateway__MaxMessagesPerSecond: "20"
|
||||
|
||||
# gRPC: gateway calls auth at this address.
|
||||
# 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"
|
||||
|
||||
# ── SOR.Admin ───────────────────────────────────────────────────────────────
|
||||
# Admin inherits ASPNETCORE_URLS and ASPNETCORE_ENVIRONMENT from the same configmap.
|
||||
@@ -0,0 +1,87 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: sor-admin
|
||||
namespace: stone-server
|
||||
labels:
|
||||
app: sor-admin
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: sor-admin
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: sor-admin
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: harbor-credentials
|
||||
|
||||
containers:
|
||||
- name: sor-admin
|
||||
# CI updates this image tag on every push to master.
|
||||
# TODO: replace with your actual Harbor hostname/project before first deploy.
|
||||
image: harbor.aeternalisgames.com/sor/sor-admin:latest
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: sor-config
|
||||
|
||||
env:
|
||||
# Postgres — same database, admin-specific schema access.
|
||||
- name: ConnectionStrings__Default
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: sor-app-secrets
|
||||
key: ConnectionStrings__Default
|
||||
|
||||
# CDN — needed for asset uploads in the admin portal.
|
||||
- name: Cdn__PublicBaseUrl
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: sor-app-secrets
|
||||
key: Cdn__PublicBaseUrl
|
||||
- name: Cdn__UploadBaseUrl
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: sor-app-secrets
|
||||
key: Cdn__UploadBaseUrl
|
||||
- name: Cdn__ApiKey
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: sor-app-secrets
|
||||
key: Cdn__ApiKey
|
||||
|
||||
# ASP.NET Core Data Protection — persists Blazor auth cookies across restarts.
|
||||
# TODO: generate a strong random value and store in sor-app-secrets.
|
||||
- name: DataProtection__ApplicationName
|
||||
value: "sor-admin"
|
||||
|
||||
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:
|
||||
requests:
|
||||
cpu: "100m"
|
||||
memory: "128Mi"
|
||||
limits:
|
||||
cpu: "500m"
|
||||
memory: "512Mi"
|
||||
@@ -0,0 +1,95 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: sor-host
|
||||
namespace: stone-server
|
||||
labels:
|
||||
app: sor-host
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: sor-host
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: sor-host
|
||||
spec:
|
||||
# Pull images from Harbor using the harbor-credentials secret.
|
||||
imagePullSecrets:
|
||||
- name: harbor-credentials
|
||||
|
||||
containers:
|
||||
- name: sor-host
|
||||
# CI updates this image tag on every push to master.
|
||||
# TODO: replace with your actual Harbor hostname/project before first deploy.
|
||||
image: harbor.aeternalisgames.com/sor/sor-host:latest
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
|
||||
# ── Non-secret config from ConfigMap ──────────────────────────────
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: sor-config
|
||||
|
||||
# ── Secrets injected as individual env vars ────────────────────────
|
||||
env:
|
||||
# Postgres — from the sor-app-secrets Secret (see deploy/secrets/).
|
||||
- name: ConnectionStrings__Default
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: sor-app-secrets
|
||||
key: ConnectionStrings__Default
|
||||
|
||||
# Redis — from the pre-existing redis-credentials Secret.
|
||||
# TODO: verify the key name matches your redis-credentials secret.
|
||||
- name: ConnectionStrings__Redis
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: redis-credentials
|
||||
key: connection-string
|
||||
|
||||
# CDN
|
||||
- name: Cdn__PublicBaseUrl
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: sor-app-secrets
|
||||
key: Cdn__PublicBaseUrl
|
||||
- name: Cdn__UploadBaseUrl
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: sor-app-secrets
|
||||
key: Cdn__UploadBaseUrl
|
||||
- name: Cdn__ApiKey
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: sor-app-secrets
|
||||
key: Cdn__ApiKey
|
||||
|
||||
# ── 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 ─────────────────────────────────────────────────────
|
||||
resources:
|
||||
requests:
|
||||
cpu: "250m"
|
||||
memory: "256Mi"
|
||||
limits:
|
||||
cpu: "1000m"
|
||||
memory: "1Gi"
|
||||
@@ -0,0 +1,61 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: sor-ingress
|
||||
namespace: stone-server
|
||||
annotations:
|
||||
# cert-manager: automatically provision / renew Let's Encrypt certs.
|
||||
# TODO: verify your cluster-issuer name (run: kubectl get clusterissuer -A).
|
||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||
|
||||
# Nginx: keep WebSocket connections open for up to 1 hour.
|
||||
# Required so clients don't get disconnected mid-game by proxy timeouts.
|
||||
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
|
||||
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
|
||||
nginx.ingress.kubernetes.io/proxy-connect-timeout: "60"
|
||||
|
||||
# Nginx will forward HTTP → HTTPS and handle the WebSocket Upgrade header.
|
||||
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
||||
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
|
||||
tls:
|
||||
# hub.aeternalisgames.com — game server + WebSocket gateway.
|
||||
# hub-tls already exists in this namespace (your existing Let's Encrypt cert).
|
||||
- hosts:
|
||||
- hub.aeternalisgames.com
|
||||
secretName: hub-tls
|
||||
|
||||
# admin.aeternalisgames.com — admin portal.
|
||||
# cert-manager will auto-provision this cert on first deployment.
|
||||
# TODO: ensure DNS A record for admin.aeternalisgames.com points to your ingress IP.
|
||||
- hosts:
|
||||
- admin.aeternalisgames.com
|
||||
secretName: admin-tls
|
||||
|
||||
rules:
|
||||
# ── Game server / WebSocket gateway ────────────────────────────────────────
|
||||
- host: hub.aeternalisgames.com
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: sor-host
|
||||
port:
|
||||
number: 80
|
||||
|
||||
# ── Admin portal ───────────────────────────────────────────────────────────
|
||||
# Hosted on a separate subdomain to avoid SignalR/Blazor path conflicts.
|
||||
- host: admin.aeternalisgames.com
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: sor-admin
|
||||
port:
|
||||
number: 80
|
||||
@@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: sor-admin
|
||||
namespace: stone-server
|
||||
spec:
|
||||
selector:
|
||||
app: sor-admin
|
||||
ports:
|
||||
- name: http
|
||||
protocol: TCP
|
||||
port: 80
|
||||
targetPort: 8080
|
||||
type: ClusterIP
|
||||
@@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: sor-host
|
||||
namespace: stone-server
|
||||
spec:
|
||||
selector:
|
||||
app: sor-host
|
||||
ports:
|
||||
- name: http
|
||||
protocol: TCP
|
||||
port: 80
|
||||
targetPort: 8080
|
||||
type: ClusterIP
|
||||
@@ -0,0 +1,60 @@
|
||||
# SOR Kubernetes Secrets
|
||||
|
||||
These files are **NOT committed to git** (excluded via root `.gitignore`).
|
||||
The `*.yaml.template` files in this directory ARE committed — copy them, fill in
|
||||
real values, then apply to the cluster.
|
||||
|
||||
---
|
||||
|
||||
## Quick Setup
|
||||
|
||||
### 1. Harbor image pull secret
|
||||
```bash
|
||||
cp harbor-pull-secret.yaml.template harbor-pull-secret.yaml
|
||||
# edit harbor-pull-secret.yaml — fill in your Harbor username and password
|
||||
kubectl apply -f harbor-pull-secret.yaml
|
||||
```
|
||||
|
||||
### 2. Application secrets
|
||||
```bash
|
||||
cp sor-app-secrets.yaml.template sor-app-secrets.yaml
|
||||
# edit sor-app-secrets.yaml — fill in Postgres connection string and CDN credentials
|
||||
kubectl apply -f sor-app-secrets.yaml
|
||||
```
|
||||
|
||||
### 3. Gitea Actions repository secrets
|
||||
In your Gitea repository → Settings → Secrets, add:
|
||||
| Name | Value |
|
||||
|-------------------|--------------------------------|
|
||||
| HARBOR_USERNAME | Your Harbor robot account name |
|
||||
| HARBOR_PASSWORD | Your Harbor robot account token |
|
||||
|
||||
---
|
||||
|
||||
## Secrets Reference
|
||||
|
||||
| Secret Name | Key | Used By | Notes |
|
||||
|--------------------|----------------------------|-----------------|-------------------------------------------|
|
||||
| sor-app-secrets | ConnectionStrings__Default | host + admin | Postgres connection string |
|
||||
| sor-app-secrets | Cdn__PublicBaseUrl | host + admin | e.g. https://cdn.aeternalisgames.com |
|
||||
| sor-app-secrets | Cdn__UploadBaseUrl | host + admin | CDN upload endpoint |
|
||||
| sor-app-secrets | Cdn__ApiKey | host + admin | CDN API key |
|
||||
| redis-credentials | connection-string | host only | **Already exists** in stone-server ns |
|
||||
| harbor-credentials | .dockerconfigjson | both pods | Harbor image pull secret |
|
||||
|
||||
---
|
||||
|
||||
## Notes
|
||||
|
||||
- `redis-credentials` is assumed to already exist in the `stone-server` namespace.
|
||||
If the key name inside it is different from `connection-string`, update
|
||||
`deploy/k8s/deployment-host.yaml` to match.
|
||||
|
||||
- The Redis connection string format expected by StackExchange.Redis:
|
||||
`HOST:PORT,password=PASSWORD,ssl=true,abortConnect=false`
|
||||
|
||||
- The Postgres connection string format expected by Npgsql:
|
||||
`Host=HOST;Port=5432;Database=SOR;Username=USER;Password=PASSWORD;`
|
||||
|
||||
- For production, consider enabling SSL on the Postgres connection:
|
||||
`...;SSL Mode=Require;Trust Server Certificate=true`
|
||||
@@ -0,0 +1,28 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: harbor-credentials
|
||||
namespace: stone-server
|
||||
type: kubernetes.io/dockerconfigjson
|
||||
stringData:
|
||||
# Base64-encoded Docker config JSON.
|
||||
# Easiest way to generate this — run locally then paste the output:
|
||||
#
|
||||
# kubectl create secret docker-registry harbor-credentials \
|
||||
# --docker-server=harbor.aeternalisgames.com \
|
||||
# --docker-username=HARBOR_USERNAME \
|
||||
# --docker-password=HARBOR_PASSWORD \
|
||||
# --namespace=stone-server \
|
||||
# --dry-run=client -o yaml
|
||||
#
|
||||
# TODO: replace with output from the command above.
|
||||
.dockerconfigjson: |
|
||||
{
|
||||
"auths": {
|
||||
"harbor.aeternalisgames.com": {
|
||||
"username": "CHANGEME",
|
||||
"password": "CHANGEME",
|
||||
"auth": "CHANGEME_BASE64_OF_USER:PASS"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: sor-app-secrets
|
||||
namespace: stone-server
|
||||
type: Opaque
|
||||
stringData:
|
||||
# Postgres connection string (shared by sor-host and sor-admin).
|
||||
# Format: Host=HOST;Port=5432;Database=SOR;Username=USER;Password=PASSWORD;
|
||||
ConnectionStrings__Default: "Host=172.10.1.127;Port=5432;Database=SOR;Username=SOR-DBA;Password=CHANGEME"
|
||||
|
||||
# CDN — public URL served to clients, upload endpoint, and API key.
|
||||
Cdn__PublicBaseUrl: "https://CHANGEME"
|
||||
Cdn__UploadBaseUrl: "https://CHANGEME"
|
||||
Cdn__ApiKey: "CHANGEME"
|
||||
Reference in New Issue
Block a user