Kubernetes作业和持久卷声明的Django迁移
使用Kubernetes Django部署的应用程序上的作业和持久卷声明进行迁移和迁移模型的最佳方法是什么 持续容积Kubernetes作业和持久卷声明的Django迁移,django,kubernetes,migration,persistent-volumes,persistent-volume-claims,Django,Kubernetes,Migration,Persistent Volumes,Persistent Volume Claims,使用Kubernetes Django部署的应用程序上的作业和持久卷声明进行迁移和迁移模型的最佳方法是什么 持续容积 apiVersion: v1 kind: PersistentVolumeClaim metadata: name: csi-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 5Gi storageClassName: do-block-storage
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: csi-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: do-block-storage
工作
我看起来不错。不确定是否需要在新pod启动时运行此作业一次或每次 如果它在Django服务吊舱每次启动之前运行,也许您可以获得帮助 例如:
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: myapp-container
image: busybox:1.28
command: ['sh', '-c', 'echo The app is running! && sleep 3600']
initContainers:
- name: init-myservice
image: busybox:1.28
command: ['sh', '-c', 'until nslookup myservice; do echo waiting for myservice; sleep 2; done;']
- name: init-mydb
image: busybox:1.28
command: ['sh', '-c', 'until nslookup mydb; do echo waiting for mydb; sleep 2; done;']
您可以对部署执行相同的操作工作正常测试。。注意集装箱代码目录。。您需要挂载绝对路径
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: myapp-container
image: busybox:1.28
command: ['sh', '-c', 'echo The app is running! && sleep 3600']
initContainers:
- name: init-myservice
image: busybox:1.28
command: ['sh', '-c', 'until nslookup myservice; do echo waiting for myservice; sleep 2; done;']
- name: init-mydb
image: busybox:1.28
command: ['sh', '-c', 'until nslookup mydb; do echo waiting for mydb; sleep 2; done;']