Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Managed Service for Kubernetes
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Connecting to a node over SSH
    • Creating a configuration file
    • Configuring a Kubernetes cluster network
      • Granting access to an app running in a Kubernetes cluster
      • Using Kubernetes cluster network policies
    • Encrypting secrets
    • Using persistent volumes
      • Dynamically preparing volumes
      • Statically preparing volumes
      • Managing storage classes
      • Expanding a volume
      • Mounting a volume in Block mode
    • Managing a Kubernetes cluster
      • Adding Kubernetes cluster credentials to the kubectl configuration file
      • Getting information about a Kubernetes cluster
      • Creating a Kubernetes cluster
      • Editing a Kubernetes cluster
      • Deleting a Kubernetes cluster
    • Managing a node group
      • Getting information about a node group
      • Creating a node group
      • Editing a node group
      • Deleting a node group
  • Solutions
    • Integration with Container Registry
    • Running workloads with GPUs
    • Making backups to Object Storage
  • Concepts
    • Relationship between service resources
    • Release channels and updates
    • Using Kubernetes API objects
      • Volume
      • Service
    • Node group
      • Autoscaling node groups
      • Evicting pods from a node
      • Dynamic resource allocation for a node
      • Node groups with GPUs
    • Kubernetes cluster network policies
    • Quotas and limits
  • 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
  1. Step-by-step instructions
  2. Using persistent volumes
  3. Managing storage classes

Managing storage classes

  • 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
    storageclass.storage.k8s.io/my-sc-hdd created
    
  3. Check that the storage class was created:

    $ 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
    

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
    
In this article:
  • Create a storage class
  • Specification format for creating a storage class
  • Change the default storage class
Language
Careers
Privacy policy
Terms of use
© 2021 Yandex.Cloud LLC