You are viewing documentation for a release that is no longer maintainedSee documentation for the latest supported version 3 or the latest supported version 4.4.8.3. 在特权 pod 中挂载 hostPath 共享 创建持久性卷声明后,应用程序就可以使用它。以下示例演示了在 pod 中挂载此共享。 先决条件 已存在一个映射到底层 hostPath 共享的持久性卷声明。 流程 创建可挂载现有持久性卷声明的特权 pod: apiVersion: v1 kind: Pod metadata: name: pod-name spec: containers: ... securityContext: privileged: true volumeMounts: - mountPath: /data name: hostpath-privileged ... securityContext: {} volumes: - name: hostpath-privileged persistentVolumeClaim: claimName: task-pvc-volume apiVersion: v1 kind: Pod metadata: name: pod-name 1 spec: containers: ... securityContext: privileged: true 2 volumeMounts: - mountPath: /data 3 name: hostpath-privileged ... securityContext: {} volumes: - name: hostpath-privileged persistentVolumeClaim: claimName: task-pvc-volume 4 Copy to Clipboard Copied! Toggle word wrap Toggle overflow 1 pod 的名称。 2 pod 必须以特权运行,才能访问节点的存储。 3 在特权 pod 中挂载主机路径共享的路径。不要挂载到容器 root、/ 或主机和容器中相同的任何路径。如果容器有足够权限,可能会损坏您的主机系统(如主机的 /dev/pts 文件)。使用 /host 挂载主机是安全的。 4 之前创建的 PersistentVolumeClaim 对象的名称。 前一个下一个