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
    • Start testing with double trial credits
    • 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:

  • Getting started
  • Create a PersistentVolume object
  • Create a PersistentVolumeClaim object
  • Create a pod with a statically provisioned volume
  • How to delete a volume
  1. Step-by-step guides
  2. Working with persistent volumes
  3. Static volume provisioning

Static volume provisioning

Written by
Yandex Cloud
Updated at April 22, 2025
  • Getting started
  • Create a PersistentVolume object
  • Create a PersistentVolumeClaim object
  • Create a pod with a statically provisioned volume
  • How to delete a volume

Create a pod with a statically provisioned volume:

  1. Create a PersistentVolume.
  2. Create a PersistentVolumeClaim.
  3. Create a pod.

Tip

You can use a Yandex Object Storage bucket as storage for your pod. For more information, see Integration with Object Storage.

Getting started

  1. Install kubect and configure it to work with the new cluster.

  2. Find out the unique ID of the disk you are going to use to create a PersistentVolume:

    1. If you do not have a disk yet, create one.

      Warning

      Make sure the disk is located in the same availability zone as the nodes of the group that the pods will be running on.

    2. Get the disk ID (the ID column):

      yc compute disk list
      

      Result:

      +----------------------+------+------------+-------------------+--------+--------------+-------------+
      |          ID          | NAME |    SIZE    |       ZONE        | STATUS | INSTANCE IDS | DESCRIPTION |
      +----------------------+------+------------+-------------------+--------+--------------+-------------+
      | ef3ouo4sgl86******** | k8s  | 4294967296 | ru-central1-a     | READY  |              |             |
      +----------------------+------+------------+-------------------+--------+--------------+-------------+
      
  3. Check what storage classes are available and select the appropriate one:

    kubectl get storageclass
    

    Result:

    NAME                          PROVISIONER                    RECLAIMPOLICY  VOLUMEBINDINGMODE     ALLOWVOLUMEEXPANSION  AGE
    yc-network-hdd (default)      disk-csi-driver.mks.ycloud.io  Delete         WaitForFirstConsumer  true                  12d
    yc-network-nvme               disk-csi-driver.mks.ycloud.io  Delete         WaitForFirstConsumer  true                  12d
    yc-network-ssd                disk-csi-driver.mks.ycloud.io  Delete         WaitForFirstConsumer  true                  12d
    yc-network-ssd-nonreplicated  disk-csi-driver.mks.ycloud.io  Delete         WaitForFirstConsumer  true                  12d
    

    Note

    Please note that Kubernetes storage classes and Yandex Compute Cloud disk types are different concepts.

Create a PersistentVolume object

  1. Save the PersistentVolume creation specification to a YAML file named test-pv.yaml.

    For more information about the specification, see the Kubernetes documentation.

    When providing the spec.capacity.storage parameter, make sure the exact disk size is specified. Container Storage Interface does not verify disk size for statically provisioned volumes.

    To create a PersistentVolume from an existing cloud drive, enter its unique disk ID in the volumeHandle parameter.

    Note

    If the storageClassName parameter is not specified, the default storage class (yc-network-hdd) is used. To change the default class, see Change the default storage class.

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

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: <PersistentVolume_name>
    spec:
      capacity:
        storage: <PersistentVolume_size>
      accessModes:
        - ReadWriteOnce
      csi:
        driver: disk-csi-driver.mks.ycloud.io
        fsType: ext4
        volumeHandle: <disk_ID>
      storageClassName: <storage_class_name>
    
  2. Run this command:

    kubectl create -f test-pv.yaml
    

    Result:

    persistentvolume/<PersistentVolume_name> created
    
  3. View the information about the new PersistentVolume object:

    kubectl describe persistentvolume <PersistentVolume_name>
    

    Result:

    Name:            <PersistentVolume_name>
    Labels:          <none>
    Annotations:     <none>
    Finalizers:      [kubernetes.io/pv-protection]
    StorageClass:    <storage_class_name>
    Status:          Available
    ...
    

Create a PersistentVolumeClaim object

  1. Save the PersistentVolumeClaim creation specification to a YAML file named test-claim.yaml.

    For more information about the specification, see the Kubernetes documentation.

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: <PersistentVolumeClaim_name>
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: <PersistentVolumeClaim_size>
      storageClassName: <storage_class_name>
      volumeName: <PersistentVolume_name>
    

    Note

    The size of PersistentVolumeClaim must be less than or equal to that of PersistentVolume.

  2. Run this command:

    kubectl create -f test-claim.yaml
    

    Result:

    persistentvolumeclaim/<PersistentVolumeClaim_name> created
    
  3. View the information about the new PersistentVolumeClaim:

    kubectl describe persistentvolumeclaim <PersistentVolumeClaim_name>
    

    Result:

    Name:          <PersistentVolumeClaim_name>
    Namespace:     default
    StorageClass:  <storage_class_name>
    Status:        Bound
    Volume:        <PersistentVolume_name>
    ...
    

Create a pod with a statically provisioned volume

  1. Create a file named test-pod.yaml with a manifest for the pod using PersistentVolumeClaim:

    apiVersion: v1
    kind: Pod
    metadata:
      name: test-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: <PersistentVolumeClaim_name>
    

    For more information about the specification, see the Kubernetes documentation.

  2. Run this command:

    kubectl create -f test-pod.yaml
    

    Result:

    pod/test-pod created
    
  3. View the information about the new pod:

    kubectl describe pod test-pod
    

    Result:

    Name:       test-pod
    Namespace:  default
    Priority:   0
    ...
      ----    ------                  ----  ----                     -------
      Normal  Scheduled               20m   default-scheduler        Successfully assigned default/test-pod to cl1jtehftl7q********-icut
      Normal  SuccessfulAttachVolume  20m   attachdetach-controller  AttachVolume.Attach succeeded for volume "<PersistentVolume_name>"
    

In the Compute Cloud management console under Disks, the word Active will appear next to your disk.

How to delete a volume

Disks are not deleted automatically from Compute Cloud when you delete PersistentVolume. To delete the volume completely:

  1. Delete the PersistentVolumeClaim object.

    kubectl delete pvc <PersistentVolumeClaim_object_ID>
    
  2. Delete the PersistentVolume object.

    kubectl delete pv <PersistentVolume_object_ID>
    
  3. In Compute Cloud, delete the disk linked to the PersistentVolume object.

Was the article helpful?

Previous
Dynamic volume provisioning
Next
Managing storage classes
© 2025 Direct Cursus Technology L.L.C.