Skip to main content

Block storage

This page is for a Project member who stores data on persistent volumes in Kube-DC. After you read it, you can choose a storage class, and create, clone, attach, and delete volumes in the console or with kubectl.

Kube-DC provides persistent block storage through Kubernetes PersistentVolumeClaims (PVCs). The Containerized Data Importer (CDI) adds DataVolumes, which create and populate PVCs from sources such as VM images. You manage both resource types in the console or with kubectl.

Volumes page​

To open the Volumes page, click Block Storage in the section rail. The page lists the PVCs of your Project. The section tree also links to Snapshots under Volumes and snapshots.

Volumes page with status and storage class filters, the Create PersistentVolumeClaim button, and a table of volumes

The table shows each volume's name, capacity, status, storage class, access modes, volume mode, and age. To narrow the list, use the All statuses and All storage classes filters, and the name filter. To open a volume's details panel, click its name.

The Actions menu of a volume offers these actions:

  • View YAML and Edit YAML: show or change the PVC manifest.
  • Expand volume: increases the requested capacity. A volume cannot shrink, and the storage class must support expansion.
  • VM attachment: attaches the volume to a stopped VM, or detaches a non-boot disk.
  • Clone volume: creates a separate copy of the volume.
  • Create snapshot: creates a VolumeSnapshot of the volume.
  • Delete: deletes the PVC.

The DataVolumes of your Project are on the DataVolumes page under Virtual machines > Storage. A DataVolume offers Clone volume. When your installation shows the Kubernetes resources section, a DataVolume also offers Manage underlying volume. A snapshot offers Restore to new volume on the Snapshots page.

Volume types​

DataVolumes (VM disk imports)​

A DataVolume is a KubeVirt resource provided by the Containerized Data Importer (CDI). It creates a PVC and fills it with data from a source, usually an OS image for a VM root disk.

When the Create virtual machine sheet imports an image, it creates a DataVolume for the root disk. For a Prepared snapshot image, it restores a PVC directly from a VolumeSnapshot instead. In both cases, the VM uses a PVC-backed disk.

DataVolumes can populate storage from these sources:

  • HTTP or HTTPS URL: download a cloud image, such as Debian or Ubuntu
  • Container registry: pull a disk image from a container registry
  • Blank: create an empty disk for additional storage

Example: VM root disk DataVolume

apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: debian-root
namespace: acme-production
spec:
source:
http:
url: https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
pvc:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20G
storageClassName: local-path

After the import completes (Phase: Succeeded), the DataVolume is ready and can be attached to a VM.

Example: Blank data disk

apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: data-disk
namespace: acme-production
spec:
source:
blank: {}
pvc:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50G
storageClassName: local-path

PersistentVolumeClaims (VMs and containers)​

A PVC is the standard Kubernetes resource for requesting persistent storage. VMs use PVC-backed disks, and containerized workloads such as Deployments, StatefulSets, and Pods mount PVCs when their data must persist across restarts.

Example: PVC for a database

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-data
namespace: acme-production
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: local-path

Mount it in a Pod:

apiVersion: v1
kind: Pod
metadata:
name: postgres
namespace: acme-production
spec:
containers:
- name: postgres
image: postgres:16
env:
- name: POSTGRES_PASSWORD
value: change-this-example-password
volumeMounts:
- name: data
mountPath: /var/lib/postgresql/data
volumes:
- name: data
persistentVolumeClaim:
claimName: postgres-data

When to use a DataVolume and when to use a PVC​

FeatureDataVolumePVC
Primary useCreate and populate VM disksBacking storage for VMs and containers
Data populationCDI source such as HTTP, registry, blank, or another volumeEmpty on creation, or clone/snapshot when the storage driver supports it
Created byVM provisioning or manuallyDirectly by user
Backed byCreates a PVC internallyDirectly binds to a PersistentVolume
Shown in the consoleVirtual machines > DataVolumesBlock Storage > Block Volumes

Storage classes​

A StorageClass defines what type of storage backs your volumes. The available storage classes depend on the infrastructure provider.

Node-local storage: local-path​

Your provider decides which class is the default. To list the classes and see the default, run:

kubectl get storageclass

On an installation that offers node-local storage, the output contains a line such as:

NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE
local-path (default) rancher.io/local-path Delete WaitForFirstConsumer

The local-path storage class provisions storage on the local disk of the node where the workload runs. It has these characteristics:

  • Fast: Direct local disk I/O, no network overhead
  • Node-bound: Data is stored on a specific node; the workload must run on the same node
  • Delete reclaim policy: When a PVC is deleted, the underlying data is removed

Which classes you are offered​

The available classes depend on the infrastructure. Typical ones are node-local storage (local-path), replicated network storage such as Ceph RBD, and an object-storage class for buckets. Each picker in the console offers only the classes that suit what you are creating, and labels each one with what it can do: Node-local, Snapshots, Live migration.

