Kubernetes - PVC not binding the NFS PV

5/22/2017

I created a physical volume using NFS and PVC for the same volume. However, the PVC always creates a EBS disk storage instead of binding to the PV. Please see the log below:

> kubectl get pv
NAME      CAPACITY   ACCESSMODES   RECLAIMPOLICY   STATUS      CLAIM     STORAGECLASS   REASON    AGE
mynfspv   100Gi      RWX           Retain          Available                                      7s

create PVC now

> kubectl get pvc
NAME       STATUS    VOLUME                                     CAPACITY   ACCESSMODES   STORAGECLASS   AGE
mynfspvc   Bound     pvc-a081c470-3f23-11e7-9d30-024e42ef6b60   100Gi      RWX           default        4s


> kubectl get pv
NAME                                       CAPACITY   ACCESSMODES   RECLAIMPOLICY   STATUS      CLAIM              STORAGECLASS   REASON    AGE
mynfspv                                    100Gi      RWX           Retain          Available                                               50s
pvc-a081c470-3f23-11e7-9d30-024e42ef6b60   100Gi      RWX           Delete          Bound       default/mynfspvc   default                  17s

nfs-pv.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: mynfspv
  labels:
    name: nfs2
spec:
  capacity:
    storage: 100Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  nfs:
    server: dbc56.efs.us-west-2.amazonaws.com
    path: /

nfs-pvc.yaml

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: mynfspvc
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 100Gi
-- khuss
kubernetes

2 Answers

5/25/2017

Which version of Kube is this ? The root cause is as mentioned by @ddysher. In your setup the "Default" Storage class is "EBS" as you can see in the get pv{c} outputs. According to kube version you can also make use of 'calim selector' in PVC spec. Refer # https://github.com/kubernetes/community/blob/master/contributors/design-proposals/volume-selectors.md

-- Humble
Source: StackOverflow

5/24/2017

It looks like you have dynamic provisioning and default storageclass feature enabled, and the default class is AWS ebs. You can check your default class with following command:

$ kubectl get storageclasses
NAME                 TYPE
standard (default)   kubernetes.io/aws-ebs

If this is correct, then I think you'll need to specify storage class to solve you problem.

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: nfs-class
provisioner: kubernetes.io/fake-nfs

Add storageClassName to both of your PV

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: mynfspvc
spec:
  storageClassName: nfs-class
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 100Gi

and PVC

apiVersion: v1
kind: PersistentVolume
metadata:
  name: mynfspv
  labels:
    name: nfs2
spec:
  storageClassName: nfs-class
  capacity:
    storage: 100Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  nfs:
    server: dbc56.efs.us-west-2.amazonaws.com
    path: /

You can check out https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1 for details.

-- ddysher
Source: StackOverflow