如何防止两个卷声明在 Kubernetes 上声明相同的卷?
How to prevent two volume claims to claim the same volume on Kubernetes?
在 GKE 上的 Kubernetes 集群上,我有以下持久卷声明 (PVC):
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: registry
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Gi
和:
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
修复
在 GKE 上的 Kubernetes 集群上,我有以下持久卷声明 (PVC):
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: registry
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Gi
和:
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
修复