connecting AWS efs with kubernetes

2/11/2018

I am trying to connect AWS efs with Kubernetes, I managed to mount the EFS to all my nodes using the mounting command:

sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 fs-fe058857.efs.us-west-2.amazonaws.com:/ efs

And every change in the efs directory I created I see in every node that is connected to it.

I can see that the EFS are mapped to my nodes When running: df -h

admin@ip-172-20-34-666:~/efs$ df -h
Filesystem                                 Size  Used Avail Use% Mounted on
udev                                        10M     0   10M   0% /dev
tmpfs                                      791M  664K  791M   1% /run
/dev/xvda1                                 120G  3.4G  112G   3% /
tmpfs                                      2.0G     0  2.0G   0% /dev/shm
tmpfs                                      5.0M     0  5.0M   0% /run/lock
tmpfs                                      2.0G     0  2.0G   0% /sys/fs/cgroup
fs-fe058857.efs.us-west-2.amazonaws.com:/  8.0E     0  8.0E   0% /home/admin/efs

Now I tried to run a pod which is using that EFS, So I created a simple pod and mounted the /efs directory to the claim I created like that:

      volumeMounts:
        - name: cassandra
          mountPath: /efs  

  volumes:
    - name: cassandra
      persistentVolumeClaim:
        claimName: persistantvolumeclaim
  imagePullSecrets:
    - name: mprestg-credentials   

pv yaml:

--- 
apiVersion: v1
kind: PersistentVolume
metadata: 
  name: persistant
spec: 
  accessModes: 
    - ReadWriteOnce
  capacity: 
    storage: 1Gi
  nfs: 
    path: "/"
    server: us-west-2a.fs-fe058857.efs.us-west-2.amazonaws.com

when I get inside the pod and create a file inside that mounted folder I can see that file even after I terminate the pod and a new one is starting, But when I try to see that file inside the efs mounted directory of one of the nodes - I can not see it.

df -h inside the pod give me this:

root@dummy-pod1:/# df -h
Filesystem      Size  Used Avail Use% Mounted on
overlay         120G  4.0G  111G   4% /
tmpfs           2.0G     0  2.0G   0% /dev
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/xvdbw      976M  1.3M  908M   1% /efs
/dev/xvda1      120G  4.0G  111G   4% /etc/hosts
shm              64M     0   64M   0% /dev/shm
tmpfs           2.0G   12K  2.0G   1% /run/secrets/kubernetes.io/serviceaccount
tmpfs           2.0G     0  2.0G   0% /sys/firmware

Where can I find the files I created inside the pod? and can I do it the other way and copy files to the mounted EFS directory from one of the nodes and use it from the pod?

-- Shachar Hamuzim Rajuan
amazon-efs
amazon-web-services
kubernetes

0 Answers