Enable Disk Expansion

For storage methods such as RBD or CephFS, Kubernetes supports expanding storage in-use (allowVolumeExpansion feature). With the ExpandDisks feature, KubeVirt can make additional storage available for the virtual machines. This feature is currently disabled by default and requires enabling a feature gate. To enable it, add the ExpandDisks feature gate in the Kubevirt object by applying the following Helm override:

  1. Create an overrides file listing the desired feature gates.

    cat <<EOF > /home/sysadmin/kubevirt-overrides.yaml
    featureGates:
      - Snapshot
      - ExpandDisks
    EOF
    
  2. Apply the Helm override.

    ~(keystone_admin)]$ system helm-override-update kubevirt-app kubevirt-app kubevirt --values /home/sysadmin/kubevirt-overrides.yaml
    
  3. Apply the KubeVirt application.

    ~(keystone_admin)]$ system application-apply kubevirt-app
    
  4. Verify that the ExpandDisks feature gate is enabled in the KubeVirt CR.

    ~(keystone_admin)]$ kubectl get kubevirt kubevirt -n kubevirt -o jsonpath='{.spec.configuration.developerConfiguration.featureGates}'
    Expected: ["Snapshot","ExpandDisks"]
    

Expand a PVC Backed Disk from VM

Below is an example of how to expand a PVC backed disk from a VM:

  1. Identify the PVC to expand (under spec.template.spec.domain.devices.disks).

    kubectl get vm <vm name> -n <namespace> -o yaml
    
  2. Edit the PVC to expand its size using the kubectl edit pvc <pvc name> -n <namespace> command.

    spec:
      resources:
        requests:
          storage: 20Gi   # new desired size
    

    Confirm the change using the kubectl get pvc <pvc name> -n <namespace> command.

  3. Restart VM.

    virtctl stop  <vm name>
    virtctl start <vm name>
    
  4. Resize the filesystem of OS in use inside VM.