我已经成功地创建了一个NFS持久卷和一个持久卷声明,当我运行我的部署时,它完成了它应该做的事情,并在NFS卷上挂载了我的应用程序数据文件夹。一切都很好。
在码头有运行的能力
-v <host dir>:<container dir>我如何告诉部署中的Kubernetes不要使用/kubernetes,而是使用/kubernetes/例如?
当前的工作代码是: nfs-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-pv
spec:
capacity:
storage: 10Gi
volumeMode: Filesystem
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Recycle
storageClassName: nfs
mountOptions:
- hard
nfs:
path: /Dev1Partition1/kubernetes
server: 192.168.40.202nfs-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs-pvc
spec:
storageClassName: nfs
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi当我运行下面的部署时,上面的这些数据会显示在我指定的Kubernetes文件夹中。
这个部署看起来像这个deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: n8n-server
name: n8n-deployment
spec:
replicas: 1
selector:
matchLabels:
run: n8n-deployment
template:
metadata:
labels:
run: n8n-deployment
spec:
volumes:
- name: n8n-pv-storage
persistentVolumeClaim:
claimName: nfs-pvc
containers:
- image: 192.168.40.43:8081/dockercontainers/library/n8n:latest
name: n8n-server
volumeMounts:
- mountPath: "/root/.n8n"
name: n8n-pv-storage
imagePullSecrets:
- name: progercred我试着在卷下添加:
hostPath: path: n8n (and /n8n)
type: Directory这个吐出来了
spec.template.spec.volumes.persistentVolumeClaim:禁忌:不得指定超过1卷类型的spec.template.spec.containers.volumeMounts.name:未找到:“n8n-pv-存储”
我猜是因为hostPath是给emptyDir的?
帮助?
我想对了吗?
发布于 2021-06-18 10:57:01
几乎没有一个PV/PVC/NFS站点提到的是subPath。
因此,在deployment.yaml的containers部分中,更改了
volumeMounts:
- mountPath: "/root/.n8n"
name: n8n-pv-storage
subPath: n8nsubPath指令将在n8n的PV/PVC挂载点上创建一个子目录,该子目录是跨节点持久的。
参考文献:
How to mount the sub path of PVC to the specific path in container https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath
https://stackoverflow.com/questions/68032237
复制相似问题