Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PVC not binding to NFS PV #2624

Closed
kamalhussain opened this issue May 22, 2017 · 3 comments
Closed

PVC not binding to NFS PV #2624

kamalhussain opened this issue May 22, 2017 · 3 comments

Comments

@kamalhussain
Copy link

kamalhussain commented May 22, 2017

I am not sure if this is a kops issue but definitely seeing this problem on K8S cluster installed using KOPS. I created a physical volume that uses NFS (AWS EFS) but PVC is not binding to it. Instead it creates another EBS disk. Here is the log:

> 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
@Z3r0Sum
Copy link

Z3r0Sum commented Jun 2, 2017

@kamalhussain this is not a kops issue. In your PVC use the following:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: mynfspvc
  annotations:
    volume.beta.kubernetes.io/storage-class: ""
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 100Gi

You need an annotation so that the PVC does not automatically use a dynamic storage class.

@kamalhussain
Copy link
Author

Thanks. I also figured that I can add a tag "storageClassName" on both PV and PVC to make this work. For example, I added "storageClassName: slow" on both PV and PVC.

@gnufied
Copy link
Member

gnufied commented Mar 1, 2021

For posterity you could also force a PVC to bind to existing PV by specifying volumeName: in pvc spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants