Skip to main content

Expand a Hetzner Cloud volume

Inspect 1.36

Grow a Hetzner Cloud volume by raising the storage request on its PersistentVolumeClaim (PVC), the object a pod uses to claim a disk. You edit one number, the driver enlarges the volume, and the filesystem grows to match. A volume only ever grows: a smaller number is rejected.

Confirm the class allows expansion #

Expansion works only when the StorageClass sets allowVolumeExpansion: true. The standard class already does:

		$ kubectl get storageclass standard
NAME                 PROVISIONER         RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
standard (default)   csi.hetzner.cloud   Retain          WaitForFirstConsumer   true                   10d
	

If a custom class shows false in the ALLOWVOLUMEEXPANSION column, a PVC on it cannot be resized. Move the data to a class that allows expansion instead. See .

Raise the storage request #

Edit spec.resources.requests.storage on the PVC to the new, larger size. One field changes:

pv-claim.yamlyaml
		spec:
  resources:
    requests:
      storage: 10Gi
      storage: 20Gi
	

A kubectl patch applies that same change in one line:

		$ kubectl patch pvc pv-claim -p '{"spec":{"resources":{"requests":{"storage":"20Gi"}}}}'
persistentvolumeclaim/pv-claim patched
	

kubectl edit pvc pv-claim opens the same field in an editor if you prefer to change it by hand.

Watch the capacity grow #

The CAPACITY column in kubectl get pvc reports the volume's real size, so watch it climb to the new value:

		$ kubectl get pvc pv-claim
NAME       STATUS   VOLUME        CAPACITY   ACCESS MODES   STORAGECLASS   VOLUMEATTRIBUTESCLASS   AGE
pv-claim   Bound    pvc-8f3c...   20Gi       RWO            standard       <unset>                 5m
	

The capacity updates once both steps finish: the driver enlarges the Hetzner volume, then the filesystem grows to fill it. You never run a resize command inside the pod; the driver handles that part too.

Note

On the standard class, expansion happens while the pod keeps running (an online resize). If a resize ever stalls with the volume still in use, kubectl describe pvc <name> shows a condition asking you to restart the pod so the change can finish offline.

Warning

Volumes grow, never shrink A volume cannot be made smaller. Request less than the capacity the volume already reports and the API rejects the change.

		$ kubectl patch pvc pv-claim -p '{"spec":{"resources":{"requests":{"storage":"5Gi"}}}}'
The PersistentVolumeClaim "pv-claim" is invalid: spec.resources.requests.storage: Forbidden: field can not be less than status.capacity
	

Plan sizes with this in mind. To end up on a smaller disk, create a new, smaller PVC and copy the data across, the same move covered in .

Next, keep an eye on how full your volumes get with .