45 lines
1.4 KiB
YAML
45 lines
1.4 KiB
YAML
# Snapshot Job — copies prod DB into an experiment slot via sqlite3 .backup
|
|
# Usage: set SLOT to alpha, beta, or gamma before applying
|
|
#
|
|
# SLOT=alpha && sed "s/SLOT/${SLOT}/g" snapshot-job.yaml | kubectl apply -f -
|
|
#
|
|
# The job completes and self-deletes after 5 minutes.
|
|
# Always snapshot before deploying a new experiment to a slot.
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: snapshot-prod-to-SLOT
|
|
namespace: neuron
|
|
spec:
|
|
ttlSecondsAfterFinished: 300
|
|
template:
|
|
spec:
|
|
restartPolicy: Never
|
|
initContainers:
|
|
- name: stop-check
|
|
image: registry.neuralplatform.ai/neural-platform/neuron:latest
|
|
command: ["/bin/sh", "-c", "echo 'Snapshotting prod DB to SLOT — ensure neuron-SLOT pod is stopped first'"]
|
|
containers:
|
|
- name: snapshot
|
|
image: keinos/sqlite3:latest
|
|
command: ["/bin/sh", "-c"]
|
|
args:
|
|
- |
|
|
echo "Starting backup from prod to SLOT..."
|
|
sqlite3 /src/neuron.db ".backup /dst/neuron.db"
|
|
echo "Done. Prod DB snapshotted to SLOT."
|
|
ls -lh /dst/neuron.db
|
|
volumeMounts:
|
|
- name: src
|
|
mountPath: /src
|
|
readOnly: true
|
|
- name: dst
|
|
mountPath: /dst
|
|
volumes:
|
|
- name: src
|
|
persistentVolumeClaim:
|
|
claimName: neuron-data
|
|
- name: dst
|
|
persistentVolumeClaim:
|
|
claimName: neuron-SLOT-data
|