chore: bootstrap infra-k8 scaffold

This commit is contained in:
Noel Sabia committed 2026-11-14 04:16:22 +01:00
commit aeee20cb7f
14 files changed
+1256

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
# Non-secret configuration for PulseCast.
# Namespace-scoped only. Secrets are created by the human, never committed.
apiVersion: v1
kind: ConfigMap
metadata:
name: pulsecast-shared
namespace: fch26-onemanarmy
labels:
app.kubernetes.io/part-of: pulsecast
data:
PUBLIC_WEB_URL: "https://pulse.noelsabia.dev"
PUBLIC_API_URL: "https://api.pulse.noelsabia.dev"
API_INTERNAL_URL: "http://api:8080"
ML_INTERNAL_URL: "http://ml:8000"
CORS_ALLOWED_ORIGINS: "https://pulse.noelsabia.dev,http://localhost:3000"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: web-config
namespace: fch26-onemanarmy
labels:
app.kubernetes.io/name: web
app.kubernetes.io/part-of: pulsecast
data:
NODE_ENV: "production"
HOST: "0.0.0.0"
PORT: "3000"
NUXT_TELEMETRY_DISABLED: "1"
NUXT_PUBLIC_API_BASE: "https://api.pulse.noelsabia.dev"
NUXT_API_INTERNAL_BASE: "http://api:8080"
NUXT_PUBLIC_SSE_URL: "https://api.pulse.noelsabia.dev/api/stream"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: api-config
namespace: fch26-onemanarmy
labels:
app.kubernetes.io/name: api
app.kubernetes.io/part-of: pulsecast
data:
PORT: "8080"
DATA_DIR: "/app/data"
ML_BASE_URL: "http://ml:8000"
ML_TIMEOUT: "1.5s"
SSE_HEARTBEAT: "15s"
CORS_ALLOWED_ORIGINS: "https://pulse.noelsabia.dev,http://localhost:3000"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: ml-config
namespace: fch26-onemanarmy
labels:
app.kubernetes.io/name: ml
app.kubernetes.io/part-of: pulsecast
data:
PORT: "8000"
DATA_DIR: "/app/data"
MODEL_PATH: "/app/model/model.joblib"
PYTHONDONTWRITEBYTECODE: "1"
PYTHONUNBUFFERED: "1"
+107
View File
@@ -0,0 +1,107 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ml
namespace: fch26-onemanarmy
labels:
app.kubernetes.io/name: ml
app.kubernetes.io/component: ml
app.kubernetes.io/part-of: pulsecast
spec:
replicas: 1
revisionHistoryLimit: 2
strategy:
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: ml
template:
metadata:
labels:
app.kubernetes.io/name: ml
app.kubernetes.io/component: ml
app.kubernetes.io/part-of: pulsecast
spec:
automountServiceAccountToken: false
imagePullSecrets:
- name: gitea-regcred
securityContext:
seccompProfile:
type: RuntimeDefault
containers:
- name: ml
image: git.noelsabia.dev/noelsabia/pulsecast-ml:gate1
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8000
protocol: TCP
envFrom:
- configMapRef:
name: ml-config
- configMapRef:
name: pulsecast-shared
env:
- name: HOME
value: /tmp
- name: MPLCONFIGDIR
value: /tmp
resources:
requests:
cpu: 200m
memory: 512Mi
limits:
cpu: "1"
memory: 1Gi
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
volumeMounts:
- name: tmp
mountPath: /tmp
startupProbe:
httpGet:
path: /healthz
port: http
periodSeconds: 2
failureThreshold: 60
livenessProbe:
httpGet:
path: /healthz
port: http
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 3
readinessProbe:
httpGet:
path: /readyz
port: http
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 2
terminationGracePeriodSeconds: 30
volumes:
- name: tmp
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: ml
namespace: fch26-onemanarmy
labels:
app.kubernetes.io/name: ml
app.kubernetes.io/part-of: pulsecast
spec:
type: ClusterIP
selector:
app.kubernetes.io/name: ml
ports:
- name: http
port: 8000
targetPort: http
protocol: TCP
+118
View File
@@ -0,0 +1,118 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
namespace: fch26-onemanarmy
labels:
app.kubernetes.io/name: api
app.kubernetes.io/component: backend
app.kubernetes.io/part-of: pulsecast
spec:
# Scenario state and the SSE hub live in memory. One replica is intentional.
replicas: 1
revisionHistoryLimit: 2
strategy:
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: api
template:
metadata:
labels:
app.kubernetes.io/name: api
app.kubernetes.io/component: backend
app.kubernetes.io/part-of: pulsecast
spec:
automountServiceAccountToken: false
imagePullSecrets:
- name: gitea-regcred
securityContext:
seccompProfile:
type: RuntimeDefault
containers:
- name: api
image: git.noelsabia.dev/noelsabia/pulsecast-api:gate1
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8080
protocol: TCP
envFrom:
- configMapRef:
name: api-config
- configMapRef:
name: pulsecast-shared
env:
- name: HOME
value: /tmp
# Created by the human; see docs/deploy.md. Never commit real credentials.
- name: CONTROL_USER
valueFrom:
secretKeyRef:
name: control-auth
key: CONTROL_USER
- name: CONTROL_PASS
valueFrom:
secretKeyRef:
name: control-auth
key: CONTROL_PASS
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 256Mi
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
volumeMounts:
- name: tmp
mountPath: /tmp
startupProbe:
httpGet:
path: /api/healthz
port: http
periodSeconds: 2
failureThreshold: 30
livenessProbe:
httpGet:
path: /api/healthz
port: http
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 3
readinessProbe:
httpGet:
path: /api/readyz
port: http
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 2
# SSE clients reconnect with retry: 3000; give them a moment on shutdown.
terminationGracePeriodSeconds: 20
volumes:
- name: tmp
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: api
namespace: fch26-onemanarmy
labels:
app.kubernetes.io/name: api
app.kubernetes.io/part-of: pulsecast
spec:
type: ClusterIP
selector:
app.kubernetes.io/name: api
ports:
- name: http
port: 8080
targetPort: http
protocol: TCP
+111
View File
@@ -0,0 +1,111 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
namespace: fch26-onemanarmy
labels:
app.kubernetes.io/name: web
app.kubernetes.io/component: frontend
app.kubernetes.io/part-of: pulsecast
spec:
replicas: 1
revisionHistoryLimit: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
selector:
matchLabels:
app.kubernetes.io/name: web
template:
metadata:
labels:
app.kubernetes.io/name: web
app.kubernetes.io/component: frontend
app.kubernetes.io/part-of: pulsecast
spec:
automountServiceAccountToken: false
imagePullSecrets:
- name: gitea-regcred
securityContext:
seccompProfile:
type: RuntimeDefault
containers:
- name: web
# Replace owner/package only if your Gitea layout differs. Keep the tag in sync with `make build`.
image: git.noelsabia.dev/noelsabia/pulsecast-web:gate1
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 3000
protocol: TCP
envFrom:
- configMapRef:
name: web-config
- configMapRef:
name: pulsecast-shared
env:
- name: HOME
value: /tmp
# Nuxt/Nitro may use a temp dir; keep it on the writable emptyDir.
- name: NITRO_TEMP_DIR
value: /tmp
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
volumeMounts:
- name: tmp
mountPath: /tmp
startupProbe:
httpGet:
path: /
port: http
periodSeconds: 2
failureThreshold: 30
livenessProbe:
httpGet:
path: /
port: http
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 3
readinessProbe:
httpGet:
path: /
port: http
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 2
volumes:
- name: tmp
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: web
namespace: fch26-onemanarmy
labels:
app.kubernetes.io/name: web
app.kubernetes.io/part-of: pulsecast
spec:
type: ClusterIP
selector:
app.kubernetes.io/name: web
ports:
- name: http
port: 3000
targetPort: http
protocol: TCP
+99
View File
@@ -0,0 +1,99 @@
# Cloudflare Tunnel is the only public exposure path.
# Routes are configured in the Cloudflare Zero Trust dashboard:
# pulse.noelsabia.dev -> http://web:3000
# api.pulse.noelsabia.dev -> http://api:8080
# The token lives in the `cloudflared` Secret, created by the human; never in git.
apiVersion: apps/v1
kind: Deployment
metadata:
name: cloudflared
namespace: fch26-onemanarmy
labels:
app.kubernetes.io/name: cloudflared
app.kubernetes.io/component: tunnel
app.kubernetes.io/part-of: pulsecast
spec:
replicas: 1
revisionHistoryLimit: 2
strategy:
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: cloudflared
template:
metadata:
labels:
app.kubernetes.io/name: cloudflared
app.kubernetes.io/component: tunnel
app.kubernetes.io/part-of: pulsecast
spec:
automountServiceAccountToken: false
securityContext:
seccompProfile:
type: RuntimeDefault
containers:
- name: cloudflared
# Public Docker Hub image; no Gitea pull secret needed for this pod.
image: cloudflare/cloudflared:latest
imagePullPolicy: IfNotPresent
args:
- tunnel
- --no-autoupdate
- --metrics
- 0.0.0.0:2000
- run
- --token
- $(TUNNEL_TOKEN)
env:
- name: TUNNEL_TOKEN
valueFrom:
secretKeyRef:
name: cloudflared
key: TUNNEL_TOKEN
- name: HOME
value: /tmp
ports:
- name: metrics
containerPort: 2000
protocol: TCP
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 200m
memory: 128Mi
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
volumeMounts:
- name: tmp
mountPath: /tmp
startupProbe:
httpGet:
path: /ready
port: metrics
periodSeconds: 2
failureThreshold: 30
livenessProbe:
httpGet:
path: /ready
port: metrics
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 3
readinessProbe:
httpGet:
path: /ready
port: metrics
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 2
terminationGracePeriodSeconds: 30
volumes:
- name: tmp
emptyDir: {}