Home Explore Blog CI



kubernetes

4th chunk of `content/en/blog/_posts/2017-03-00-Dynamic-Provisioning-And-Storage-Classes-Kubernetes.md`
abbca4927f4ddf10412014bde5c1bd784a9ddf31c8c4e9a00000000100000d9d
  - ReadWriteOnce

  resources:

    requests:

      storage: 100Gi
  ```



**Can I add my own storage classes?**  
Yes. To add your own storage class, first determine which provisioners will work in your cluster. Then, create a StorageClass object with parameters customized to meet your needs (see user-guide for more detail). For many users, the easiest way to create the object is to write a yaml file and apply it with “kubectl create -f”. The following is an example of a StorageClass for Google Cloud Platform named “gold” that creates a “pd-ssd”. Since multiple classes can exist within a cluster, the administrator may leave the default enabled for most workloads (since it uses a “pd-standard”), with the “gold” class reserved for workloads that need extra performance.  


 ```
kind: StorageClass

apiVersion: storage.k8s.io/v1

metadata:

  name: gold

provisioner: kubernetes.io/gce-pd

parameters:

  type: pd-ssd
  ```



**How do I check if I have a default StorageClass Installed?**

You can use kubectl to check for StorageClass objects. In the example below there are two storage classes: “gold” and “standard”. The “gold” class is user-defined, and the “standard” class is installed by Kubernetes and is the default.



 ```
$ kubectl get sc

NAME                 TYPE

gold                 kubernetes.io/gce-pd   

standard (default)   kubernetes.io/gce-pd
  ```





 ```
$ kubectl describe storageclass standard

Name:     standard

IsDefaultClass: Yes

Annotations: storageclass.beta.kubernetes.io/is-default-class=true

Provisioner: kubernetes.io/gce-pd

Parameters: type=pd-standard

Events:         \<none\>
  ```



**Can I delete/turn off the default StorageClasses?**  
You cannot delete the default storage class objects provided. Since they are installed as cluster addons, they will be recreated if they are deleted.  

You can, however, disable the defaulting behavior by removing (or setting to false) the following annotation: storageclass.beta.kubernetes.io/is-default-class.  

If there are no StorageClass objects marked with the default annotation, then PersistentVolumeClaim objects (without a StorageClass specified) will not trigger dynamic provisioning. They will, instead, fall back to the legacy behavior of binding to an available PersistentVolume object.  

**Can I assign my existing PVs to a particular StorageClass?**  
Yes, you can assign a StorageClass to an existing PV by editing the appropriate PV object and adding (or setting) the desired storageClassName field to it.  

**What happens if I delete a PersistentVolumeClaim (PVC)?**  
If the volume was dynamically provisioned, then the default reclaim policy is set to “delete”. This means that, by default, when the PVC is deleted, the underlying PV and storage asset will also be deleted. If you want to retain the data stored on the volume, then you must change the reclaim policy from “delete” to “retain” after the PV is provisioned.  


- Post questions (or answer questions) on [Stack Overflow](http://stackoverflow.com/questions/tagged/kubernetes)
- Join the community portal for advocates on [K8sPort](http://k8sport.org/)
- Get involved with the Kubernetes project on [GitHub](https://github.com/kubernetes/kubernetes)
- Follow us on Twitter [@Kubernetesio](https://twitter.com/kubernetesio) for latest updates
- Connect with the community on [Slack](http://slack.k8s.io/)
- [Download](http://get.k8s.io/) Kubernetes

Title: FAQs: Checking for Default StorageClass, Disabling Defaulting, Assigning PVs, PVC Deletion and Community Resources
Summary
This passage provides answers to frequently asked questions about Kubernetes storage classes. It explains how to verify the presence of a default StorageClass using 'kubectl get sc' and 'kubectl describe storageclass'. It clarifies that default storage classes cannot be deleted but their defaulting behavior can be disabled by removing the 'storageclass.beta.kubernetes.io/is-default-class' annotation. The text explains how to assign existing PVs to a StorageClass by editing the PV object. It also details that deleting a PVC results in the deletion of the underlying PV and storage asset by default, unless the reclaim policy is changed to 'retain'. Finally, it provides links to various community resources for Kubernetes, including Stack Overflow, K8sPort, GitHub, Twitter, Slack, and the download page.