Warning
This page was translated from the original Japanese version by PLaMo Translate. The Japanese version is authoritative; the English translation may contain inaccuracies.
Using Block Storage
PFCP supports block storage as PersistentVolume resources with either ReadWriteOnce or ReadWriteOncePod access modes. For ReadWriteOncePod volumes, access is restricted to a single pod only.
Creating and Mounting a Filesystem from PersistentVolumeClaim to a Pod
To utilize block storage by creating a filesystem on it, you should first create a PersistentVolumeClaim resource to request the necessary storage capacity, then mount the dynamically provisioned PersistentVolume from within your pod. Below is an example demonstrating this process.
-
Create a PersistentVolumeClaim by specifying the organization-specific StorageClass. The available StorageClass name is
standard-rwo-<organization-name>.apiVersion: v1 kind: PersistentVolumeClaim metadata: name: hello-sample-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi storageClassName: standard-rwo-<organization-name> volumeMode: FilesystemIn this example, we’re creating a PersistentVolumeClaim to request a filesystem on 10GiB of block storage. Since volumeMode defaults to Filesystem, this specification is technically optional—the resulting volume would be created identically without this explicit declaration. After applying this manifest to Kubernetes, the PersistentVolume will be created dynamically, and you can verify that the PersistentVolumeClaim status becomes
Boundas follows:$ kubectl -n org-<organization-name> get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE hello-sample-pvc Bound pvc-ac98a6ff-58cd-4bef-8057-4837949107d0 10Gi RWO standard-rwo-<organization-name> <unset> 7s -
By specifying this PersistentVolumeClaim in your pod configuration, you can mount it and use it as file storage.
apiVersion: v1 kind: Pod metadata: name: jupyter-notebook spec: containers: - name: jupyter-notebook image: quay.io/jupyter/scipy-notebook:2024-03-14 volumeMounts: - mountPath: "/hello-sample" name: hello-sample-pv volumes: - name: hello-sample-pv persistentVolumeClaim: claimName: hello-sample-pvc
Using Block Storage Directly from a Pod Without Creating a Filesystem
To use block storage directly as a raw block device, you should create a PersistentVolumeClaim to request the necessary storage capacity, then access the dynamically provisioned PersistentVolume through your pod via a device file. Below is an example demonstrating this approach.
-
Create a PersistentVolumeClaim by specifying the organization-specific StorageClass. The available StorageClass name is
standard-rwo-<organization-name>.apiVersion: v1 kind: PersistentVolumeClaim metadata: name: hello-sample-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi storageClassName: standard-rwo-<organization-name> volumeMode: BlockIn this example, we’re creating a PersistentVolumeClaim to use 10GiB of block storage as a raw block device. By specifying Block as the volumeMode, we prevent any filesystem creation operations on the block storage. After applying this manifest to Kubernetes, the PersistentVolume will be created dynamically, and you can verify that the PersistentVolumeClaim status becomes
Boundas follows:$ kubectl -n org-<organization-name> get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE hello-sample-pvc Bound pvc-fb34c017-ce51-488c-a445-65981b031e0b 10Gi RWO standard-rwo-<organization-name> <unset> 119s -
By specifying this PersistentVolumeClaim in your pod configuration as a device file, you can access it directly as a block device from within your pod.
apiVersion: v1 kind: Pod metadata: name: block-demo spec: containers: - name: block-demo image: ubuntu command: - sleep - "3600" volumeDevices: - name: hello-sample-pv devicePath: /dev/block volumes: - name: hello-sample-pv persistentVolumeClaim: claimName: hello-sample-pvcThis example demonstrates how to operate the block device from within the pod. Here, the device file is mapped to nvme2n1, and you can confirm it is recognized as a block device with the specified 10GiB capacity from the PersistentVolumeClaim.
$ kubectl -n org-<organization-name> exec -it block-demo -- bash root@block-demo:/# ls -lF /dev/block brw-rw---- 1 root disk 259, 20 Aug 9 03:49 /dev/block root@block-demo:/# lsblk /dev/block NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS nvme2n1 259:20 0 10G 0 disk root@block-demo:/#