我想将 PersistentVolumeClaim 与 gcePersistentDisk PersistentVolume 绑定。在我为得到它所做的步骤下面:
1. gcePersistentDisk 的创建:
gcloud compute disks create --size=2GB --zone=us-east1-b gce-nfs-disk
2. 定义 PersistentVolume 和 PersistentVolumeClaim
# pv-pvc.yml
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-pv
spec:
capacity:
storage: 2Gi
accessModes:
- ReadWriteOnce
gcePersistentDisk:
pdName: gce-nfs-disk
fsType: ext4
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs-pvc
labels:
app: test
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
运行后kubectl apply -f pv-pvc.yml
,nfs-pvc
不绑定nfs-pv
。事实上,下面是我拥有的 PersistentVolume 和 PersistentVolumeClaim 的列表:
$ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
nfs-pv 2Gi RWO Retain Available 30s
pvc-16e4cdf2-cd3d-11e7-83ae-42010a8e0243 2Gi RWO Delete Bound default/nfs-pvc standard 26s
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
nfs-pvc Bound pvc-16e4cdf2-cd3d-11e7-83ae-42010a8e0243 2Gi RWO standard 59s
得到的 PersistentVolume 是我在 Google Container Engine 上创建的节点的磁盘上的一个卷。那么,我错过了什么吗?
PS:kubernetes的版本
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.3", GitCommit:"f0efb3cb883751c5ffdbe6d515f3cb4fbe7b7acd", GitTreeState:"clean", BuildDate:"2017-11-08T18:39:33Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"7+", GitVersion:"v1.7.8-gke.0", GitCommit:"a7061d4b09b53ab4099e3b5ca3e80fb172e1b018", GitTreeState:"clean", BuildDate:"2017-10-10T18:48:45Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}