在 Azure 文件存储中使用 mountOptions 设置

本文讨论在 Azure 文件存储上配置存储类对象时建议的装载选项。 这些装载选项有助于在 Kubernetes 群集上预配存储。

对于服务器消息块(SMB)和网络文件系统(NFS)共享,建议使用以下 mountOptions 设置:

  • SMB 共享

    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: azurefile-csi
    provisioner: file.csi.azure.com
    allowVolumeExpansion: true
    parameters:
      skuName: Premium_LRS  # available values: Premium_LRS, Premium_ZRS, Standard_LRS, Standard_GRS, Standard_ZRS, Standard_RAGRS, Standard_RAGZRS
    reclaimPolicy: Delete
    volumeBindingMode: Immediate
    mountOptions:
      - dir_mode=0777  # modify this permission if you want to enhance the security
      - file_mode=0777 # modify this permission if you want to enhance the security
      - mfsymlinks    # support symbolic links
      - cache=strict  # https://linux.die.net/man/8/mount.cifs
      - nosharesock  # reduces probability of reconnect race
      - actimeo=30  # reduces latency for metadata-heavy workload
      - nobrl  # disable sending byte range lock requests to the server and for applications which have challenges with posix locks
    
  • NFS 共享

    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: azurefile-csi-nfs
    provisioner: file.csi.azure.com
    parameters:
      protocol: nfs
      skuName: Premium_LRS     # available values: Premium_LRS, Premium_ZRS
    reclaimPolicy: Delete
    volumeBindingMode: Immediate
    allowVolumeExpansion: true
    mountOptions:
      - nconnect=4  # improves performance by enabling multiple connections to share
      - noresvport  # improves availability
      - actimeo=30  # reduces latency for metadata-heavy workloads
    

注释

配置装载选项的位置(mountOptions)取决于是预配动态持久性卷还是静态持久性卷。 如果使用存储类 动态预配卷 ,请在存储类对象(kind: StorageClass)上指定装载选项。 如果您静态预配卷,请在PersistentVolume对象的kind: PersistentVolume上指定装载选项。 如果将文件共享装载为内联卷,请在对象Podkind: Pod中指定装载选项。

详细信息

有关 Azure 文件存储的最佳做法,请参阅 预配 Azure 文件存储

联系我们寻求帮助

如果有疑问,可以询问 Azure 社区支持。 还可以将产品反馈提交到 Azure 反馈社区