Configuring storage classes, PVCs and pods

This section details how to configure Kubernetes storage classes, persistent volume claims and pods.

Defining additional Kubernetes storage classes

Define additional Kubernetes storage classes, if needed. Template for setting storage classes is illustrated below. The template is provided as the ./yamls/templates/storage-class-template.yml file . As the only storage class, created during installation, is used for the database, you might need additional storage classes for volume provisioning on IBM storage. A separate storage class must be assigned for each storage service delegated to the IBM Storage Enabler for Containers interface in Spectrum Control Base.
kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
  name: "<Storage class name>"
  labels:
    product: ibm-storage-enabler-for-containers
#  annotations:
#   storageclass.beta.kubernetes.io/is-default-class: "boolean" 
provisioner: "ubiquity/flex"
parameters:
  profile: "<SCBE service name>"
  fstype: "<Filesystem type>"        
backend: "scbe"
Table 1. Configuration parameters in storage-class-template.yml
Parameter Description
name Storage class name. It is recommended to use the storage class profile value as the storage class name.
profile Spectrum Control Base storage service name
fstype File system type of a new volume

Allowed values: ext4 or xfs.

is-default-class Configures the storage class to be the default true or not false. By default, it is set to false.
product Permanently set to ibm-storage-enabler-for-containers
provisioner Permanently set to ubiquity/flex
backend Permanently set to scbe.

Creating persistent volume claims (PVCs)

Use the IBM Storage Enabler for Containers for creating persistent volume claims (PVCs) on IBM storage systems. Template for PVC configuration is illustrated below. The template is provided as the ./yamls/templates/pvc-template.yml file.

When a PVC is created, the IBM Storage Dynamic Provisioner generates a persistent volume (PV), according to Spectrum Control Base storage service, defined for the PVC storage class, then it binds the PV to the PVC. By default, the PV name will be PVC-ID. The volume name on the storage will be u_[ubiquity-instance]_[PVC-ID]. Keep in mind that the [ubiquity-instance] value is set in the IBM Storage Enabler for Containers configuration file.

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: "<PVC name>"
  labels:
     product: ibm-storage-enabler-for-containers
  #  pv-name: "<PV name>"   
spec:  
  storageClassName: <Storage Class Name>
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
storage: <Number>Gi
Table 2. Configuration parameters in pvc-template.yml
Parameter Description
name Persistent volume claim name
storageClassName Storage class name used for the PVC provisioning
pv-name

Persistent volume name. This name is used for creating a PV with a specific name, which is different from the default PV. The default PV name is its PVC ID. However, this dedicated PV name must be unique. No other PV with the same name is allowed within the Kubernetes cluster.

accessModes Permanently set to ReadWriteOnce. Other access modes, such as ReadWriteMany, are not supported.
storage Volume size in Gb. Other volume size units are not supported.

Creating a pod to use the PVC for storage

The PVCs can be used by Kubernetes pods for running stateful applications. Below is the example for of the template for using PVC in the pod yml file. When a pod is created, The IBM Storage FlexVolume performs the following actions automatically:
  • Volume attachment to the host, on which Kubernetes scheduled the pod to run.
  • Rescanning and discovering the multipath device of the new volume.
  • Creating an XFS or EXT4 filesystem on the device (if filesystem does not exist on the volume).
  • Mounting the new multipath device on /ubiquity/[WWN of the volume].
  • Creating a symbolic link from /var/lib/kubelet/pods/[pod ID]/volumes/ibm~ubiquity-k8s-flex/[PVC ID] to /ubiquity/[WWN of the volume].

    As a result, the pod goes up with the mounted PV on the container pod in the mountPath defined in the yml file.

kind: Pod
apiVersion: v1
metadata:
  name: <Pod name>          
spec:
  containers:
  - name: <Container name>  
    image: <Image name>
    volumeMounts:
      - name: <yaml volume name>
        mountPath: <Mount point>  
  volumes:
    - name: <yaml volume name>
      persistentVolumeClaim:
         claimName: <PVC name>
Table 3. Configuration parameters in sanity-pod.yml
Parameter Description
name Pod name
containers.name Container name
containers.image Container image
volumeMounts.name Internal volume name
volumeMounts.mountPath Mounting point for the PVC in the container
volumes.name Internal volume name
volumes.persistentVolumeClaim Name of the persistent volume claim
When a pod is deleted, the following actions are performed automatically:
  • Removing a symbolic link from /var/lib/kubelet/pods/[pod ID]/volumes/ibm~ubiquity-k8s-flex/[PVC ID] to /ubiquity/[WWN of the volume].
  • Unmounting the new multipath device on /ubiquity/[WWN of the volume].
  • Removing the multipath device of the volume.
  • Detaching (unmapping) the volume from the host.
  • Rescanning in the cleanup mode to remove the physical and multipath device files of the detached volume.