简体   繁体   中英

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

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM