Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
© 2022 Yandex.Cloud LLC
Yandex Managed Service for Kubernetes
  • Comparison with other Yandex Cloud services
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Connecting to a node over SSH
    • Updating Kubernetes
    • Configuring autoscaling
    • Connecting to a cluster
      • Connection method overview
      • Configuring security groups
      • Creating a static configuration file
    • Installing applications
      • Basics of working with Cloud Marketplace
      • Installing Jaeger
      • Installing Metrics Provider
    • Network scenarios
      • Granting access to an app running in a Kubernetes cluster
      • Configuring the Calico network policy controller
      • Configuring the Cilium network policy controller
      • Configuring NodeLocal DNS for the Cilium network policy controller
    • Working with persistent volumes
      • Dynamic volume provisioning
      • Static volume provisioning
      • Managing storage classes
      • Expanding a pod volume
      • Expanding a StatefulSet controller volume
      • Mounting a volume in Block mode
      • Integration with Object Storage
    • Managing a Kubernetes cluster
      • Getting information about a Kubernetes cluster
      • Creating a Kubernetes cluster
      • Editing a Kubernetes cluster
      • Creating a namespace in a Kubernetes cluster
      • Deleting a Kubernetes cluster
    • Managing a node group
      • Information about existing node groups
      • Creating a node group
      • Connecting to a node over SSH
      • Configuring autoscaling
      • Changing a node group
      • Managing Kubernetes cluster node labels
      • Deleting a node group
    • Connecting external nodes to the cluster
  • Practical guidelines
    • All tutorials
    • Integration with Container Registry
    • Running workloads with GPUs
    • Installing the NGINX Ingress controller with Let's Encrypt®
    • Configuring the Application Load Balancer Ingress controller
    • Backups to Object Storage
    • Horizontal application scaling in a cluster
    • Vertical application scaling in a cluster
    • Working with snapshots
    • Integrating into a corporate DNS zone
    • Automatic DNS scaling by cluster size
    • Setting up local DNS caching
    • Configuring Fluent Bit for Cloud Logging
    • Syncing with Yandex Lockbox secrets
    • Using Cloud Marketplace products
      • Using Jaeger to trace requests in Managed Service for YDB
  • Concepts
    • Relationships between service resources
    • Release channels and updates
    • Encrypting secrets
    • Using Kubernetes API objects
      • Volumes
      • Service
    • Node groups
      • Cluster autoscaler
      • Evicting pods from nodes
      • Dynamic resource allocation for a node
      • Node groups with GPUs
    • Network in Managed Service for Kubernetes
    • External cluster nodes
    • Network settings and cluster policies
    • Automatic scaling
    • Quotas and limits
    • Recommendations for using Managed Service for Kubernetes
  • Access management
  • Pricing policy
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • ClusterService
      • NodeGroupService
      • VersionService
      • OperationService
    • REST
      • Overview
      • Cluster
        • Overview
        • create
        • delete
        • get
        • list
        • listNodeGroups
        • listNodes
        • listOperations
        • start
        • stop
        • update
      • NodeGroup
        • Overview
        • create
        • delete
        • get
        • list
        • listNodes
        • listOperations
        • update
      • Version
        • Overview
        • list
  • Questions and answers
    • General questions
    • Data storage
    • Configuring and updating
    • Automatic scaling
    • Resources
    • Logs
    • All questions on one page
  1. Step-by-step instructions
  2. Working with persistent volumes
  3. Managing storage classes

Managing storage classes

Written by
Yandex Cloud
  • Create a storage class
    • Specification format for creating a storage class
  • Change the default storage class

Storage class (StorageClass) allows administrators to divide the stores they provision into classes with defined parameters.

Managed Service for Kubernetes automatically provides two storage classes, yc-network-hdd and yc-network-ssd, with the following parameters:

  • Volume Binding Mode: WaitForFirstConsumer.
  • Reclaim Policy: Delete.
  • The default class is yc-network-hdd.

