The maintainer's login Secrets carry pg_service.conf ([evolution]), pgpass and ca.crt. Add a strict read_pg_service (known keys only, verify-full unless a local socket, bounded size) behind --pg-service in evo-server and evo-world-clone, mount each login Secret whole in the store Jobs instead of reading aevolution-db, and fix the migrate Job's PGSERVICE to the [evolution] section. Record the store node choice, per-environment databases and the backup plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
164 lines
5.9 KiB
Plaintext
164 lines
5.9 KiB
Plaintext
# M8.3 store Jobs for ONE disposable environment (dev or stage). Not an Argo path.
|
|
# Copy, then replace every REPLACE_* marker (the markers make this file unappliable
|
|
# as committed), and apply by hand:
|
|
# REPLACE_NAMESPACE evolution-dev | evolution-stage (never evolution-world0)
|
|
# REPLACE_DB_CIDR the database VM's address as a /32 (PGHOSTADDR)
|
|
# REPLACE_DB_PORT its port (PGPORT)
|
|
# REPLACE_RUNTIME_ROLE that environment's NOLOGIN runtime group role
|
|
# REPLACE_TOOLS_DIGEST aevolution-postgres-tools image digest (sha256:...)
|
|
# REPLACE_SERVER_DIGEST aevolution server-runtime image digest (sha256:...)
|
|
# Secret contract (docs/infrastructure/ENVIRONMENTS.md, never in Git). Each login
|
|
# Secret is self-contained, with keys pg_service.conf (section [evolution], with
|
|
# sslrootcert=/run/postgres/ca.crt), pgpass and ca.crt:
|
|
# evolution-postgres-migrator the environment's migrator login (migrate-postgres.sh)
|
|
# evolution-postgres-runtime the environment's runtime login (check-store, region)
|
|
# Order: apply the NetworkPolicy, run migrate, then check-store (twice: the second
|
|
# run must report "probe verified", proving the volume survived a new pod).
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: NetworkPolicy
|
|
metadata:
|
|
name: aevolution-database-egress
|
|
namespace: REPLACE_NAMESPACE
|
|
labels:
|
|
app.kubernetes.io/part-of: aevolution
|
|
spec:
|
|
podSelector:
|
|
matchExpressions:
|
|
- key: app.kubernetes.io/component
|
|
operator: In
|
|
values: [migrate, store-check, region]
|
|
policyTypes: [Egress]
|
|
egress:
|
|
- to:
|
|
- ipBlock:
|
|
cidr: REPLACE_DB_CIDR
|
|
ports:
|
|
- {protocol: TCP, port: REPLACE_DB_PORT}
|
|
---
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: aevolution-db-migrate
|
|
namespace: REPLACE_NAMESPACE
|
|
labels:
|
|
app.kubernetes.io/part-of: aevolution
|
|
app.kubernetes.io/component: migrate
|
|
spec:
|
|
backoffLimit: 0
|
|
activeDeadlineSeconds: 180
|
|
ttlSecondsAfterFinished: 86400
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/part-of: aevolution
|
|
app.kubernetes.io/component: migrate
|
|
spec:
|
|
serviceAccountName: aevolution-migrator
|
|
automountServiceAccountToken: false
|
|
restartPolicy: Never
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
runAsUser: 10001
|
|
runAsGroup: 10001
|
|
fsGroup: 10001
|
|
seccompProfile: {type: RuntimeDefault}
|
|
containers:
|
|
- name: migrate
|
|
image: registry.aeternalisgames.com/aeternalis/aevolution-postgres-tools@REPLACE_TOOLS_DIGEST
|
|
env:
|
|
- {name: PGSERVICE, value: evolution}
|
|
- {name: PGSERVICEFILE, value: /run/postgres/pg_service.conf}
|
|
- {name: EVO_PGPASS_SOURCE, value: /run/postgres/pgpass}
|
|
- {name: EVO_PG_RUNTIME_ROLE, value: REPLACE_RUNTIME_ROLE}
|
|
resources:
|
|
requests: {cpu: 100m, memory: 64Mi}
|
|
limits: {memory: 128Mi}
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
readOnlyRootFilesystem: true
|
|
capabilities: {drop: [ALL]}
|
|
volumeMounts:
|
|
- {name: connection, mountPath: /run/postgres, readOnly: true}
|
|
- {name: scratch, mountPath: /tmp}
|
|
volumes:
|
|
- name: connection
|
|
secret:
|
|
secretName: evolution-postgres-migrator
|
|
defaultMode: 0440
|
|
items:
|
|
- {key: pg_service.conf, path: pg_service.conf}
|
|
- {key: pgpass, path: pgpass}
|
|
- {key: ca.crt, path: ca.crt}
|
|
- name: scratch
|
|
emptyDir: {medium: Memory, sizeLimit: 8Mi}
|
|
---
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: aevolution-store-check
|
|
namespace: REPLACE_NAMESPACE
|
|
labels:
|
|
app.kubernetes.io/part-of: aevolution
|
|
app.kubernetes.io/component: store-check
|
|
spec:
|
|
backoffLimit: 0
|
|
activeDeadlineSeconds: 120
|
|
ttlSecondsAfterFinished: 86400
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/part-of: aevolution
|
|
app.kubernetes.io/component: store-check
|
|
spec:
|
|
serviceAccountName: aevolution-region
|
|
automountServiceAccountToken: false
|
|
restartPolicy: Never
|
|
nodeSelector:
|
|
aevolution.io/stores: "true"
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
runAsUser: 10001
|
|
runAsGroup: 10001
|
|
fsGroup: 10001
|
|
seccompProfile: {type: RuntimeDefault}
|
|
containers:
|
|
- name: check-store
|
|
image: registry.aeternalisgames.com/aeternalis/aevolution-server@REPLACE_SERVER_DIGEST
|
|
# libpq ignores a group-readable password file, and Secret volumes are
|
|
# group-readable for a non-root fsGroup, so copy it to private memory first.
|
|
# w1/r1 is a reserved probe namespace, never a real world.
|
|
command: ["/bin/bash", "-c"]
|
|
args:
|
|
- |
|
|
set -eu
|
|
umask 077
|
|
cp /run/postgres/pgpass /tmp/pgpass
|
|
exec /usr/local/bin/evo-world-clone check-store --world 1 --region 1 \
|
|
--objects /objects --pg-service /run/postgres/pg_service.conf \
|
|
--pg-passfile /tmp/pgpass
|
|
resources:
|
|
requests: {cpu: 50m, memory: 64Mi}
|
|
limits: {memory: 256Mi}
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
readOnlyRootFilesystem: true
|
|
capabilities: {drop: [ALL]}
|
|
volumeMounts:
|
|
- {name: objects, mountPath: /objects}
|
|
- {name: connection, mountPath: /run/postgres, readOnly: true}
|
|
- {name: scratch, mountPath: /tmp}
|
|
volumes:
|
|
- name: objects
|
|
persistentVolumeClaim:
|
|
claimName: aevolution-objects
|
|
- name: scratch
|
|
emptyDir: {medium: Memory, sizeLimit: 1Mi}
|
|
- name: connection
|
|
secret:
|
|
secretName: evolution-postgres-runtime
|
|
defaultMode: 0440
|
|
items:
|
|
- {key: pg_service.conf, path: pg_service.conf}
|
|
- {key: pgpass, path: pgpass}
|
|
- {key: ca.crt, path: ca.crt}
|