How to prevent two volume claims to claim the same volume on Kubernetes?

情到浓时终转凉″ 提交于 2020-05-13 08:09:04

问题


On my Kubernetes cluster on GKE, I have the following persistent volume claims (PVCs):

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: registry
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 100Gi

and:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: postgresql-blobs
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 100Gi

Amongst others, I have the following persistent volume defined:

kind: PersistentVolume
apiVersion: v1
metadata:
  name: pv0003
spec:
  capacity:
    storage: 100Gi
  accessModes:
    - ReadWriteOnce
    - ReadOnlyMany
  gcePersistentDisk:
    pdName: registry
    fsType: ext4

Now, both claims claimed the same volume:

bronger:~$ kubectl describe pvc postgresql-blobs registry
Name:           postgresql-blobs
Namespace:      default
Status:         Bound
Volume:         pv0003
Labels:         <none>
Capacity:       100Gi
Access Modes:   RWO,ROX


Name:           registry
Namespace:      default
Status:         Bound
Volume:         pv0003
Labels:         <none>
Capacity:       100Gi
Access Modes:   RWO,ROX

Funny enough, the PV knows only about one of the claims:

bronger:~$ kubectl describe pv pv0003
Name:           pv0003
Labels:         <none>
Status:         Bound
Claim:          default/postgresql-blobs
Reclaim Policy: Retain
Access Modes:   RWO,ROX
Capacity:       100Gi
Message:
Source:
    Type:       GCEPersistentDisk (a Persistent Disk resource in Google Compute Engine)
    PDName:     registry
    FSType:     ext4
    Partition:  0
    ReadOnly:   false

How can I prevent this from happening?


回答1:


This is a bug and is fixed by https://github.com/kubernetes/kubernetes/pull/16432



来源:https://stackoverflow.com/questions/33711700/how-to-prevent-two-volume-claims-to-claim-the-same-volume-on-kubernetes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!