kubernetes持久卷ReadWriteOnly(RWO)不适用于nfs [英] kubernetes persistent volume ReadWriteOnly(RWO) does not work for nfs
问题描述
有
根据文档:
ReadWriteOnce – the volume can be mounted as read-write by a single node
我基于nfs创建了一个PV:
I created a PV based on nfs:
apiVersion: v1
kind: PersistentVolume
metadata:
name: tspv01
spec:
capacity:
storage: 15Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Recycle
nfs:
path: /gpfs/fs01/shared/prod/democluster01/dashdb/gamestop/spv01
server: 169.55.11.79
此PV的PVC:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: sclaim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 15Gi
创建PVC之后,将其绑定到PV:
After create the PVC bind to the PV:
root@hydra-cdsdev-dal09-0001:~/testscript# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESSMODES AGE
sclaim Bound tspv01 15Gi RWO 4m
然后我使用相同的PVC创建了2个POD:
Then I created 2 PODs using the same PVC:
POD1:
kind: Pod
apiVersion: v1
metadata:
name: mypodshared1
labels:
name: frontendhttp
spec:
containers:
- name: myfrontend
image: nginx
ports:
- containerPort: 80
name: "http-server"
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: mypd
volumes:
- name: mypd
persistentVolumeClaim:
claimName: sclaim
POD2:
kind: Pod
apiVersion: v1
metadata:
name: mypodshared2
labels:
name: frontendhttp
spec:
containers:
- name: myfrontend
image: nginx
ports:
- containerPort: 80
name: "http-server"
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: mypd
volumes:
- name: mypd
persistentVolumeClaim:
claimName: sclaim
创建2个POD之后,将它们分配给2个不同的节点.而且我可以执行到容器中,并且可以在nfs挂载的文件夹中进行读写.
After I create the 2 PODs, they are assigned to 2 different nodes. And I can exec into the container, and can read&write in the nfs mounted folder.
root@hydra-cdsdev-dal09-0001:~/testscript# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE
mypodshared1 1/1 Running 0 18s 172.17.52.7 169.45.189.108
mypodshared2 1/1 Running 0 36s 172.17.83.9 169.45.189.116
有人知道为什么会这样吗?
Anybody know why this happened?
推荐答案
accessModes取决于存储提供程序.对于NFS,它们实际上并没有做任何不同,但是HostPath应该正确使用模式.
The accessModes are dependent upon the storage provider. For NFS they don't really do anything different, but a HostPath should use the modes correctly.
有关所有各种选项,请参见下表: http: //kubernetes.io/docs/user-guide/persistent-volumes/#access-modes
See the following table for all the various options: http://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes
这篇关于kubernetes持久卷ReadWriteOnly(RWO)不适用于nfs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!