/ k8s-storage / devel / storage-classes/

Storage Classes

A StorageClass provides a way for administrators to describe the “classes” of storage they offer. Different classes might map to quality-of-service levels, or to backup policies, or to arbitrary policies determined by the cluster administrators. Kubernetes itself is unopinionated about what classes represent. This concept is sometimes called “profiles” in other storage systems.

Kadalu provides a few storage classes by default, but users are not limited to only these classes. This document helps to understand the default available storage classes and how to create new ones for your requirements.

kadalu

On using this Storage class, Kadalu can provision PVs from any of the available volumes without applying any filters.

Example PVC,

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pv1
spec:
  storageClassName: kadalu
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi

kadalu.storage-pool-name

Kadalu creates and deploys Storage Class when storage is created. The name of this Storage class is same as the Storage name. Kadalu wil provision PVs only from this Storage pool across the Cluster.

Example:

When a Storage is created with name "storage-pool-1", Kadalu deploys a Storage Class with name "kadalu.storage-pool-1". The parameter "storage_name" is set to "storage-pool-1" to filter storages to PVs only from this Storage.

Example: Create Storage "storage-pool-1",

$ kubectl kadalu storage-add storage-pool-1 \
    --path kube-nodename:/mnt/mount/export-path

Deployed Storage Class,

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: kadalu.storage-pool-1
provisioner: kadalu
parameters:
  storage_name: "storage-pool-1"

And the PVC,

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pv1
spec:
  storageClassName: kadalu.storage-pool-1
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi

How to Create a custom Storage Class?

The following filters are available. Use any of the filters to create a new Storage class.

storage_name

Specify the name of the Storage pool from which PVs need to provision.

Example Storage Class

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: kadalu.fast-storage
provisioner: kadalu
parameters:
  storage_name: "storage-pool-1"

And the PVC,

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pv5
spec:
  storageClassName: kadalu.fast-storage
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi

node_affinity

Use this option if a PV needs to provision from the locally available Storage, This Storage Class behaves the same as local Storage but with the support for dynamic provisioning.

Example Storage Class

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: kadalu.local-kube1
provisioner: kadalu
parameters:
  node_affinity: "kube1"  # Node name as shown in `kubectl get nodes`

And the PVC,

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pv6
spec:
  storageClassName: kadalu.local-kube1
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi

storage_type

Specify the name of the Storage pool type from which PVs need to provision. By default, Kadalu provides Storage Class for all supported Storage types.

Example Storage Class

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: kadalu.replica2
provisioner: kadalu
parameters:
  storage_type: "Replica2"

And the PVC,

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pv7
spec:
  storageClassName: kadalu.replica2
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi

pv_type

Use this option if the PV created using this Storage Class should be a Mounted Block Volume.

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: kadalu.db-storage
provisioner: kadalu
parameters:
  storage_name: "storage-pool-1"
  pv_type: Block

And the PVC,

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pv8
spec:
  storageClassName: kadalu.db-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

The number of customization a Storage Class can provide is impressive. The only limit is your imagination. Please open a new issue if your use case needs more filters than the ones listed above.

© 2021 Kadalu Software Private Limited. All Rights Reserved.