Skip to content

    Kubernetes Volume Storage

    This page describes the configuration options for the Volume Storage resource. The Volume Storage resource is used to configure a Kubernetes Volume as a storage backend.

    Currently, it supports PersistentVolumeClaim for automatically provisioning PersistentVolumes.

    Defining a Volume Storage

    A Volume Storage can be defined by setting the .spec.volume object on the Storage resource.

    apiVersion: kannika.io/v1alpha
    kind: Storage
    metadata:
    name: my-storage
    spec:
    volume:
    capacity: 10Gi

    Configuring the storage class

    To configure the storage class of the volume, set the name of the StorageClass in the .spec.volume.storageClass field.

    When the storage class is not specified, the storage class configured in the operator is used. If the operator has not been configured with a storage class, no storage class is used for the PersistentVolumeClaim and the default storage class of the cluster . is used.

    Once set, the .spec.volume.storageClass becomes immutable and cannot be changed. This is because the storage class is used to provision the PersistentVolumeClaim and changing it would require deleting and recreating the PersistentVolumeClaim. If the operator has been configured with a storage class, it will update the .spec.volume.storageClass field on the Storage, making it immutable.

    apiVersion: kannika.io/v1alpha
    kind: Storage
    metadata:
    name: my-storage
    spec:
    volume:
    storageClass: my-storage-class
    capacity: 10Gi

    For more information on how to configure the storage class, see the Storage Class section.

    Configuring the capacity

    To configure the capacity of the volume, set the .spec.volume.capacity field to the desired capacity. The capacity is specified by a Kubernetes Quantity (e.g. 1Mi, 2.5Gi, etc).

    apiVersion: kannika.io/v1alpha
    kind: Storage
    metadata:
    name: my-storage
    spec:
    volume:
    capacity: 10Gi

    Configuring the access mode

    At the moment we do not support configuring the access mode of the volume. The access mode is set to ReadWriteOnce by default.

    What happens with the data when the volume is deleted?

    When the Storage resource is deleted, the PersistentVolumeClaim wil be deleted when it is not actively used by a Pod anymore. See the Storage Object in Use Protection section of the Kubernetes documentation for more information.

    Depending on the StorageClass, the PersistentVolume may be deleted or not. We recommend using a StorageClass with a Reclaim Policy set to Retain to ensure that the PersistentVolume is not deleted when the PersistentVolumeClaim is deleted. See the Storage Class section for more information on how to configure the StorageClass.