0
我想用nfs創建通用持久性卷。Kubernetes nfs在聲明中定義路徑
PV(NFS):
common-data-pv 1500Gi RWO Retain
192.168.0.24 /home/common-data-pv
我希望有一個如權利要求或吊艙(安裝權利要求)訂閱共數據-PV可以定義路徑例如:
/home/common-data-pv/www-site-1(50GI)
/home/common-data-pv/www-site-2(50GI)
但我在未找到記錄我如何定義這個。
我的光伏實際的conf:
kind: PersistentVolume
apiVersion: v1
metadata:
name: common-data-pv
labels:
type: common
spec:
capacity:
storage: 1500Gi
accessModes:
- ReadWriteMany
nfs:
server: 192.168.122.1
path: "/home/pv/common-data-pv"
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: common-data-pvc
namespace: kube-system
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
selector:
matchLabels:
type: common
使用例:
apiVersion: v1
kind: ReplicationController
metadata:
name: nfs-web-1
namespace: kube-system
spec:
replicas: 2
selector:
role: web-frontend
template:
metadata:
labels:
role: web-frontend
spec:
containers:
- name: web
image: nginx:alpine
ports:
- name: web
containerPort: 80
volumeMounts:
# name must match the volume name below
- name: nfs
mountPath: "/usr/share/nginx/html"
volumes:
- name: nfs
persistentVolumeClaim:
claimName: common-data-pvc
apiVersion: v1
kind: ReplicationController
metadata:
name: nfs-web-2
namespace: kube-system
spec:
replicas: 2
selector:
role: web-frontend
template:
metadata:
labels:
role: web-frontend
spec:
containers:
- name: web
image: nginx:alpine
ports:
- name: web
containerPort: 80
volumeMounts:
# name must match the volume name below
- name: nfs
mountPath: "/usr/share/nginx/html"
volumes:
- name: nfs
persistentVolumeClaim:
claimName: common-data-pvc
是的,我知道;-)。所以想象你創建一個名稱爲nfs-web-2的RC具有相同的PVC或PV,所有文件都在同一目錄中註冊(因此你可以有衝突)。我用一個例子編輯我的問題。 – timactive
您不能在不同的RC /部署中重複使用相同的聲明。您需要爲每個RC使用子目錄並聲明這些目錄。要以自動化的方式執行此操作,您應該使用可爲您創建資源的自動配置器。這是一個nfs-provisioner,作爲一個kubernetes孵化器項目被採用https://github.com/wongma7/nfs-provisioner這是它的未來主頁https://github.com/kubernetes-incubator/nfs-provisioner –