2017-04-12 49 views
0

Kubernetes新近穩定的Auto-Provisioning features看起來消除了定義PersistentVolume的需求,並基於其StorageClass導致PersistentVolumeClaim滿足其需求。Kubernetes 1.6使用NFS自動配置

這一切似乎有點簡單,但我在一個小的損失,下面PVC和PV將被捆綁在一起,做什麼,當談到更新我的清單爲canonical NFS example

1.6和之前其他幾個服務可以使用ReadWriteMany PVC nfs-pvc沒有問題

apiVersion: v1 
kind: PersistentVolume 
metadata: 
    name: nfs 
    namespace: staging 
spec: 
    capacity: 
    storage: 1Mi 
    accessModes: [ "ReadWriteMany" ] 
    persistentVolumeReclaimPolicy: Delete 
    nfs: 
    # FIXME: use the right IP 
    server: 10.7.252.23 
    path: "/exports" 
--- 
kind: PersistentVolumeClaim 
apiVersion: v1 
metadata: 
    name: nfs-pvc 
    namespace: staging 
spec: 
    accessModes: [ "ReadWriteMany" ] 
    resources: 
    requests: 
     storage: 1Mi 

(請注意,只有現在我已經加入persistentVolumeReclaimPolicy但不影響東西)

然而,在1.6,RU在此明細表中導致額外的PV pv/pvc-75f9e8d1-1f69-11e7-b065-42010a84002d。大概這是由於自動配置。不幸的是,這不是NFS。

Matthews-iMac:gke matt$ k get pv,pvc 
NAME           CAPACITY ACCESSMODES RECLAIMPOLICY STATUS  CLAIM       STORAGECLASS REASON AGE 
pv/nfs          1Mi  RWX   Delete   Available                18m 
pv/postgres-volume       100Gi  RWO   Retain   Bound  default/postgres-storage-claim fast      16h 
pv/pvc-630748eb-1f69-11e7-b065-42010a84002d 100Gi  RWO   Delete   Bound  staging/nfs-server-pvc   standard     18m 
pv/pvc-75f9e8d1-1f69-11e7-b065-42010a84002d 1Gi  RWX   Delete   Bound  staging/nfs-pvc     standard     18m 

NAME     STATUS VOLUME          CAPACITY ACCESSMODES STORAGECLASS AGE 
pvc/nfs-pvc   Bound  pvc-75f9e8d1-1f69-11e7-b065-42010a84002d 1Gi  RWX   standard  18m 
pvc/nfs-server-pvc Bound  pvc-630748eb-1f69-11e7-b065-42010a84002d 100Gi  RWO   standard  18m 

我想我可能會錯過關於selector或什麼的東西?我嘗試添加selector -> matchLabel,但顯然GCE配置程序不支持此功能。感謝您的幫助

回答

1

所以,我想我已經到了這個底部。 documentation

圍繞「Class」提到,當啓用「允許插件」(因爲它在GKE上)時,有必要在PVC中指定a storageClass: ""。這實際上意味着PVC將僅被考慮用於沒有storageClass的PV。

這是我更新的清單:

apiVersion: v1 
kind: PersistentVolume 
metadata: 
    name: nfs 
    namespace: staging 
spec: 
    capacity: 
    storage: 1Mi 
    accessModes: [ "ReadWriteMany" ] 
    persistentVolumeReclaimPolicy: Delete 
    nfs: 
    # FIXME: use the right IP 
    server: 10.7.252.23 
    path: "/exports" 
--- 
kind: PersistentVolumeClaim 
apiVersion: v1 
metadata: 
    name: nfs-pvc 
    namespace: staging 
spec: 
    accessModes: [ "ReadWriteMany" ] 
    resources: 
    requests: 
     storage: 1Mi 
    storageClassName: "" # setting this to empty means this pvc can only be bound to pv with no class (i.e. not dynamically provisioned!) 

而且我綁定的實例:

Matthews-iMac:gke matt$ k get pv,pvc 
NAME           CAPACITY ACCESSMODES RECLAIMPOLICY STATUS  CLAIM       STORAGECLASS REASON AGE 
pv/nfs          1Mi  RWX   Delete   Bound  staging/nfs-pvc           5m 
pv/postgres-volume       100Gi  RWO   Retain   Bound  default/postgres-storage-claim fast      18h 
pv/pvc-1d61980f-1f67-11e7-b065-42010a84002d 1Gi  RWX   Delete   Released staging/nfs-pvc     standard     2h 
pv/pvc-630748eb-1f69-11e7-b065-42010a84002d 100Gi  RWO   Delete   Bound  staging/nfs-server-pvc   standard     1h 

NAME     STATUS VOLUME          CAPACITY ACCESSMODES STORAGECLASS AGE 
pvc/nfs-pvc   Bound  nfs          1Mi  RWX       5m 
pvc/nfs-server-pvc Bound  pvc-630748eb-1f69-11e7-b065-42010a84002d 100Gi  RWO   standard  1h 
Matthews-iMac:gke matt$ 
+0

這篇解決方案爲您工作? –

+0

是的,PVC和PV按預期加入 – elmpp