在 Kubernetes Django 部署的应用程序上使用 Job 和 Persistent Volume Claim 进行迁移和迁移模型的最佳方法是什么?
持久卷
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: csi-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: do-block-storage
工作
apiVersion: batch/v1
kind: Job
metadata:
name: django-migrations-job
spec:
template:
spec:
containers:
- name: app
image: user/app:latest
command: ["/bin/sh", "-c"]
args: ["python manage.py makemigrations app; python manage.py migrate"]
volumeMounts:
- mountPath: "/container-code-dir/app/migrations"
name: my-do-volume
volumes:
- name: my-do-volume
persistentVolumeClaim:
claimName: csi-pvc