【发布时间】:2020-07-07 08:00:29
【问题描述】:
我有一个带有文件夹/mnt/kubernetes-volumes/ 的文件服务器。在这个文件夹中,我的应用程序的每个用户都有子目录:
/mnt/kubernetes-volumes/customerA/mnt/kubernetes-volumes/customerB/mnt/kubernetes-volumes/customerC
在每个客户文件夹中,我有两个用于我的数据存储应用程序的文件夹:
/mnt/kubernetes-volumes/customerA/elastic/mnt/kubernetes-volumes/customerA/postgres
我有一个指定持久卷和声明的 Kubernetes 配置文件。这些挂载到elastic 和postgres 文件夹。
# Create a volume on the NFS disk that the postgres db can use.
apiVersion: v1
kind: PersistentVolume
metadata:
namespace: customerA
name: postgres-pv
labels:
name: postgres-volume
spec:
storageClassName: manual
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
nfs:
server: 1.2.3.4 # ip addres of nfs server
path: "/mnt/kubernetes-volumes/customerA/postgres"
---
# And another persistent volume for Elastic
目前,我的/etc/exports 文件如下所示:
/mnt/kubernetes-volumes/customerA/postgres 10.0.0.1(rw,sync,no_subtree_check,no_root_squash)
/mnt/kubernetes-volumes/customerA/elastic 10.0.0.1(rw,sync,no_subtree_check,no_root_squash)
/mnt/kubernetes-volumes/customerA/postgres 10.0.0.2(rw,sync,no_subtree_check,no_root_squash)
/mnt/kubernetes-volumes/customerA/elastic 10.0.0.2(rw,sync,no_subtree_check,no_root_squash)
/mnt/kubernetes-volumes/customerB/postgres 10.0.0.1(rw,sync,no_subtree_check,no_root_squash)
/mnt/kubernetes-volumes/customerB/elastic 10.0.0.1(rw,sync,no_subtree_check,no_root_squash)
/mnt/kubernetes-volumes/customerB/postgres 10.0.0.2(rw,sync,no_subtree_check,no_root_squash)
/mnt/kubernetes-volumes/customerB/elastic 10.0.0.2(rw,sync,no_subtree_check,no_root_squash)
对于每个客户,我为 Kubernetes 集群中的每个节点分别显式导出 postgres 和 elastic 文件夹。这按预期工作。但是,我现在必须为每个新客户手动将行添加到 etc/exports 文件中。是否可以只有这样的两行:
/mnt/kubernetes-volumes/ 10.0.0.1(rw,sync,no_subtree_check,no_root_squash)
/mnt/kubernetes-volumes/ 10.0.0.2(rw,sync,no_subtree_check,no_root_squash)
并自动让 Kubernetes 在kubernetes-volumes 目录中创建正确的子目录(customer、postgres 和 elastic)并挂载它们?
【问题讨论】:
标签: kubernetes nfs