Home Explore Blog CI



kubernetes

2nd chunk of `content/en/blog/_posts/2016-10-00-Dynamic-Provisioning-And-Storage-In-Kubernetes.md`
fa2e51f20b7bd06331d1075ed535c887b122969cd258532a0000000100000a7a
Below is an example of how a cluster administrator would expose two tiers of storage, and how a user would select and use one. For more details, see the [reference](/docs/user-guide/persistent-volumes/#storageclasses) and [example](https://github.com/kubernetes/kubernetes/tree/release-1.4/examples/experimental/persistent-volume-provisioning) docs.  

**Admin Configuration**  

The cluster admin defines and deploys two StorageClass objects to the Kubernetes cluster:  

```
kind: StorageClass

apiVersion: storage.k8s.io/v1beta1

metadata:

  name: slow

provisioner: kubernetes.io/gce-pd

parameters:

  type: pd-standard
 ```


This creates a storage class called “slow” which will provision standard disk-like Persistent Disks.  

```
kind: StorageClass

apiVersion: storage.k8s.io/v1beta1

metadata:

  name: fast

provisioner: kubernetes.io/gce-pd

parameters:

  type: pd-ssd
 ```



This creates a storage class called “fast” which will provision SSD-like Persistent Disks.  



**User Request**



Users request dynamically provisioned storage by including a storage class in their PersistentVolumeClaim. For the beta version of this feature, this is done via the volume.beta.kubernetes.io/storage-class annotation. The value of this annotation must match the name of a StorageClass configured by the administrator.



To select the “fast” storage class, for example, a user would create the following PersistentVolumeClaim:



```
{

  "kind": "PersistentVolumeClaim",

  "apiVersion": "v1",

  "metadata": {

    "name": "claim1",

    "annotations": {

        "volume.beta.kubernetes.io/storage-class": "fast"

    }

  },

  "spec": {

    "accessModes": [

      "ReadWriteOnce"

    ],

    "resources": {

      "requests": {

        "storage": "30Gi"

      }

    }

  }

}
 ```




This claim will result in an SSD-like Persistent Disk being automatically provisioned. When the claim is deleted, the volume will be destroyed.




**Defaulting Behavior**



Dynamic Provisioning can be enabled for a cluster such that all claims are dynamically provisioned without a storage class annotation. This behavior is enabled by the cluster administrator by marking one StorageClass object as “default”. A StorageClass can be marked as default by adding the storageclass.beta.kubernetes.io/is-default-class annotation to it.



When a default StorageClass exists and a user creates a PersistentVolumeClaim without a storage-class annotation, the new [DefaultStorageClass](https://github.com/kubernetes/kubernetes/pull/30900) admission controller (also introduced in v1.4), automatically adds the class annotation pointing to the default storage class.

Title: Configuring and Using Storage Classes in Kubernetes
Summary
This section provides examples of how a cluster administrator can define and deploy StorageClass objects to expose different tiers of storage (e.g., "slow" and "fast") and how users can request dynamically provisioned storage by including a storage class annotation in their PersistentVolumeClaim. It also explains how to configure a default StorageClass, so that PersistentVolumeClaims without a storage-class annotation will be automatically provisioned using the default class.