Introduction

In this post we will focus on how to Use OpenEBS with hostPath on Kubernetes. The reason to want such a solution is usually to use our Kubernetes worker’s disks. In this way we can provide more storage options to the end users and customers. You can even use it to provide block storage to provide S3 service using Minio on Kubernetes. To deploy Kubernetes you can use our How to Deploy Kubernetes Using Kubespray guide

Procedure

Let’s create our working directory:

$ mkdir /opt/octopus/06_openebs && /opt/octopus/06_openebs

Install OpenEBS using Helm

Add the helm repo:

$ helm repo add openebs https://openebs.github.io/charts
$ helm repo update openebs

Install using Helm:

$ helm install --namespace openebs openebs openebs/openebs

Output:

NAME: openebs
LAST DEPLOYED: Sun Feb 11 15:24:37 2024
NAMESPACE: openebs
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Successfully installed OpenEBS.

Configure the StorageClass with hostPath

Now Deploy the storage class:

custom_sc.yaml

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-octopus-bigdata-hostpath
  annotations:
    openebs.io/cas-type: local
    cas.openebs.io/config: |
      - name: StorageType
        value: hostpath
      - name: BasePath
        value: /var/octopus/bigdata/
provisioner: openebs.io/local
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer

This is the expected output

$ k get storageclass
NAME                             PROVISIONER        RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
local-octopus-bigdata-hostpath   openebs.io/local   Delete          WaitForFirstConsumer   false                  2s
openebs-device                   openebs.io/local   Delete          WaitForFirstConsumer   false                  25m
openebs-hostpath                 openebs.io/local   Delete          WaitForFirstConsumer   false                  25m

For additional information about the local pv option you can read the official documenation.

Default StorageClass in kubernetes

Now, let’s make it the default storageclass:

$ kubectl patch storageclass local-octopus-bigdata-hostpath -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

That’s It! You can now request PVs with PVCs in your Kubernetes cluster and those will be assigned by OpenEBS with storage from you worker disks.

Summary

At Octopus, we’re dedicated to helping our clients harness the full potential of innovative open-source technologies like OpenEBS. Our expert team can guide you through Use OpenEBS with hostPath on Kubernetes environment, ensuring you benefit from its powerful features, while maintaining a high standard of security and performance. With our experience in handling complex systems and air-gapped environments, you can trust us to provide the most efficient solutions tailored to your business needs, empowering you to focus on what truly matters – your core business.

Enjoy.