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
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
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:

  • Create a PersistentVolumeClaim object
  • Create a pod with the mounted volume
  1. Step-by-step guides
  2. Working with persistent volumes
  3. Mounting a volume in block mode

Mounting a volume in block mode

Written by
Yandex Cloud
Updated at February 6, 2025
  • Create a PersistentVolumeClaim object
  • Create a pod with the mounted volume

To mount a volume in volumeMode: Block mode:

  1. Create a PersistentVolumeClaim.
  2. Create a pod with the mounted volume.

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

Create a PersistentVolumeClaim objectCreate a PersistentVolumeClaim object

  1. To create a volume in block mode, set the spec.volumeMode field to Block.

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

    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: PersistentVolumeClaim
    metadata:
      name: pvc-block
    spec:
      accessModes:
        - ReadWriteOnce
      volumeMode: Block
      storageClassName: "yc-network-hdd"
      resources:
        requests:
          storage: 1Gi
    
  2. Create the PersistentVolumeClaim object:

    kubectl create -f pvc-block.yaml
    

    Result:

    persistentvolumeclaim/pvc-block created
    

Create a pod with the mounted volumeCreate a pod with the mounted volume

  1. When creating a volume pod in block mode, specify the spec.containers.volumeDevices field.

    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: ["-xc", "/bin/dd if=/dev/block of=/dev/null bs=1K count=10; /bin/sleep 3600"]
        volumeDevices:
        - devicePath: /dev/block
          name: persistent-storage
      volumes:
      - name: persistent-storage
        persistentVolumeClaim:
          claimName: pvc-block
    
  2. Run this command:

    kubectl create -f pod.yaml
    

    Result:

    pod/pod created
    

Was the article helpful?

Previous
Increasing volume size for the StatefulSet controller
Next
Integration with Object Storage
Yandex project
© 2025 Yandex.Cloud LLC