Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for Kubernetes
  • Comparing 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
    • Activating a Kubernetes Terraform provider
    • Installing applications from Yandex Cloud Marketplace using Terraform
      • Dynamic volume provisioning
      • Static volume provisioning
      • Managing storage classes
      • Encrypted disks for persistent volumes
      • Expanding a volume for pods
      • Mounting a volume in block mode
      • Integration with Object Storage
  • 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
  • Request volume expansion
  • Check the pod with the volume
  1. Step-by-step guides
  2. Working with persistent volumes
  3. Expanding a volume for pods

Expanding a pod volume

Written by
Yandex Cloud
Updated at September 26, 2025
  • Enable volume expansion
  • Create a PersistentVolumeClaim object
  • Create a pod with a dynamically provisioned volume
  • Request volume expansion
  • Check the pod with the volume

To expand a volume:

  1. Enable volume expansion.
  2. Create a PersistentVolumeClaim.
  3. Create a pod with a dynamically provisioned volume.
  4. Request volume expansion.
  5. Check 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
    

Request volume expansionRequest volume expansion

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

    kubectl patch pvc pvc-expansion -p '{"spec":{"resources":{"requests":{"storage":"2Gi"}}}}'
    
  2. Wait a few minutes for the volume to expand. Check the change results:

    kubectl get pvc pvc-expansion -o yaml
    

    The status.capacity.storage field shows the requested volume size:

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

Check the pod with the volumeCheck the pod with the volume

Check the pod status:

kubectl get pod pod -o yaml

The pod is running. The status section shows no container restarts.

Was the article helpful?

Previous
Encrypted disks for persistent volumes
Next
Mounting a volume in block mode
© 2025 Direct Cursus Technology L.L.C.