Facing an issue with attaching EFS volume to Kubernetes pods

前端 未结 3 851
不知归路
不知归路 2021-01-18 20:51

I am running my docker containers with the help of kubernetes cluster on AWS EKS. Two of my docker containers are using shared volume and both of these containers are runnin

3条回答
  •  无人共我
    2021-01-18 21:24

    The issue was, I had 2 ec2 instances running, but I mounted EFS volume to only one of the ec2 instances and kubectl was always deploying pods on the ec2 instance which doesn't have the mounted volume. Now I mounted the same volume to both the instances and using PVC, PV like below. It is working fine.

    ec2 mounting: AWS EFS mounting with EC2

    PV.yml

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: efs
    spec:
      capacity:
        storage: 100Mi
      accessModes:
        - ReadWriteMany
      nfs:
        server: efs_public_dns.amazonaws.com
        path: "/"
    

    PVC.yml

    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: efs
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 100Mi
    

    replicaset.yml

    ----- only volume section -----

     volumes:
      - name: test-volume
        persistentVolumeClaim:
          claimName: efs
    

提交回复
热议问题