在 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)取决于是预配动态持久卷还是静态持久卷。 如果要使用存储类 动态预配卷 ,请在存储类对象(类型:StorageClass)上指定装载选项。 如果要 静态预配卷,请在 PersistentVolume 对象上指定装载选项(类型:PersistentVolume)。 如果您要 将文件共享装载为内嵌卷,请在 Pod 对象(类型:Pod)上指定装载选项。

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

联系我们寻求帮助

如果有疑问或需要帮助, 请创建支持请求,或询问 Azure 社区支持。 还可以将产品反馈提交到 Azure 反馈社区