Raw Block Volume
Explore this Page
- Overview
- Provisioning a Raw Block Volume
- Creating a PersistentVolumeClaim (PVC)
- Deploying an Application with a Raw Block Volume
- Benefits of Raw Block Volume
Overview
Some enterprise workloads and performance-critical applications, such as databases and storage systems, require direct access to block devices. These applications often bypass traditional file system layers to avoid performance overhead and to retain full control over data layout and management. Examples include databases that manage their own storage structures and software-defined storage solutions that need direct block-level access.
With the increasing adoption of Kubernetes for running such workloads, it has become essential to support raw block volumes within Kubernetes environments. DataCore Puls8, leveraging its versatile and high-performance storage solutions - including Local PV LVM, Local PV ZFS, and Replicated PV Mayastor enables seamless provisioning and attachment of raw block volumes to containers, facilitating seamless integration with applications that demand direct device-level access.
Provisioning a Raw Block Volume
To create a raw block volume, define a StorageClass without a file system type (fstype
), as raw block volumes should not be formatted with a file system.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: lvmpv-block
allowVolumeExpansion: true
parameters:
volgroup: "lvmpv-vg"
provisioner: local.csi.openebs.io
Creating a PersistentVolumeClaim (PVC)
Once the StorageClass is configured, define a PVC that specifies volumeMode: Block
. This explicitly requests a raw block device instead of a mounted file system.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: block-claim
spec:
volumeMode: Block
storageClassName: lvmpv-block
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
Deploying an Application with a Raw Block Volume
After provisioning the PVC, you can deploy an application that consumes the raw block device. The device is made available inside the container at the specified path using the volumeDevices
configuration.
apiVersion: apps/v1
kind: Deployment
metadata:
name: fiob
spec:
replicas: 1
selector:
matchLabels:
name: fiob
template:
metadata:
labels:
name: fiob
spec:
containers:
- resources:
name: perfrunner
image: openebs/tests-fio
imagePullPolicy: IfNotPresent
command: ["/bin/bash"]
args: ["-c", "while true ;do sleep 50; done"]
volumeDevices:
- devicePath: /dev/xvda
name: storage
volumes:
- name: storage
persistentVolumeClaim:
claimName: block-claim
In the above deployment, the raw block volume is exposed inside the pod at /dev/xvda
, which the application can use directly.
Benefits of Raw Block Volume
- Enhanced Performance: Bypasses the file system layer to enable faster and more efficient I/O operations.
- Greater Control: Allows applications like databases to manage their own storage layout directly on the device.
- Reduced Latency: Provides direct access to block devices, minimizing delays in data processing.
Learn More