4.3.2. 在 pod 中挂载 Azure File 共享

创建持久性卷声明后,应用程序就可以使用它。以下示例演示了在 pod 中挂载此共享。

先决条件

  • 已存在一个映射到底层 Azure File 共享的持久性卷声明。

流程

  • 创建可挂载现有持久性卷声明的 pod:

    apiVersion: v1
    kind: Pod
    metadata:
      name: pod-name 1
    spec:
      containers:
        ...
        volumeMounts:
        - mountPath: "/data" 2
          name: azure-file-share
      volumes:
        - name: azure-file-share
          persistentVolumeClaim:
            claimName: claim1 3
    1
    pod 的名称。
    2
    在 pod 中挂载 Azure File 共享的路径。不要挂载到容器 root、/ 或主机和容器中相同的任何路径。如果容器有足够权限,可能会损坏您的主机系统(如主机的 /dev/pts 文件)。使用 /host 挂载主机是安全的。
    3
    之前创建的 PersistentVolumeClaim 对象的名称。