Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Cloud Desktop
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • Serverless Integrations
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Yandex Query
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • 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
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Tutorials
    • All tutorials
    • Setting up a Managed Service for PostgreSQL connection from a container in Serverless Containers
    • Creating a VM from a Container Optimized Image
    • Creating a VM from a Container Optimized Image with an additional volume for a Docker container
    • Creating an instance group from a Container Optimized Image with multiple Docker containers
    • Creating an instance group from a Container Optimized Image
    • Creating a VM from a Container Optimized Image with multiple Docker containers
    • Updating a Container Optimized Image VM
    • Configuring data output from a Docker container to a serial port
    • Running a Docker image on a VM using Cloud Registry
      • Creating a new Kubernetes project
      • Creating a Kubernetes cluster with no internet access
      • Creating a Kubernetes cluster using the Yandex Cloud provider for the Kubernetes Cluster API
      • Running workloads with GPUs
      • Using node groups with GPUs and no pre-installed drivers
      • Setting up time-slicing GPUs
      • Migrating resources to a different availability zone
      • Encrypting secrets
      • Connecting a BareMetal server as an external node to a Managed Service for Kubernetes cluster
        • Working with Compute Cloud snapshots

In this article:

  • Required paid resources
  • Getting started
  • Set up a test environment
  • Create a snapshot
  • Restore objects from the snapshot
  • Delete the resources you created
  1. Container infrastructure
  2. Managed Service for Kubernetes
  3. Backups
  4. Working with Compute Cloud snapshots

Managing Compute Cloud snapshots in Yandex Managed Service for Kubernetes

Written by
Yandex Cloud
Improved by
Sergei T.
Updated at July 17, 2026
View in Markdown
  • Required paid resources
  • Getting started
  • Set up a test environment
  • Create a snapshot
  • Restore objects from the snapshot
  • Delete the resources you created

Managed Service for Kubernetes supports snapshots, which are point-in-time PersistentVolume copies. For more on snapshots, see this Kubernetes guide.

To create a snapshot and then use it for restoring:

  1. Set up a test environment.
  2. Create a snapshot.
  3. Restore objects from the snapshot.

If you no longer need the resources you created, delete them.

Required paid resourcesRequired paid resources

The support cost for this solution includes:

  • Fee for a Managed Service for Kubernetes cluster: using the master and outbound traffic (see Managed Service for Kubernetes pricing).
  • Fee for cluster nodes (VMs): using computing resources, OS, and storage (see Compute Cloud pricing).
  • Fee for a public IP address if assigned to cluster nodes (see Virtual Private Cloud pricing).

Getting startedGetting started

  1. Create Kubernetes resources:

    Manually
    Terraform
    1. Create security groups for the Managed Service for Kubernetes cluster and its node groups.

      Warning

      The configuration of security groups determines performance and availability of the cluster and the services and applications running in it.

    2. Create a Managed Service for Kubernetes cluster and node group with any suitable configuration. When creating, specify the preconfigured security groups.

    1. If you do not have Terraform yet, install it.

    2. Get the authentication credentials. You can add them to environment variables or specify them later in the provider configuration file.

    3. Configure and initialize a provider. There is no need to create a provider configuration file manually, you can download it.

    4. Place the configuration file in a separate working directory and specify the parameter values. If you did not add the authentication credentials to environment variables, specify them in the configuration file.

    5. Download the k8s-cluster.tf cluster configuration file to the same working directory. This file describes:

      • Network.

      • Subnet.

      • Managed Service for Kubernetes cluster.

      • Service account required to create the Managed Service for Kubernetes cluster and node group.

      • Security groups which contain rules required for the Managed Service for Kubernetes cluster and its node groups.

        Warning

        The configuration of security groups determines performance and availability of the cluster and the services and applications running in it.

    6. Specify the folder ID in the configuration file:

    7. Validate your Terraform configuration files using this command:

      terraform validate
      

      Terraform will display any configuration errors detected in your files.

    8. Create the required infrastructure:

      1. Run this command to view the planned changes:

        terraform plan
        

        If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.

      2. If everything looks correct, apply the changes:

        1. Run this command:

          terraform apply
          
        2. Confirm updating the resources.

        3. Wait for the operation to complete.

      All the required resources will be created in the specified folder. You can check resource availability and their settings in the management console.

  2. Install kubectl and configure it to work with the new cluster.

Set up a test environmentSet up a test environment

