简体   繁体   English

是否可以使用 AWS EFS 访问点在 EKS 中安装 kubernetes 持久卷?

[英]Is it possible to use AWS EFS access points to mount a kubernetes persistent volume in EKS?

First of all to put some context on that question.首先要为这个问题提供一些背景信息。

  • I have an EKS cluster with version >= 1.15我有一个版本 >= 1.15EKS集群
  • The EFS - EKS security group / mount target etc. are working properly EFS - EKS security group / mount target等工作正常
  • The CSI driver for EFS in EKS is installed and work as expected EKSEFSCSI驱动程序已安装并按预期工作
  • I have deployed a storage class called efs-sc using the EFS CSI driver as a provisioner我已经部署了一个名为efs-sc的存储 class,使用EFS CSI驱动程序作为配置器
  • I can access the EFS volume on the pod我可以访问 pod 上的EFS

But... it only works if it is the root path / that is defined as the path in the kubernetes persistent volume resource definition.但是......它仅在根路径/被定义为kubernetes持久卷资源定义中的路径时才有效。

Example with Terraform 0.12 syntax Terraform 0.12 语法示例

resource "kubernetes_persistent_volume" "vol" {
  metadata {
    name = "my-vol"
  }
  spec {
    capacity = {
      storage = "15Gi"
    }
    access_modes = ["ReadWriteMany"]
    storage_class_name = "efs-sc"
    persistent_volume_reclaim_policy = "Recycle"
    persistent_volume_source {
      nfs {
        path = "/" # -> OK it works properly
        # path = "/access-point-path" -> NOT WORKING
        server = var.efs-storage-apt-server
      }
    }
  }
}

When I try to specify the path of my access point the mounting of the volume fails.当我尝试指定访问点的路径时,卷的安装失败。

The efs access point is configured like this efs接入点是这样配置的

在此处输入图像描述

So is it a limitation?那么这是一个限制吗? Did I miss something?我错过了什么?

I was looking about this solution efs-provisioner but I don't see what this will solve from this current configuration.我正在寻找这个解决方案efs-provisioner但我看不出这将从当前配置中解决什么问题。

What seems to be happening is that the path /access-point-path does not exist inside your mounted filesystem.似乎正在发生的事情是路径/access-point-path在您安装的文件系统中不存在。

When you use access points, the path specified by the access point is mounted as the / of the filesystem.使用接入点时,接入点指定的路径挂载为文件系统的/

Let's suppose this is the state of your EFS :假设这是您的EFS的 state :

|__ access-point-path/

When you mount it in your deployment using access point in /access-point-path , it only sees an empty folder, because the access-point-path folder is now the root directory ( / ) of your deployment.当您使用/access-point-path中的访问点将其挂载到部署中时,它只会看到一个空文件夹,因为access-point-path文件夹现在是部署的根目录 ( / )。 There is no access-point-path folder to bind.没有要绑定access-point-path文件夹。

That's why the / works and the access-point-path/ does not.这就是/有效而access-point-path/无效的原因。

There's now documentation available: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/access_points/README.md#create-access-points-in-efs现在有可用的文档: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/access_points/README.md#create-access-points-in-efs

You'll need to be using the updated EFS CSI driver.您需要使用更新的 EFS CSI 驱动程序。 The access point is defined under PersistentVolume's volumeHandle .访问点在 PersistentVolume 的volumeHandle下定义。 The recent EFS CSI driver no longer supports dynamic binding, hence, the PersistentVolume needs to be created manually for each PersistentVolumeClaim.最近的 EFS CSI 驱动程序不再支持动态绑定,因此,需要为每个 PersistentVolumeClaim 手动创建 PersistentVolume。

apiVersion: v1
kind: PersistentVolume
metadata:
  name: efs-pv1
spec:
  capacity:
    storage: 5Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  storageClassName: efs-sc
  csi:
    driver: efs.csi.aws.com
    volumeHandle: [FileSystemId]::[AccessPointId]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM