Deploying an Application on OCP with Lightbits

This is the procedure for connecting OpenShift to Lightbits software-defined storage via a CSI plugin and then deploying a workload that uses Lightbits as its persistent storage.

Prerequisites:

  • An OpenShift cluster with internet access
  • The Lightbits CSI driver
  • OC is installed on a workstation to configure the OpenShift cluster
  • console access to the OpenShift cluster

Instructions

We will be using a series of YAML files to create various components of our application, which is a simple message board. I will provide the YAML files here so they won’t have to be recreated from scratch.

1. Log in to the OCP web console.
OCP web console
2. Log in to your terminal on your OCP cluster.
image of a terminal on an OCP cluster

3. Make sure your nodes are ready.

image of OCP node readiness

image of Red Hat assisted installer warning
1. The first step we take is to install the Lightbits CSI driver. The Lightbits CSI driver is open-sourced. To install the driver on the OCP cluster, run the following from your OC workstation.
images of Lightbits CSI Driver installation code

The tar file creates the following directories: helm, k8s, examples
There is a file that needs to be adjusted to enable the CSI driver to use the RWX (ReadWriteMany) mode for the volume. It is located in the k8s directory and is named lb-csi-plugin-k8s-v1.30-dc.yaml. In this file, we need to create two extra entries to enable the RWX for the CSI driver. Please edit the file and add in the containers section the following two lines, (line number 313):

image of Lightbits YAML file
2. The service account lb-csi-node-sa section looks like this:

image of service account lb-csi-node-sa section

3. This also needs to be added to the section serviceAccount: lb-csi-ctrl-sa (line number 448) and looks like the following:

image of lb-csi-ctrl-sa code

4. The next thing is to run the yaml with the kubectl command:

image of yaml with the kubectl command

The output will be like the following:
image of yaml with the kubectl command output
5. To verify that the Lightbits pods are running:

image that Lightbits pods are running in OCP

The output will be similar to the following:
image showing the Lightbits pods are running in OCP

The CSI driver is now configured to work with RWX. This is also visible in the GUI:
image of Lightbits GUI Photon with OCP pods running

Next, we want to configure a secret for the Lightbits cluster, define the default storage class as Lightbits, and create a project for this workload to run under.

1. Create the project:
Image of a Lightbits project in OCP
2. Within the Lightbits CSI bundle, there are folders containing various examples for secrets and storage classes. I created the following using the lightos_jwt from my Lightbits nodes. I then made it base64 to work with OCP.
image of a Lightbits CSI bundle
3. Go to Workloads, then Secrets in the GUI, and paste the secret file using the ‘Create from YAML’ option.

image of Workloads in the Lightbits CSI folder
5. The next step is to create the default storage class.
image of a default storage class in OCP
6. Note that I have defined this as the default Storage Class for this cluster in the annotations section.

image showing default storage class for Lightbits cluster in OCP
7. With all the setup complete, we can deploy a workload on our Kubernetes cluster using Lightbits storage as a backend. I am using the Unifi network controller application. First, we need to deploy the persistent volume claim with the Lightbits storage class lb-sc.

image showing Lightbits being deployed on a Kubernetes cluster in OCP
8. After the PVC is bound, we need to create the deployment. This may take some time, depending on the availability of resources.

image showing Lightbits deployment in OCPimage of Lightbits deployment in OCP
9. Lastly, we need to expose this deployment outside of the Kubernetes cluster so it’s usable. We do this with a service.yaml
image showing Lightbits exposed to Kubernetes clusterimage of Lightbits cluster exposed to Kubernetes in OCP

10. Open a browser and point it to <your-url>:30006
image of browser window verifying deployment of Lightbits in OCP

This procedure can be used for any application you wish to deploy.  You will need to modify the YAML files to suit the application you are deploying, whether it is a simple one like this or a multi-tier application with a database backend.

Visit Lightbits Homepage for more information or to schedule a demo with me.

About the Writer: