如何防止两个卷声明在 Kubernetes 上声明同一个卷?

2024-05-13

在 GKE 上的 Kubernetes 集群上,我有以下持久卷声明 (PVC):

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

其中,我定义了以下持久卷:

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

现在,这两种说法声称体积相同:

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

有趣的是,PV 只知道其中一项说法:

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

我怎样才能防止这种情况发生?


这是一个错误,已修复https://github.com/kubernetes/kubernetes/pull/16432 https://github.com/kubernetes/kubernetes/pull/16432

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何防止两个卷声明在 Kubernetes 上声明同一个卷? 的相关文章

随机推荐