You are creatingClasses offered
VM boot disk or data diskBlock storage, node-local or replicated
Data disk of a live-migratable VMShared block storage that supports live migration (never node-local)
Volume (PersistentVolumeClaim)Block or file storage
Clone of a disk (CSI clone)Classes on the source disk's driver and storage pool; the source's own class is always offered
Volume restored from a snapshotClasses on the snapshot's driver and storage pool; the form starts on the source volume's class and modes
Managed cluster worker diskBlock storage for a persistent disk, or an ephemeral container disk with no storage class

Object-storage (bucket) classes, internal scratch classes and classes without dynamic provisioning are never offered for volumes. Older classes that remain only for existing volumes are not offered when you create a volume, but keep working for the volumes that use them.

What the platform refuses​

The same rules apply to the YAML editor and the API, not only to pickers. A create request is refused with a message that names the class and the reason when:

  • the class does not exist (400);
  • the class cannot hold that kind of volume, for example ceph-bucket for a volume or a VM disk (422);
  • a restore or CSI clone names a class on a different driver or storage pool than its source (422). The message names the source's class to use instead.

If the platform cannot read the storage classes (for example during an API server restart), it does not block the request; Kubernetes still validates the claim.

Pick the class explicitly

Leaving storageClassName empty uses the cluster's default class, which is often node-local. A volume restored from a snapshot or cloned from a disk must use a class on the source's driver, so name it explicitly when you write YAML yourself. Run kubectl get storageclass to see the classes on your installation.

Create a volume​

Use the console​

  1. In the section rail, click Block Storage.
  2. Click Create PersistentVolumeClaim. The Create PersistentVolumeClaim dialog opens.
  3. In Name, enter a name for the volume.
  4. In Capacity (GiB), enter the size.
  5. In Storage class, select a class. Each option shows what the class supports. Cluster default appears only when the default class suits a volume.
  6. In Access mode, select the access mode.
  7. In Volume mode, select Filesystem or Block.
  8. Optional: click Validate with Kubernetes to check the request without creating the volume.
  9. Click Create PersistentVolumeClaim. The volume appears on the Volumes page.

To write the manifest yourself, click Edit full YAML in the dialog. To create a DataVolume, click Create DataVolume on the DataVolumes page under Virtual machines > Storage.

Use kubectl​

Create a DataVolume (for VMs):

kubectl apply -f - <<EOF
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: my-data-disk
namespace: acme-production
spec:
source:
blank: {}
pvc:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 30G
storageClassName: local-path
EOF

Create a PVC (for containers):

kubectl apply -f - <<EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-pvc
namespace: acme-production
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: local-path
EOF

Manage volumes​

Check volume status​

# List all PVCs
kubectl get pvc -n acme-production

# List all DataVolumes
kubectl get datavolumes -n acme-production

# Get volume details
kubectl describe pvc debian-root -n acme-production

Clone a volume​

To request a separate copy of a volume, open its Actions menu and select Clone volume. In the Clone volume dialog, click Clone volume. PVC cloning requires CSI clone support from the selected StorageClass. DataVolume cloning can use CDI's copy strategy. For example, local-path does not provide CSI cloning, so a direct PVC clone can remain pending.

Check the cloned DataVolume or PVC status and events before attaching it. A clone is not a replacement for a tested backup or snapshot policy.

Detach a volume​

Detaching disconnects a volume from a VM without deleting the data. You can attach the volume again later. To detach a volume from a VM:

  1. Stop the VM, and wait for its guest to shut down.
  2. In the volume's Actions menu, select VM attachment.
  3. In Operation, select Detach from VM.
  4. In Virtual machine, select the VM.
  5. Click Detach volume.

A running VM can hot-plug disks from its Disks tab. To detach a PVC from a Pod, Deployment, or StatefulSet, update that workload's manifest or controller instead.

Delete a volume​

To delete a volume in the console, open its Actions menu and select Delete. To delete it with kubectl, run:

# Delete a DataVolume (also deletes the underlying PVC)
kubectl delete datavolume my-data-disk -n acme-production

# Delete a PVC directly
kubectl delete pvc my-pvc -n acme-production
warning

Deleting a claim removes the Kubernetes storage resource. What happens to the underlying data depends on the StorageClass reclaim policy. The hosted local-path class uses Delete, so deleting its PVC removes the backing data; do not rely on recovery after deletion.

Quick reference​

ActionCommand
List PVCskubectl get pvc -n acme-production
List DataVolumeskubectl get datavolumes -n acme-production
List StorageClasseskubectl get storageclass
Describe volumekubectl describe pvc <name> -n acme-production
Delete DataVolumekubectl delete datavolume <name> -n acme-production
Delete PVCkubectl delete pvc <name> -n acme-production

Next steps​