Files
pages/deploy/kubernetes/exhibition/bootstrap.yaml
T
Anya Tokugawa 4a863fe63c chore(exhibition): preserve deployment and synthetic demo tooling
Separate one-time bootstrap, historical deployment examples and local validation. Document final hostname and historical status; exclude credentials and runtime data.
2026-11-30 23:14:24 +09:00

95 lines
3.9 KiB
YAML

# One-time, fresh exhibition only. SQLite lives on emptyDir, NEVER on NFS.
# Refuses any second import. Keep the completed Job until verification ends.
apiVersion: batch/v1
kind: Job
metadata: {name: pageswiki-exhibition-bootstrap}
spec:
backoffLimit: 0
activeDeadlineSeconds: 1800
template:
metadata:
labels: {pageswiki-db-client: 'true'}
spec:
restartPolicy: Never
automountServiceAccountToken: false
securityContext:
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
seccompProfile: {type: RuntimeDefault}
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels: {app: pageswiki-postgres}
topologyKey: kubernetes.io/hostname
initContainers:
- name: initialize-local-source
image: python@sha256:9ef1a599f863231c3d91e941389bfdc4a2d6070557243d54df1a4e57015b960e
command: [python3, -c, "import os; os.chown('/data', 10001, 10001)"]
securityContext:
runAsNonRoot: false
runAsUser: 0
runAsGroup: 0
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities: {drop: [ALL], add: [CHOWN]}
resources:
requests: {cpu: 50m, memory: 32Mi}
limits: {cpu: 100m, memory: 64Mi}
volumeMounts:
- {name: source, mountPath: /data}
containers:
- name: bootstrap
image: git.anya.jp/anya/pageswiki-app@sha256:a999fe16f11ef91dbdb9904c63bb43d9ec3caef93f77cc07b1fe4a80460f67f9
command: [/bin/sh, -ec]
args:
- |
umask 077
test ! -e /persistent/import-complete.json
PAGESWIKI_DB_BACKEND=sqlite /pageswiki >/tmp/bootstrap.log 2>&1 &
pid=$!
trap 'kill -TERM "$pid" 2>/dev/null || true' EXIT
healthy=false
for attempt in $(seq 1 120); do
if wget -q -O /dev/null http://127.0.0.1:3000/health; then healthy=true; break; fi
kill -0 "$pid"
sleep 1
done
test "$healthy" = true
kill -TERM "$pid"
wait "$pid"
trap - EXIT
/pageswiki migrate-postgres --data-dir /data --apply --timeout 20m >/persistent/import-report.pending.json
mv /persistent/import-report.pending.json /persistent/import-complete.json
# Preserve the stopped synthetic source for audit, not runtime use.
mkdir /persistent/bootstrap-source
cp /data/pages.db /persistent/bootstrap-source/pages.db
echo 'Synthetic namespace initialized and verified PostgreSQL import committed.'
env:
- {name: PAGESWIKI_DATA_DIR, value: /data}
- name: PAGESWIKI_AUTH_KEY
valueFrom: {secretKeyRef: {name: pageswiki-exhibition-app, key: auth-key}}
- name: PAGESWIKI_POSTGRES_DSN
valueFrom: {secretKeyRef: {name: pageswiki-exhibition-app, key: postgres-dsn}}
securityContext:
allowPrivilegeEscalation: false
capabilities: {drop: [ALL]}
resources:
requests: {cpu: 250m, memory: 512Mi}
limits: {cpu: '1', memory: 2Gi}
volumeMounts:
- {name: source, mountPath: /data}
- {name: data, mountPath: /data/documents, subPath: pageswiki-exhibit-v018/wiki/documents}
- {name: data, mountPath: /persistent, subPath: pageswiki-exhibit-v018/wiki}
- {name: ca, mountPath: /pg-ca, readOnly: true}
volumes:
- name: source
emptyDir: {}
- name: data
persistentVolumeClaim: {claimName: pageswiki-data}
- name: ca
secret:
secretName: pageswiki-exhibition-tls
items: [{key: ca.crt, path: ca.crt}]