The module lifecycle stage: Generally available version
The module has requirements for installation
The d8 utility is the recommended way to export and import volume data. Without -n, the commands below use the namespace of the current kubeconfig context, or default when the context sets none, as kubectl does; this works in d8 v0.34.8 and later, while before v0.34.8 d8 defaults to the d8-storage-volume-data-manager namespace, so with those versions pass -n with the namespace of the volume. The default TTL is 2m unless overridden.
For workflows without the d8 utility (YAML manifests, curl, raw HTTP API), see the FAQ.
Access permissions
The user needs permissions in the namespace of the DataExport or DataImport. With RBAC v1,
the standard Editor access level and higher provide object management and data transfer.
With RBAC v2, use manager or higher. The v1 User and v2 viewer/user levels can only
read transfer objects.
Creating a transfer object and transferring bytes are separate permissions. Download requests
require create on dataexports/download in the storage.deckhouse.io API group; upload requests,
including import completion, require create on dataimports/upload. For a custom role, grant
these permissions in addition to the required DataExport/DataImport object permissions.
Existing custom roles using dataimports/download must be updated to dataimports/upload.
Exporting data
Create a DataExport
d8 data export create [flags] <data_export_name> <volume_type>/<volume_name>Supported volume types:
| Short | Full name | Kubernetes kind |
|---|---|---|
pvc |
persistentvolumeclaim |
PersistentVolumeClaim |
vs |
volumesnapshot |
VolumeSnapshot |
vd |
virtualdisk |
VirtualDisk |
vds |
virtualdisksnapshot |
VirtualDiskSnapshot |
Flags:
-n, --namespace— target namespace (default: the namespace of the current kubeconfig context)--ttl— time to live after the last access (default:2m)--publish— expose the exporter outside the cluster (default:false)
Example: export a PVC named data in the project namespace:
d8 data export create -n project my-export pvc/data --ttl 5mExample: export a VolumeSnapshot:
d8 data export create -n project my-export vs/my-snapshot --ttl 10mPVC resources can only be exported when they are not currently mounted by any pods.
List exported content
d8 data export list [flags] <data_export_name> [/path/]Alias: ls.
For filesystem volumes, the directory path must end with /. For block volumes, omit the path.
Example:
d8 data export list -n project my-export /mydir/Flags: -n, --publish, --ttl (TTL for auto-created DataExport), --cleanup.
When the first argument is a volume reference (e.g. pvc/data) instead of an existing DataExport name, the command creates a temporary DataExport automatically.
Download data
d8 data export download [flags] [KIND/]<name> [path/file.ext] -o <output_file>The command can reference an existing DataExport by name or auto-create one by passing a volume reference (e.g. pvc/data, vs/my-snapshot).
- Filesystem mode: provide the file or directory path (e.g.
/mydir/file.txt). If-ois omitted, the output filename is derived from the source path. - Block mode: omit the path; the raw block device is downloaded. If
-ois omitted, the DataExport name is used as the output filename.
Example: download a file from an existing DataExport:
d8 data export download -n project my-export /test_file.txt -o test_file.txtExample: auto-create DataExport and download from a PVC:
d8 data export download -n project pvc/data /mydir/file.txt -o file.txt --ttl 5mExample: download a block volume from a VolumeSnapshot:
d8 data export download -n project vs/my-snapshot -o data.imgFlags: -n, -o, --publish, --ttl, --cleanup (delete auto-created DataExport without prompting when set to true).
Delete a DataExport
d8 data export delete [flags] <data_export_name>Example:
d8 data export delete -n project my-exportImporting data
Create a DataImport
d8 data import create [flags] <data_import_name> -f <pvc-template.yaml>The PVC template file describes the target volume. Example template (pvc-template.yaml):
metadata:
name: imported-data
namespace: project
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: local-path
volumeMode: FilesystemExample:
d8 data import create my-import \
-n project \
-f ./pvc-template.yaml \
--ttl 60m --publish --wffc falseFlags:
-n, --namespace— target namespace (default:metadata.namespaceof the template, then the namespace of the current kubeconfig context)-f, --file— path to the PVC template file (required)--ttl— time to live (default:2m)--publish— expose the importer outside the cluster (default:false)--wffc— wait for first consumer (default:false)
If the multitenancy-manager module is enabled and a ClusterResourceGrantPolicy limits the StorageClasses available to the project, the module checks spec.targetRef.pvcTemplate.spec.storageClassName of the DataImport. A DataImport that names a StorageClass not available to the project is rejected on creation with the message [multitenancy] DataImport "<NAME>" references "<CLASS>" which is not available to project "<PROJECT>"; the field is validated only and never replaced with the project default. Without a policy, every StorageClass is available. Requests from members of the system:masters group, from nodes, and from ServiceAccounts of the kube-system, d8-system, and d8-user-authz namespaces are not checked. The controllers of this module are not exempt: a PersistentVolumeClaim they create in a project namespace goes through the StorageClass check of PersistentVolumeClaims (the storageclasses-pvc reference), which replaces a class not available to the project with the default class of the project and rejects the claim if the project has no available default class.
Upload data
d8 data import upload [flags] <data_import_name>Upload a local file to the DataImport endpoint. The command auto-detects uid, gid, and permissions from the source file.
Example:
d8 data import upload my-import \
-n project \
-f ./test-file \
-d /myfile \
-PFlags:
-n, --namespace— target namespace-f, --file— local source file path (required)-d, --dstPath— destination path on the volume (required)-P, --publish— use the public URL of the DataImport-c, --chunks— split the upload into N chunks (default:10)--resume— resume an interrupted upload from the server-reported offset
Resume an interrupted upload:
d8 data import upload my-import -n project -f ./test-file -d /myfile -P --resumeUpload in chunks:
d8 data import upload my-import -n project -f ./test-file -d /myfile -P -c 4Delete a DataImport
d8 data import delete [flags] <data_import_name>Example:
d8 data import delete my-import -n projectGetting resource information
To inspect a created resource:
d8 k -n <namespace> get de <data_export_name>
d8 k -n <namespace> get di <data_import_name>The status section contains the access URL (url), CA certificate (ca), public URL (publicURL when --publish is enabled), and readiness conditions.