简体   繁体   English

kubernetes持久卷ReadWriteOnly(RWO)不适用于nfs

[英]kubernetes persistent volume ReadWriteOnly(RWO) does not work for nfs

there, 那里,

According to the doc: 根据文档:

ReadWriteOnce – the volume can be mounted as read-write by a single node

I created a PV based on nfs: 我基于nfs创建了一个PV:

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

a PVC for this PV: 此PV的PVC:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: sclaim
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 15Gi

After create the PVC bind to the PV: 创建PVC之后,将其绑定到PV:

root@hydra-cdsdev-dal09-0001:~/testscript# kubectl get pvc
NAME      STATUS    VOLUME    CAPACITY   ACCESSMODES   AGE
sclaim    Bound     tspv01    15Gi       RWO           4m

Then I created 2 PODs using the same PVC: 然后,我使用相同的PVC创建了2个POD:

POD1: 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: 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

After I create the 2 PODs, they are assigned to 2 different nodes. 创建2个POD之后,将它们分配给2个不同的节点。 And I can exec into the container, and can read&write in the nfs mounted folder. 我可以执行到容器中,并且可以在nfs挂载的文件夹中进行读写。

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? 有人知道为什么会这样吗?

The accessModes are dependent upon the storage provider. accessModes取决于存储提供程序。 For NFS they don't really do anything different, but a HostPath should use the modes correctly. 对于NFS,它们实际上并没有做任何不同,但是HostPath应该正确使用模式。

See the following table for all the various options: http://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes 有关所有各种选项,请参见下表: http : //kubernetes.io/docs/user-guide/persistent-volumes/#access-modes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有 NFS 持久卷的 Kubernetes statefulset - Kubernetes statefulset with NFS persistent volume 具有 NFS 持久卷配置的 Kubernetes MongoDB pod - Kubernetes MongoDB pods with NFS persistent volume provisioning Kubernetes日志记录架构-NFS持久卷? - Kubernetes logging architecture - NFS Persistent volume? Kubernetes:使用 NFS 的动态持久卷配置 - Kubernetes : Dynamic Persistent Volume provisioning using NFS 在 GKE 上创建一个 Kubernetes Persistent Volume,连接到 GCE 上的外部 NFS 服务器 - Create a Kubernetes Persistent Volume on GKE connected to an external NFS server on GCE kubernetes:使用iSCSI和NFS的动态持久卷配置 - kubernetes : dynamic persistent volume provisioning using iSCSI and NFS NFS卷在kubernetes中不是持久的 - NFS volumes are not persistent in kubernetes 无法在 kubernetes 中挂载 nfs 持久卷,因为每个从节点上都没有安装 nfs 客户端 - Can't mount nfs persistent volume in kubernetes, because there is no nfs client install on each slave node Kubernetes NFS 持久卷 - 在同一卷上有多个声明? 索赔卡在等待中? - Kubernetes NFS Persistent Volumes - multiple claims on same volume? Claim stuck in pending? Kubernetes持久体积与迷你管 - Kubernetes persistent volume with minikube
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM