Containerizes the momentum monolith and packages every run mode for
deployment in a single Kubernetes namespace, with PostgreSQL hosted in
the cluster.
- Dockerfile (python:3.11-slim, non-root, writable /app/data) + .dockerignore
- GitHub Actions workflow publishing to ghcr.io/fez5587/momentum-system
- Helm chart (deploy/helm/momentum):
* PostgreSQL StatefulSet + PVC (single source of truth; schema
auto-creates from storage/pg_schema.sql on first connect)
* App Deployment running run_live_paper.py with the embedded dashboard
(replicas: 1, Recreate; the dashboard's write endpoints need the
in-process TradingExecutionService) + Service/Ingress on 8010, plus a
wait-for-postgres initContainer
* CronJobs for journal / eod-replay / nightly-tune (US/Eastern via
spec.timeZone) sharing the app data PVC
* ConfigMap (tuning env) + Secret (DATABASE_URL/broker keys, existingSecret
supported); DATABASE_URL built from the in-cluster Postgres service
* Optional Grafana provisioned against the in-cluster Postgres
- deploy/README.md with install, secrets, and constraints
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JCVMm2AbmZvvxwLTX6UpNR
68 lines
2.5 KiB
YAML
68 lines
2.5 KiB
YAML
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: {{ include "momentum.postgresName" . }}
|
|
labels:
|
|
{{- include "momentum.labels" . | nindent 4 }}
|
|
app.kubernetes.io/component: postgres
|
|
spec:
|
|
serviceName: {{ include "momentum.postgresName" . }}
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
{{- include "momentum.selectorLabels" (dict "ctx" . "component" "postgres") | nindent 6 }}
|
|
template:
|
|
metadata:
|
|
labels:
|
|
{{- include "momentum.selectorLabels" (dict "ctx" . "component" "postgres") | nindent 8 }}
|
|
spec:
|
|
{{- with .Values.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
containers:
|
|
- name: postgres
|
|
image: {{ .Values.postgres.image | quote }}
|
|
ports:
|
|
- name: postgres
|
|
containerPort: {{ .Values.postgres.port }}
|
|
env:
|
|
- name: POSTGRES_USER
|
|
value: {{ .Values.postgres.username | quote }}
|
|
- name: POSTGRES_DB
|
|
value: {{ .Values.postgres.database | quote }}
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ include "momentum.secretName" . }}
|
|
key: POSTGRES_PASSWORD
|
|
# Keep PGDATA in a subdir so the volume root (lost+found) doesn't clash.
|
|
- name: PGDATA
|
|
value: /var/lib/postgresql/data/pgdata
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: /var/lib/postgresql/data
|
|
readinessProbe:
|
|
exec:
|
|
command: ["pg_isready", "-U", {{ .Values.postgres.username | quote }}, "-d", {{ .Values.postgres.database | quote }}]
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 10
|
|
livenessProbe:
|
|
exec:
|
|
command: ["pg_isready", "-U", {{ .Values.postgres.username | quote }}, "-d", {{ .Values.postgres.database | quote }}]
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 15
|
|
resources:
|
|
{{- toYaml .Values.postgres.resources | nindent 12 }}
|
|
volumeClaimTemplates:
|
|
- metadata:
|
|
name: data
|
|
spec:
|
|
accessModes: ["{{ .Values.postgres.persistence.accessMode }}"]
|
|
{{- if .Values.postgres.persistence.storageClass }}
|
|
storageClassName: {{ .Values.postgres.persistence.storageClass | quote }}
|
|
{{- end }}
|
|
resources:
|
|
requests:
|
|
storage: {{ .Values.postgres.persistence.size | quote }}
|