Raw block devices in Rancher
The Portworx CSI Driver supports both File and Block volume types in Kubernetes PVCs. While file has more supported features, block support for ReadWriteOnly PVCs was added in Portworx Enterprise in version 2.8.0.
Use cases for Raw Block Devices
If your application has a requirement to consume a raw block device as opposed to a mounted filesystem, this is a perfect use case for Portworx CSI Raw Block devices.
Currently, only ReadWriteOnce PVCs can be created with the block volume mode.
Create and use raw block PVCs
In this example we are using the px-csi-db storage class out of the box. Please refer CSI Enabled Storage Classes for list of available CSI enabled storage classes offered by Portworx.
-
Create a PVC spec that references the portworx-csi-sc as seen below in a YAML file named
raw-block-pvc.yaml:kind: PersistentVolumeClaimapiVersion: v1metadata:name: px-csi-raw-block-pvcspec:volumeMode: BlockstorageClassName: px-csi-dbaccessModes:- ReadWriteOnceresources:requests:storage: 2Gi -
Apply the
raw-block-pvc.yamlspec to create the raw block PVC:kubectl apply -f raw-block-pvc.yaml -
Create a deployment SPEC that references the above raw block PVC in
raw-block-deployment.yaml:apiVersion: apps/v1kind: Deploymentmetadata:name: iopingspec:selector:matchLabels:app: iopingstrategy:rollingUpdate:maxSurge: 1maxUnavailable: 1type: RollingUpdatereplicas: 1template:metadata:labels:app: iopingversion: "1"spec:containers:- name: iopingimage: hpestorage/iopingcommand: [ "ioping" ]args: [ "/dev/xvda" ]volumeDevices:- name: raw-devicedevicePath: /dev/xvdavolumes:- name: raw-devicepersistentVolumeClaim:claimName: px-csi-raw-block-pvc -
Apply the
raw-block-deployment.yamlspec to create the deployment utilizing our raw block PVC:kubectl apply -f raw-block-deployment.yaml