VMI PVC Fill

VMI PVC Fill creates a temporary file on a PVC attached to a KubeVirt VirtualMachineInstance and removes it after the configured hold duration. It supports filesystem PVCs resolved through the VMI’s launcher pod and block PVCs filled from inside the guest.

Choose a storage mode

  • Filesystem PVC: the PVC is mounted as a filesystem in a pod. Krkn resolves the PVC mount and fills it through the pod. Guest SSH settings and device_path are not needed.
  • Block PVC: the PVC is attached as a raw block device to the VMI. Krkn connects to the guest with virtctl ssh, formats the guest device only when requested, mounts it, fills it, and cleans up the temporary file.

Prerequisites for block PVCs

  • The VMI must be running and have the target PVC attached.
  • device_path must be the guest device path, such as /dev/vdb, not a path from the virt-launcher pod.
  • virtctl ssh must be able to connect to the guest using the configured username and private key. The matching public key must be authorized in the guest.
  • The guest user must be able to run the needed storage commands with passwordless sudo.
  • Set format_device: true only for a disposable data disk. Formatting erases existing data on the selected device. With formatting disabled, the device must already contain the configured filesystem.

Configuration

vmi_pvc_fill_scenario:
  vmi_name: my-vmi
  namespace: default
  pvc_name: my-vmi-data
  # Required for block PVCs; ignored for filesystem PVCs.
  device_path: /dev/vdb
  mount_path: /mnt/krkn-data
  filesystem: ext4
  fill_percentage: 50
  duration: 60
  format_device: false
  username: fedora
  # Path inside the krkn-hub container; mount the key there for block mode.
  identity_file: /home/krkn/.ssh/vmi-pvc-fill-key
  pod_name: ""

fill_percentage defaults to 50 when omitted or blank. It must be between 1 and 99 and above the filesystem’s current utilization. Quoted numeric values such as "50" are accepted.

Supported parameters

ParameterDescriptionDefault
vmi_nameTarget VMI. Required for block PVCs; may identify the launcher pod for filesystem PVCs.""
pvc_namePVC attached to the VMI or mounted by the target pod.""
pod_namePod mounting a filesystem PVC when not resolving via VMI or PVC name.""
namespaceNamespace containing the VMI, PVC, or pod.default
device_pathGuest block-device path, such as /dev/vdb.""
mount_pathGuest mount path for block mode./mnt/krkn-data
filesystemGuest filesystem type: ext4 or xfs.ext4
fill_percentageTarget filesystem usage, 1–99 and above current utilization.50
durationHold duration in seconds.60
format_deviceFormat the block device before filling; destroys its existing data.false
usernameGuest SSH username for block mode.root
identity_filePrivate key path inside the container for block mode.empty

Target selection

Set at least one of vmi_name, pvc_name, or pod_name. Block mode requires vmi_name and device_path; specify pvc_name when the VMI has multiple PVCs so the intended disk is selected. Filesystem mode can resolve the target using a VMI, PVC, or pod.

How to run

Configure the scenario in config.yaml and include the scenario file in chaos_scenarios:

kraken:
  chaos_scenarios:
    - vmi_pvc_fill_scenarios:
        - scenarios/kubevirt/vmi_pvc_fill.yaml

Set the parameters in scenarios/kubevirt/vmi_pvc_fill.yaml. For filesystem PVC mode, provide pvc_name or pod_name. For block PVC mode, provide vmi_name, device_path, and identity_file; make sure the guest trusts the matching public key.

The plugin is available in the Krkn repository under krkn/scenario_plugins/vmi_pvc_fill.

Choose the storage mode and pass its settings as environment variables. This example runs block mode; the private key is mounted inside the container, and IDENTITY_FILE points to that in-container path.

docker run --name=vmi-pvc-fill \
  --net=host --pull=always \
  -v <path-to-kube-config>:/home/krkn/.kube/config:Z \
  -v <path-to-guest-private-key>:/home/krkn/.ssh/vmi-pvc-fill-key:ro,Z \
  -e VMI_NAME=my-vmi \
  -e PVC_NAME=my-vmi-data \
  -e NAMESPACE=default \
  -e DEVICE_PATH=/dev/vdb \
  -e USERNAME=fedora \
  -e IDENTITY_FILE=/home/krkn/.ssh/vmi-pvc-fill-key \
  -e FILL_PERCENTAGE=50 \
  -e DURATION=60 \
  containers.krkn-chaos.dev/krkn-chaos/krkn-hub:vmi-pvc-fill

For filesystem PVC mode, omit the guest-only settings and provide PVC_NAME or POD_NAME to locate the mounted PVC. Set VMI_NAME when using the VMI to identify the target. See the parameter table below for the full list of environment variables.

Run the published scenario image with krknctl:

krknctl run vmi-pvc-fill [--<parameter> <value>]

For filesystem PVC mode, pass --pvc-name or --pod-name. For block PVC mode, also pass --vmi-name, --device-path, and --identity-file:

krknctl run vmi-pvc-fill \
  --vmi-name my-vmi \
  --pvc-name my-vmi-data \
  --device-path /dev/vdb \
  --username fedora \
  --identity-file /path/to/guest-private-key \
  --fill-percentage 50 \
  --duration 60

The matching public key must be authorized in the guest. --identity-file accepts a local file path, which krknctl mounts into the scenario container. See the parameter table below for all options. You can also set global variables listed here.