To test snapshots, you will create a PersistentVolumeClaim and a pod to simulate the workload.

  1. Create the 01-pvc.yaml file with the PersistentVolumeClaim manifest:

    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: pvc-dynamic
    spec:
      accessModes:
        - ReadWriteOnce
      storageClassName: yc-network-hdd
      resources:
        requests:
          storage: 5Gi
    
  2. Create a PersistentVolumeClaim:

    kubectl apply -f 01-pvc.yaml
    
  3. Make sure the PersistentVolumeClaim was created and is Pending:

    kubectl get pvc pvc-dynamic
    
  4. Create the 02-pod.yaml file with the pod-source pod manifest:

    ---
    apiVersion: v1
    kind: Pod
    metadata:
      name: pod-source
    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-dynamic
    

    The pod container will write the current date and time to the /data/out.txt file.

  5. Create a pod named pod-source:

    kubectl apply -f 02-pod.yaml
    
  6. Make sure the pod has switched to Running:

    kubectl get pod pod-source
    
  7. Make sure that /data/out.txt collects date and time entries by running the following command on the pod:

    kubectl exec pod-source -- tail /data/out.txt
    

    Result:

    Thu Feb 3 04:55:21 UTC 2022
    Thu Feb 3 04:55:26 UTC 2022
    ...
    

Create a snapshotCreate a snapshot

  1. Create the 03-snapshot.yaml file with the snapshot manifest:

    ---
    apiVersion: snapshot.storage.k8s.io/v1
    kind: VolumeSnapshot
    metadata:
      name: new-snapshot-test
    spec:
      volumeSnapshotClassName: yc-csi-snapclass
      source:
        persistentVolumeClaimName: pvc-dynamic
    
  2. Create a snapshot:

    kubectl apply -f 03-snapshot.yaml
    
  3. Make sure the snapshot was created:

    kubectl get volumesnapshots.snapshot.storage.k8s.io
    
  4. Make sure the VolumeSnapshotContent was created:

    kubectl get volumesnapshotcontents.snapshot.storage.k8s.io
    

Restore objects from the snapshotRestore objects from the snapshot

When restoring objects from the snapshot, the cluster will create:

  • PersistentVolumeClaim object named pvc-restore.
  • Pod named pod-restore with entries in /data/out.txt.

To restore from the snapshot:

  1. Create the 04-restore-snapshot.yaml file with the new PersistentVolumeClaim manifest:

    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: pvc-restore
    spec:
      storageClassName: yc-network-hdd
      dataSource:
        name: new-snapshot-test
        kind: VolumeSnapshot
        apiGroup: snapshot.storage.k8s.io
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 10Gi
    

    Tip

    You can resize the PersistentVolumeClaim being created. To do this, specify its new size in the spec.resources.requests.storage setting.

  2. Create the new PersistentVolumeClaim:

    kubectl apply -f 04-restore-snapshot.yaml
    
  3. Make sure the PersistentVolumeClaim was created and is Pending:

    kubectl get pvc pvc-restore
    
  4. Create the 05-pod-restore.yaml file with the new pod-restore pod manifest:

    ---
    apiVersion: v1
    kind: Pod
    metadata:
      name: pod-restore
    spec:
      containers:
        - name: app-restore
          image: ubuntu
          command: ["/bin/sh"]
          args: ["-c", "while true; do sleep 5; done"]
          volumeMounts:
            - name: persistent-storage-r
              mountPath: /data
      volumes:
        - name: persistent-storage-r
          persistentVolumeClaim:
            claimName: pvc-restore
    

    The new pod container will not perform any actions with /data/out.txt.

  5. Create a pod named pod-restore:

    kubectl apply -f 05-pod-restore.yaml
    
  6. Make sure the pod has switched to Running:

    kubectl get pod pod-restore
    
  7. Make sure the new PersistentVolumeClaim status changed to Bound:

    kubectl get pvc pvc-restore
    
  8. Make sure /data/out.txt on the new pod contains all entries added by pod-source container before creating the snapshot:

    kubectl exec pod-restore -- tail /data/out.txt
    

    Result:

    Thu Feb 3 04:55:21 UTC 2022
    Thu Feb 3 04:55:26 UTC 2022
    ...
    

Delete the resources you createdDelete the resources you created

Delete the resources you no longer need to avoid paying for them:

  1. Delete the Managed Service for Kubernetes cluster:

    Manually
    Terraform

    Delete the Managed Service for Kubernetes cluster.

    1. In the terminal window, go to the directory containing the infrastructure plan.

      Warning

      Make sure the directory has no Terraform manifests with the resources you want to keep. Terraform deletes all resources that were created using the manifests in the current directory.

    2. Delete resources:

      1. Run this command:

        terraform destroy
        
      2. Confirm deleting the resources and wait for the operation to complete.

      All the resources described in the Terraform manifests will be deleted.

  2. Delete the cluster's public static IP address if you reserved one.

  3. Delete the disk snapshot.

Was the article helpful?

Previous
DNS challenge for Let's Encrypt® certificates
Next
Cluster monitoring with Prometheus and Grafana
© 2026 Direct Cursus Technology L.L.C.