These classes only let you use PersistentVolumeClaims and PersistentVolumes in access mode ReadWriteOnce.

Classes differ based on the type of disk created:

  • yc-network-hdd uses a standard network drive (network-hdd).
  • yc-network-ssd uses a fast network drive (network-ssd).

You can create your own storage class as well as change the default storage class.

Note

yc-network-nvme is deprecated. Use yc-network-ssd instead.

Create a storage class

  1. Save the storage class creation specification in the my-sc-hdd.yaml YAML file:

    Learn more about the storage class creation specification format.

    kind: StorageClass
    apiVersion: storage.k8s.io/v1
    metadata:
      name: my-sc-hdd
    provisioner: disk-csi-driver.mks.ycloud.io
    volumeBindingMode: WaitForFirstConsumer
    parameters:
      type: network-hdd
      csi.storage.k8s.io/fstype: ext4
    allowVolumeExpansion: false
    reclaimPolicy: Retain
    
  2. Run the command:

    kubectl create -f my-sc-hdd.yaml
    

    Result:

    storageclass.storage.k8s.io/my-sc-hdd created
    
  3. Check that the storage class was created:

    kubectl get storageclass
    

    Result:

    NAME                      PROVISIONER                    AGE
    my-sc-hdd                 disk-csi-driver.mks.ycloud.io  76s
    yc-network-hdd (default)  disk-csi-driver.mks.ycloud.io  16m
    yc-network-ssd            disk-csi-driver.mks.ycloud.io  16m
    

Specification format for creating a storage class

Each StorageClass object contains the provisioner, parameters, and reclaimPolicy parameters that are used for the dynamic provisioning of PersistentVolumes.

Acceptable parameter values:

  • provisioner: disk-csi-driver.mks.ycloud.io.
  • parameters
    • type: network-hdd or network-ssd.
    • csi.storage.k8s.io/fstype: ext2, ext3, or ext4.
  • reclaimPolicy: Retain or Delete.

YAML file structure:

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: <storage class name> # Used for accessing the storage class.
provisioner: <provisioner name>
volumeBindingMode: WaitForFirstConsumer
parameters: # Storage class parameters.
  type: <disk type>
  csi.storage.k8s.io/fstype: <file system type>
allowVolumeExpansion: false
reclaimPolicy: <reclaim policy>

Change the default storage class

  1. Look up which storage class is assigned by default. default is shown next to its name in parentheses.

    kubectl get storageclass
    NAME                       PROVISIONER                     AGE
    my-sc-hdd                  disk-csi-driver.mks.ycloud.io   76s
    yc-network-hdd (default)   disk-csi-driver.mks.ycloud.io   16m
    yc-network-ssd             disk-csi-driver.mks.ycloud.io   16m
    
  2. Change the storageclass.kubernetes.io/is-default-class parameter of the default storage class to false, to remove its status as the default class:

    kubectl patch storageclass yc-network-hdd \
              -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'
    
  3. Check that yc-network-hdd is no longer the default storage class:

    kubectl get storageclass
    NAME              PROVISIONER                     AGE
    my-sc-hdd         disk-csi-driver.mks.ycloud.io   2m36s
    yc-network-hdd    disk-csi-driver.mks.ycloud.io   17m
    yc-network-ssd    disk-csi-driver.mks.ycloud.io   17m
    
  4. Specify a new default storage class, such as my-sc-hdd:

    kubectl patch storageclass my-sc-hdd \
              -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
    
  5. Check that my-sc-hdd is the default storage class:

    kubectl get storageclass
    NAME                  PROVISIONER                     AGE
    my-sc-hdd (default)   disk-csi-driver.mks.ycloud.io   4m21s
    yc-network-hdd        disk-csi-driver.mks.ycloud.io   19m
    yc-network-ssd        disk-csi-driver.mks.ycloud.io   19m
    

Was the article helpful?

Language / Region
© 2022 Yandex.Cloud LLC
In this article:
  • Create a storage class
  • Specification format for creating a storage class
  • Change the default storage class