6.2.6. Azure File 对象定义

Azure File 存储类使用 secret 来存储创建 Azure File 共享所需的 Azure 存储帐户名称和存储帐户密钥。这些权限是在以下流程中创建的。

流程

  1. 定义允许创建和查看 secret 的 ClusterRole 对象:

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
    #  name: system:azure-cloud-provider
      name: <persistent-volume-binder-role> 1
    rules:
    - apiGroups: ['']
      resources: ['secrets']
      verbs:     ['get','create']
    1
    要查看并创建 secret 的集群角色名称。
  2. 将集群角色添加到服务帐户:

    $ oc adm policy add-cluster-role-to-user <persistent-volume-binder-role>

    输出示例

     system:serviceaccount:kube-system:persistent-volume-binder

  3. 创建 Azure File StorageClass 对象:

    kind: StorageClass
    apiVersion: storage.k8s.io/v1
    metadata:
      name: <azure-file> 1
    provisioner: kubernetes.io/azure-file
    parameters:
      location: eastus 2
      skuName: Standard_LRS 3
      storageAccount: <storage-account> 4
    reclaimPolicy: Delete
    volumeBindingMode: Immediate
    1
    存储类的名称。持久性卷声明使用此存储类来置备关联的持久性卷。
    2
    Azure 存储帐户的位置,如 eastus。默认为空,表示将在 OpenShift Container Platform 集群的位置创建新的 Azure 存储帐户。
    3
    Azure 存储帐户的 SKU 层,如 Standard_LRS。默认为空,表示将使用 Standard_LRS SKU 创建新的 Azure 存储帐户。
    4
    Azure 存储帐户的名称。如果提供了存储帐户,则忽略 skuNamelocation。如果没有提供存储帐户,则存储类会为任何与定义的 skuNamelocation 匹配的帐户搜索与资源组关联的存储帐户。

6.2.6.1. 使用 Azure File 时的注意事项

默认 Azure File 存储类不支持以下文件系统功能:

  • 符号链接
  • 硬链接
  • 扩展属性
  • 稀疏文件
  • 命名管道

另外,Azure File 挂载目录的所有者用户标识符 (UID) 与容器的进程 UID 不同。可在 StorageClass 对象中指定 uid 挂载选项来定义用于挂载的目录的特定用户标识符。

以下 StorageClass 对象演示了修改用户和组标识符,以及为挂载的目录启用符号链接。

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: azure-file
mountOptions:
  - uid=1500 1
  - gid=1500 2
  - mfsymlinks 3
provisioner: kubernetes.io/azure-file
parameters:
  location: eastus
  skuName: Standard_LRS
reclaimPolicy: Delete
volumeBindingMode: Immediate
1
指定用于挂载的目录的用户标识符。
2
指定用于挂载的目录的组标识符。
3
启用符号链接。