Dynamic volume provisioning

Now that we've explored how to build from volumes, storage classes, persistent volumes, and persistent volume claims, let's take a look at how to make that all dynamic and take advantage of the built-in scaling of the cloud! Dynamic provisioning removes the need for pre-crafted storage; it relies on requests from application users instead. You use the StorageClass API object to create dynamic resources.

First, we can create a manifest that will define the type of storage class that we'll use for our dynamic storage. We'll use a vSphere example here to try out another storage class:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: durable-medium
provisioner: kubernetes.io/vsphere-volume
parameters:
type: thin

Once we have the manifest, we can use this storage by including it as a class in a new PersistentVolumeClaim. You may remember this as volume.beta.kubernetes.io/storage-class in earlier, pre-1.6 versions of Kubernetes, but now you can simply include this property in the PersistentVolumeClaim object. Keep in mind that the value of storageClassName must match the available, dynamic StorageClass that the cluster operators have provided. Here's an example of that:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: webtier-vclaim-01
spec:
accessModes:
- ReadWriteMany
storageClassName: durable-medium
resources:
requests:
storage: 20Gi

When this claim is removed, the storage is dynamically deleted. You can make this a cluster default by ensuring that the DefaultStorageClass admission controller is turned on, and after you ensure that one StorageClass object is set to default.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.37.190