vSphere Container Storage Plug-in supports block based volumes, also called raw block volumes. You can use this functionality to expose a persistent volume inside a container as a block device rather than a mounted file system.

For information about raw block volume support in Kubernetes, see Raw Block Volume Support.

Certain applications require a direct access to a block device. When using a raw block device without a file system, Kubernetes can provide a better support to high-performance applications that are capable of consuming and manipulating block storage for their needs. Such applications as MongoDB and Cassandra that require consistent I/O performance and low latency can benefit from the raw block volumes technology and organize their data directly on the underlying storage.

Requirements

When you use raw block volumes with vSphere Container Storage Plug-in, follow these guidelines and requirements.
  • Use vSphere Container Storage Plug-in version 3 or later.
  • Use only single-access ReadWriteOnce raw block volumes. vSphere Container Storage Plug-in does not support raw block volume that use the ReadWriteMany access mode.

Create a Raw Block PVC

Follow this procedure to create a new raw block PVC.

Procedure

  1. Create a storage class.
    kind: StorageClass
    apiVersion: storage.k8s.io/v1
    metadata:
      name: example-raw-block-sc
    provisioner: csi.vsphere.vmware.com
  2. Create a raw block PersistentVolumeClaim.
    You must specify volumeMode as Block and accessModes as ReadWriteOnce.
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: example-raw-block-pvc
    spec:
      volumeMode: Block
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 5Gi
      storageClassName: example-raw-block-sc

Use a Raw Block PVC

When you use the PVC in a pod definition, you must specify the device path for the block device rather than the mount path for the file system.

Procedure

  • Use the following example.
    apiVersion: v1
    kind: Pod
    metadata:
      name: example-raw-block-pod
    spec:
      containers:
        - name: test-container
          image: gcr.io/google_containers/busybox:1.24
          command: ["/bin/sh", "-c", "while true ; do sleep 2 ; done"]
          volumeDevices:
            - devicePath: /dev/xvda
              name: data
      restartPolicy: Never
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: example-raw-block-pvc