Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for Kubernetes
  • Comparison with other Yandex Cloud services
  • Getting started
    • All guides
    • Connecting to a node over SSH
    • Connecting to a node via OS Login
    • Updating Kubernetes
    • Configuring autoscaling
      • Dynamic volume provisioning
      • Static volume provisioning
      • Managing storage classes
      • Expanding a pod volume
      • Increasing volume size for the StatefulSet controller
      • Mounting a volume in block mode
      • Integration with Object Storage
    • Connecting external nodes to the cluster
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Enable volume expansion
  • Create a PersistentVolumeClaim object
  • Create a pod with a dynamically provisioned volume
  • Delete the pod with the volume
  • Request volume expansion
  • Create a pod with a volume
  1. Step-by-step guides
  2. Working with persistent volumes
  3. Expanding a pod volume

Expanding a pod volume

Written by
Yandex Cloud
Updated at February 6, 2025
  • Enable volume expansion
  • Create a PersistentVolumeClaim object
  • Create a pod with a dynamically provisioned volume
  • Delete the pod with the volume
  • Request volume expansion
  • Create a pod with a volume

To expand a volume:

  1. Enable volume expansion.
  2. Create a PersistentVolumeClaim.
  3. Create a pod with a dynamically provisioned volume.
  4. Delete the pod with the volume.
  5. Request volume expansion.
  6. Delete the pod with the volume.

Before you start, install kubectl and configure it to work with the created Managed Service for Kubernetes cluster.

Enable volume expansionEnable volume expansion

To enable the volume expansion feature, make sure the storage class (StorageClass) description contains the allowVolumeExpansion: true parameter. In Managed Service for Kubernetes storage, this feature is enabled by default:

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: yc-network-hdd
provisioner: disk-csi-driver.mks.ycloud.io
volumeBindingMode: WaitForFirstConsumer
parameters:
  type: network-hdd
  csi.storage.k8s.io/fstype: ext4
allowVolumeExpansion: true
reclaimPolicy: Delete

Create a PersistentVolumeClaim objectCreate a PersistentVolumeClaim object

  1. Save the following PersistentVolumeClaim creation specification to a YAML file named pvc-expansion.yaml.

    To learn more about the PersistentVolumeClaim creation specification, see the Kubernetes documentation.

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: pvc-expansion
    spec:
      accessModes:
        - ReadWriteOnce
      storageClassName: yc-network-hdd
      resources:
        requests:
          storage: 1Gi
    
  2. Create the PersistentVolumeClaim object:

    kubectl create -f pvc-expansion.yaml
    

    Result:

    persistentvolumeclaim/pvc-expansion created
    

Create a pod with a dynamically provisioned volumeCreate a pod with a dynamically provisioned volume

  1. Save the following pod creation specification to a YAML file named pod.yaml.

    To learn more about the pod creation specification, see the Kubernetes documentation.

    apiVersion: v1
    kind: Pod
    metadata:
      name: pod
    spec:
      containers:
      - name: app
        image: ubuntu
        command: ["/bin/sh"]
        args: ["-c", "while true; do echo $(date -u) >> /data/out.txt; sleep 5; done"]
        volumeMounts:
        - name: persistent-storage
          mountPath: /data
      volumes:
      - name: persistent-storage
        persistentVolumeClaim:
          claimName: pvc-expansion
    
  2. Create a pod:

    kubectl create -f pod.yaml
    

    Result:

    pod/pod created
    

Delete the pod with the volumeDelete the pod with the volume

To request volume expansion, you need to delete the pod.

  1. Delete the pod:

    kubectl delete pod pod
    

    Result:

    pod "pod" deleted
    

Request volume expansionRequest volume expansion

Edit the spec.resources.requests.storage field of the PersistentVolumeClaim object.

  1. Open the YAML file named pvc-expansion.yaml:

    kubectl edit pvc pvc-expansion
    

    In the text editor, change the disk size value and save it:

    # Please edit the object below. Lines beginning with a '#' will be ignored,
    # and an empty file will abort the edit. If an error occurs while saving this file will be
    # reopened with the relevant failures.
    #
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
    ...
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
         storage: 1Gi # Change to 2Gi.
    ...
    status:
      accessModes:
      - ReadWriteOnce
      capacity:
        storage: 1Gi
    phase: Bound
    
  2. Wait for the volume to expand. Check the change results:

    kubectl get pvc pvc-expansion -o yaml
    

    The spec.resources.requests.storage field shows the requested volume size:

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
    ...
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 2Gi
    ...
    status:
      accessModes:
      - ReadWriteOnce
      capacity:
        storage: 1Gi
    ...
    

Create a pod with a volumeCreate a pod with a volume

  1. To resize the volume, create a pod:

    kubectl create -f pod.yaml
    

    Result:

    pod/pod created
    
  2. Check the change results:

    kubectl get pvc pvc-expansion -o yaml
    

    The volume size increased. The status.capacity.storage field now shows the expanded size:

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
    ...
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 2Gi
    ...
    status:
      accessModes:
      - ReadWriteOnce
      capacity:
        storage: 2Gi
    ...
    

Was the article helpful?

Previous
Managing storage classes
Next
Increasing volume size for the StatefulSet controller
© 2025 Direct Cursus Technology L.L.C.