StorageClass - daniel-qa/Azure-Kubernetes-Service GitHub Wiki

  • NFS protocol 的效率會比 SMB protocol 高一些

https://learn.microsoft.com/zh-tw/azure/aks/azure-files-csi#nfs-file-shares

Azure 檔案儲存體 CSI 驅動程式: 新增功能

網路檔案系統 (NFS) 版本 4.1

  • NFS 檔案共用

並提供 POSIX 檔案系統支援。 POSIX:可移植作業系統介面(Portable Operating System Interface of UNIX)

本節說明如何在 AKS 叢集上使用 NFS 共用與 Azure 檔案 CSI 驅動程式。

先決條件:

1.您的 AKS 叢集服務主體或受控識別必須加入儲存體帳戶的參與者角色。

2.您的 AKS 叢集控制平面身分識別 (即您的 AKS 叢集名稱) 會新增至裝載 VNet 之資源群組的參與者角色。

  • 建立 NFS 檔案共用儲存體類別 建立名為 nfs-sc.yaml 的檔案
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: azurefile-csi-nfs
provisioner: file.csi.azure.com
allowVolumeExpansion: true
parameters:
  protocol: nfs
mountOptions:
  - nconnect=8

https://learn.microsoft.com/zh-tw/azure/aks/azure-files-csi

https://github.com/MicrosoftDocs/azure-docs.zh-tw/blob/master/articles/aks/concepts-storage.md

azurefile-csi:使用 Azure 標準儲存體來建立 Azure 檔案儲存體共用。
azurefile-csi-premium:使用 Azure 進階儲存體來建立 Azure 檔案儲存體共用。
  • NFT Stroage Class

nfs-sc.yaml

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: azurefile-csi-nfs
provisioner: azurefile-csi-nfs
allowVolumeExpansion: true
parameters:
  protocol: nfs
mountOptions:
  - nconnect=8

預設的 Storage Class

  • azurefile
  • azurefile-premium
  • azurefile-csi
  • azurefile-csi-premium

https://docs.microsoft.com/zh-tw/azure/aks/azure-files-volume

  • Ex1
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: webfile3
provisioner: kubernetes.io/azure-file
allowVolumeExpansion: true   # 支援增加容量
mountOptions:
  - dir_mode=0777
  - file_mode=0777
  - uid=0
  - gid=0
  - mfsymlinks
  - cache=strict
  - nosharesock
  - nobrl
parameters:
  skuName: Standard_LRS
  • mountOptions
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: my-azurefile
provisioner: file.csi.azure.com # replace with "kubernetes.io/azure-file" if aks version is less than 1.21
allowVolumeExpansion: true   # 支援增加容量
mountOptions:
  - dir_mode=0777
  - file_mode=0777
  - uid=0
  - gid=0
  - mfsymlinks
  - cache=strict
  - actimeo=30
parameters:
  skuName: Premium_LRS

https://docs.microsoft.com/zh-tw/troubleshoot/azure/azure-kubernetes/mountoptions-settings-azure-files

  • webfile 以下為微軟推薦
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: webfile
provisioner: kubernetes.io/azure-file
mountOptions:
  - dir_mode=0777
  - file_mode=0777
  - uid=1000
  - gid=1000
  - mfsymlinks
  - nobrl
  - cache=none
parameters:
  skuName: Standard_LRS

參數說明

  • cache
cache=
Cache mode. See the section below on CACHE COHERENCY for details. Allowed values are:
none: do not cache file data at all
strict: follow the CIFS/SMB2 protocol strictly
loose: allow loose caching semantics
The default in kernels prior to 3.7 was "loose". As of kernel 3.7 the default is "strict".

mfsymlinks: 啟用對符號連結的支援

SKU 主要和備援機制有關

  • 參考

通过添加-o参数指定挂载可选选项:

uid:挂载成功后,文件所属的用户。如果未设置uid,则默认uid=0。
gid:挂载成功后,文件所属的用户组。如果未设置gid,则默认gid=0。
dir_mode:向用户授予指定目录的读取、写入和执行权限。必须以0开头,例如:0755、0644等。如果未设置dir_more,则默认dir_mode=0755。
file_mode:向用户授予普通文件的读取、写入和执行权限。必须以0开头,例如:0755、0644等。如果未设置file_mode,则默认file_mode=0755。
mfsymlinks:支持symbol link功能。
cache:
cache=strict:设置SMB文件系统使用客户端缓存。如果未设置cache,则默认cache=strict。
cache=none:设置SMB文件系统不使用客户端缓存。