Configuring storage classes, PVCs and pods
As the only storage class created during installation is used for the database, you might need additional storage classes for volume provisioning on IBM Spectrum Scale.
A separate storage class must be created for each IBM Spectrum Scale file system to be used for creating persistent volumes. This section details how to configure Kubernetes storage classes, persistent volume claims, and pods. Follow these steps to configure the storage classes, PVCs and pods:
- Define additional Kubernetes storage classes, if needed. Use the following template for creating additional storage classes for IBM Spectrum Scale filesystem:
# cat storage-class-spectrumscale-template.yml # This is an IBM Storage Enabler for Containers Storage Class template. kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: "<NAME>" labels: product: ibm-storage-enabler-for-containers # annotations: # storageclass.beta.kubernetes.io/is-default-class: "true" #reclaimPolicy: "Retain" # Optional, Values: Delete[default] or Retain provisioner: "ubiquity/flex" parameters: backend: "spectrum-scale" filesystem: "<filesystem name>" type: "fileset" # fileset-type: "<fileset type>" # Optional, Values: Independent[default] or dependent # uid: "<uid number>" # Optional # gid: "<gid number>" # Optional # inode-limit: "<no of inodes to be preallocated>" # Optional # isPreexisting: "<false|true>" # Optional, Values: false[default] or true
You can set the following configuration parameters in the file:Table 1. Configuration parameters in storage-class-template.yml for IBM Spectrum Scale Parameter Description name Storage class name. filesystem IBM Spectrum Scale file system name for creating new volumes. fileset-type Optional parameter.
Type of fileset to be created for volume.
Permitted values: independent[default], dependent.
uid Optional parameter.
Owner to be set on the fileset for newly created volume. User with specified uid/name must exist on IBM Spectrum Scale.
gid Optional parameter.
Group owner to be set on the fileset for newly created volume. Must be specified along with uid.
Group with specified gid/group must exist on Spectrum Scale.
inode-limit Optional parameter.
Number of inode to be pre-allocated for newly created fileset
isPreexisting Optional parameter.
Used to indicate whether to use existing fileset or create new fileset for volume
Permitted values: false[default], true.
If true is specified, user must set pv-name parameter while creating PVC.
type Permanently set to fileset. product Permanently set to ibm-storage-enabler-for-containers. provisioner Permanently set to ubiquity/flex. backend Permanently set to spectrum-scale. reclaimPolicy Optional parameter.
The reclaim policy tells the cluster what to do with the volume after it has been released of its claim.
Persistent Volume inherit the reclaim policy from Storage Class.
Permitted values :- Delete
- If PVC is deleted then the PVC, PV and fileset that were created by IBM Storage Enabler for Containers are deleted.
- Retain
- If a PVC is deleted, PV is not deleted and remains in
Released
state. The fileset is not deleted either. Deleting the PV which is inReleased
state does not delete the fileset associated with it. The user must manually delete the fileset from IBM Spectrum Scale.
Note: To use a PV within a non-root id container we can set the uid or gid fields in the storage class to the uid or gid which is used by the container process. This changes the ownership of the volume to the uid or gid specified in the storage class. By default, the owner of the volume is root. - Use the IBM Storage Enabler for Containers for creating persistent volume claims (PVCs) on IBM
Spectrum Scale.Use the following template for creating persistent volume claim. When a PVC is created, the IBM Storage Dynamic Provisioner generates a persistent volume (PV), according to the IBM Spectrum Scale configuration defined for the PVC storage class, and then binds the PV to the PVC. By default, the PV name is
PVC-ID
. The fileset name on the storage is[PVC-ID]
.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
You can set the following configuration parameters in the file:Table 2. Configuration parameters in pvc-template.yml for IBM Spectrum Scale 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.
Optional parameter.
This must be set for using existing fileset for creating persistent volumes along with the fileset parameter from storage-class.
Note:If a PVC with pv-name= xyz is created with reclaimPolicy= Retain, then another PVC cannot be created with same pv-name, that is with pv-name= xyz, even if the previous PVC with pv-name= xyz is deleted along with the PV.
accessModes Permitted values : ReadWriteOnce and ReadWriteMany. Other access modes are not supported.
storage Volume size in Gb. Other volume size units are not supported. - Create a pod to use the Kubernetes for storage.The PVCs can be used by Kubernetes pods for running stateful applications. The following example displays the template for using PVC in the pod yml file. When a pod is created, The IBM Storage FlexVolume performs the following actions:
-
Creates a link from /var/lib/kubelet/pods/[pod ID]/volumes/ibm~ubiquity-k8s-flex/[PVCID] to the fileset link path automatically. 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>
You can set the following configuration parameters in the file:Table 3. Configuration parameters in pod-template.yml for IBM Spectrum Scale 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 link is removed from /var/lib/kubelet/pods/[pod ID]/volumes/ibm~ubiquity-k8s-flex/[PVCID] to the fileset link path automatically.
-