静态PV HBlock CSI安装时绑定的命名空间 spec: containers: name: myfrontend 容器名称 image: busybox 请替换为容器使用的镜像 imagePullPolicy: "IfNotPresent" 容器镜像的拉取策略 volumeMounts: mountPath: "/test6a" 卷挂载到容器的目标路径 name: lun06a 对应volumes标签下的资源名 command: [ "sleep", "1000000" ] volumes: name: lun06a volumes资源名,可以在volumeMounts下挂载 persistentVolumeClaim: claimName: csipvclocalnocreatestor1lun06a Pod指定使用的PVC名称 卷模式为Block,创建Pod csiapplocalpvblockstor2lunb1的配置文件csiapplocalpvstor1lun06a.yaml,参考examplesblockvolumesstaticpvcsiapplocalpvblock.yaml中的示例。 plaintext kind: Pod apiVersion: v1 metadata: name: csiapplocalpvblockstor2lunb1 Set to the actual namespace namespace: default spec: containers: name: lunb1 image: busybox imagePullPolicy: "IfNotPresent" volumeDevices: devicePath: "/dev/testb1" name: lunb1 command: [ "sleep", "1000000" ] volumes: name: lunb1 persistentVolumeClaim: claimName: csipvclocalnocreateblockstor2lunb1 应用配置文件 以csiapplocalpvstor1lun06a.yaml 为例。 plaintext [root@server test] kubectl apply f csiapplocalpvstor1lun06a.yaml pod/mycsiapplocalpvstor1lun06a created 验证Pod中挂载的卷 说明 如果命名空间非default,需要使用命令kubectl get pod n namespace grep Podname查询。 plaintext [root@server test] kubectl get podgrep mycsiapplocalpvstor1lun06a mycsiapplocalpvstor1lun06a 1/1 Running 0 92s 可以看到容器中已经挂载了路径/test6a,此路径对应HBlock中的卷lun06a。 plaintext [root@server ~] kubectl exec it mycsiapplocalpvstor1lun06a /bin/sh / ls bin dev etc home lib lib64 proc root sys test6a tmp usr var