Kubernetes storage classes

Volumes are added to pods and provide storage for containers in the pod. There are many different volume types in Kubernetes, providing both durable and non-durable storage.

Persistent Volumes (PVs) provide durable storage. For instance, the contents under /var/lib/cassandra are stored in a PV. Depending on the environment, a PV is either dynamically or statically provisioned. It has a lifecycle that is independent of the pod(s) which use it. That means that while a pod that uses a PV may be terminated, the PV remains intact.

Kubernetes (k8s) provides a storage mechanism that administrators use to dynamically provision Persistent Volumes (PVs) in a Kubernetes (k8s) cluster.

After one or more classes of storage are defined, pods can then dynamically request the specific type of storage that they require.

Storage class

Cloud vendors provide different types of storage with varying performance characteristics and varying costs. StorageClasses are the way to specify the type of PersistentVolume that is needed. The sample MissionControlCluster YAML file specifies premium-rwo. Check the documentation of your cloud provider for details on the StorageClasses that they provide.

In the MissionControlCluster YAML file, the storageClassName field must specify a storage class set up with volumeBindingMode: WaitForFirstConsumer.

If the StorageClass has reclaimPolicy: Delete then the PVs are deleted when the PVCs are deleted. When a cluster is deleted the associated PVCs are deleted as well. Without this parameter the deletion would cascade to the Persistent Volumes.

The following example uses the premium-rwo storage class and also retains PVs after the DSE cluster is deleted.

Example

  1. Copy premium-rwo to a file with this command:

    kubectl get storageclass premium-rwo -o yaml > storageclass.yaml
  2. Then modify the contents as follows:

    allowVolumeExpansion: true
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      annotations:
        components.gke.io/component-name: pdcsi
        components.gke.io/component-version: 0.11.8
        components.gke.io/layer: addon
      labels:
        addonmanager.kubernetes.io/mode: EnsureExists
        k8s-app: gcp-compute-persistent-disk-csi-driver
      name: premium-rwo-retain
    parameters:
      type: pd-ssd
    provisioner: pd.csi.storage.gke.io
    reclaimPolicy: Retain
    volumeBindingMode: WaitForFirstConsumer

    Mission Control requires a StorageClass setting of volumeBindingMode: WaitForFirstConsumer.

    Failure to set this may bind a volume on a node where the pod may not be scheduled, resulting in a deadlock or a stuck Pending pod status.

  3. With this file defined we can now submit it to the cluster with kubectl:

    kubectl apply -f storageclass.yaml
  4. When you create a MissionControlCluster object use the new storage class, premium-rwo-retain in the storageConfig section:

    storageConfig:
        cassandraDataVolumeClaimSpec:
          storageClassName: premium-rwo-retain
          accessModes:
            - ReadWriteOnce
          resources:
            requests:
              storage: 10Gi
  5. This specification indicates that when the MissionControlCluster is deleted, the PVs remain intact.

PersistentVolumeClaim (PVC)

A PVC is a request for storage. It specifies the minimal size criteria for the storage. In the following sample MissionControlCluster YAML file, the storage: request size is 10 gigabytes (10Gi):

  storageConfig:
    cassandraDataVolumeClaimSpec:
      storageClassName: premium-rwo
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 10Gi

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com