我正在使用从gcloud组件安装的kubectl的GKE。
我使用kubectl创建了一个具有命名空间范围的pv(gcePersistentDisk)。
apiVersion: v1
kind: PersistentVolume
metadata:
name: cstor-cs-a-disk-david
namespace: ns-david
spec:
gcePersistentDisk:
pdName: cstor-cs-a-disk-david
fsType: ext4
partition: 0
readOnly: false
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
capacity:
storage: 200Gi
这意味着在使用create pv时指定命名空间是/曾经是有效的:
http://kubernetes.io/third_party/swagger-ui/#!/api%2Fv1/createNamespacedPersistentVolume
当我运行'kubectl get pv'时,我可以看到pv。
$ kubectl get pv
NAME LABELS CAPACITY ACCESSMODES STATUS CLAIM REASON
cstor-cs-a-disk-david <none> 214748364800 RWO Available
我没有预料到这一点,因为pv没有使用默认的命名空间范围创建。
如果我指定了一个命名空间参数(无论是否有效),情况也是相同的。
$ kubectl get namespaces
NAME LABELS STATUS
default <none> Active
kube-system <none> Active
ns-david <none> Active
$ kubectl get pv --namespace=demo
NAME LABELS CAPACITY ACCESSMODES STATUS CLAIM REASON
cstor-cs-a-disk-david <none> 214748364800 RWO Available
如果我对此PV创建索赔并使用'kubectl get pvc'进行查询,则无法找到索赔,但在指定正确的命名空间时可以找到。
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: cstor-cs-a-disk-claim-david
namespace: ns-david
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 200Gi
volumeName: cstor-cs-a-disk-david
$ kubectl get pvc
NAME LABELS STATUS VOLUME
$ kubectl get pvc --namespace=ns-david
NAME LABELS STATUS VOLUME
cstor-cs-a-disk-claim-david map[] Bound cstor-cs-a-disk-david
pv是具有命名空间作用域还是全局作用域?