DataExport
Subcommand for the command line client for Deckhouse.
The export target is referenced by kind (targetRef.kind, the API group is
derived from it). Supported target kinds and their CLI aliases:
| Kind |
Aliases |
PersistentVolumeClaim |
pvc, persistentvolumeclaim |
VolumeSnapshot |
vs, volumesnapshot |
VirtualDisk |
vd, virtualdisk |
VirtualDiskSnapshot |
vds, virtualdisksnapshot |
Which module serves DataExport
Two Deckhouse modules serve the same CRD under different API groups:
| Module |
API group |
storage-foundation |
storage-foundation.deckhouse.io/v1alpha1 |
storage-volume-data-manager |
storage.deckhouse.io/v1alpha1 |
d8 data picks one per invocation instead of being built against a fixed group, because editions
differ in which module they ship: storage-foundation supersedes the other, but an edition without
it carries storage-volume-data-manager alone.
The choice is made from two questions the API server is asked before the command does any work:
which of the two groups it serves (discovery), and which of them the calling user may read in the
target namespace (SelfSubjectAccessReview). storage-foundation wins when both answers are yes
for it; otherwise the other module is used. Both questions are answerable by any authenticated
user, so this works for the ordinary users who run d8 data and not only for cluster admins.
The two answers are kept apart on purpose, so the error you get names the one thing that has to
change: a group that nothing serves means the module is not enabled, while a served group you are
not authorized for means an RBAC grant is missing. Check the latter with:
d8 k auth can-i get dataexports.storage-foundation.deckhouse.io -n NAMESPACE
d8 k auth can-i get dataexports.storage.deckhouse.io -n NAMESPACE
Available Commands:
- create - Create k8s DataExport object.
Examples
create
d8 data create export-name pvc/test-pvc-name
create from a snapshot
- Enable snapshot-controller module
kubectl apply -f -<<EOF
apiVersion: deckhouse.io/v1alpha1
kind: ModuleConfig
metadata:
name: snapshot-controller
spec:
enabled: true
version: 1
EOF
- Get a volume snapshot class name - this entity is created automatically for each type of CSI and is needed for creating a snapshot.
For example, "sds-local-volume-snapshot-class" as shown in the example below
kubectl get volumesnapshotclass
sds-local-volume-snapshot-class local.csi.storage.deckhouse.io Delete 22h
- Create a snapshot of a needed volume
kubectl apply -f -<<EOF
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: my-snapshot
namespace: <name of the namespace where the PVC is located>
spec:
volumeSnapshotClassName: <volume snapshot class name>
source:
persistentVolumeClaimName: <name of the PVC to snapshot>
EOF
- Check that snapshot is created normally and ready to use (usually takes a few minutes to be ready):
kubectl -n <name of the namespace> get volumesnapshot my-snapshot
NAMESPACE NAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT
<namespace> my-snapshot true test-pvc-for-snapshot 2Gi sds-local-volume-snapshot-class snapcontent-faf2ab1f-891d-4e5e-972c-334a490c99d8
- Create data export from that snapshot using d8 command as shown in the example below
d8 data create export-name vs/my-snapshot