Lightbits Kubernetes Configuration
This article discusses how to connect Lightbits to Kubernetes for use with persistent volumes.
Configuring Lightbits with Kubernetes
To configure Lightbits with Kubernetes:
Downloading and Installing Packages
Download the CSI plugin tarball and unpack (Note: Cross-check the latest version with Lightbits Support):
curl -1 -O 'https://dl.lightbitslabs.com/public/lightos-csi/raw/files/lb-csi-bundle-v1.20.0.15961757728.tar.gz'sudo tar -xvf lb-csi-bundle-v1.20.0.15961757728.tar.gzCreate the Snapshot controller if not already available:
kubectl create -f k8s/snapshot-controller-4.yamlCreate the CSI plugin with the discovery-client from the extracted yaml file:
kubectl create -f k8s/lb-csi-plugin-k8s-v1.24-dc.yamlCheck the install:
kubectl get --namespace=kube-system statefulset lb-csi-controller; kubectl get --namespace=kube-system daemonsets lb-csi-node; kubectl get --namespace=kube-system pod --selector app=lb-csi-plugin -o wideExpect to see that all pods are in a Ready state and there are no errors.
Configuring the Secret And Storage Class
Grab JWT from the Lightbits cluster and export it:
export LIGHTOS_JWT=eyJhbGc...lxQ2L7Wpe773wConvert the JWT to base 64:
echo -n $LIGHTOS_JWT | base64 -w0 -Copy the output and add it to the secrets file:
- First, open the secrets file in examples/secrets-and-storage-class.yaml.
- Next, paste in the JWT on the next line under jwt: |-, ensuring that the JWT is on one line and the pipe dash symbol stays as |-.
- Finally, change the management IP addresses in the file.
The file should look like the example below:
---# Source: lb-csi-workload-examples/charts/storageclass/templates/secret.yamlapiVersion: v1kind: Secretmetadata: name: example-secret namespace: default labels: helm.sh/chart: "storageclass-0.1.0" app.kubernetes.io/instance: "RELEASE-NAME" app.kubernetes.io/version: "" app.kubernetes.io/managed-by: "Helm"type: lightbitslabs.com/jwtdata: jwt: |- ZXlKaGJHY2lPaUpTVXpJMU5pSXNJbXRwWkNJNkluTjVjM1JsYlRweWIyOTBJaXdpZEhsd0lqb2lTbGRVSW4wLmV5SmhkV1FpT2lKTWFXZG9kRTlUS...pFLTJJSWNHSmpYWEhhNU9pQQ==---# Source: lb-csi-workload-examples/charts/storageclass/templates/storageclass.yamlapiVersion: storage.k8s.io/v1kind: StorageClassmetadata: name: example-scprovisioner: csi.lightbitslabs.comallowVolumeExpansion: trueparameters: mgmt-endpoint: 10.10.0.2:443,10.10.0.3:443,10.10.0.4:443 replica-count: "3" compression: disabled project-name: default mgmt-scheme: grpcs csi.storage.k8s.io/controller-publish-secret-name: example-secret csi.storage.k8s.io/controller-publish-secret-namespace: default csi.storage.k8s.io/controller-expand-secret-name: example-secret csi.storage.k8s.io/controller-expand-secret-namespace: default csi.storage.k8s.io/node-publish-secret-name: example-secret csi.storage.k8s.io/node-publish-secret-namespace: default csi.storage.k8s.io/node-stage-secret-name: example-secret csi.storage.k8s.io/node-stage-secret-namespace: default csi.storage.k8s.io/provisioner-secret-name: example-secret csi.storage.k8s.io/provisioner-secret-namespace: defaultCreate the secrets and first storage class:
kubectl create -f examples/secret-and-storage-class.yamlCheck the status:
kubectl get secret,scTesting the Configuration
The examples/filesystem-workload.yaml file provided with the supplementary package contains two manifests:
- PVC named
example-fs-pvc, referencingexample-scStorageClass created above. - POD named
example-fs-pod, binding toexample-fs-pvc.
Deploying PVC and POD
To deploy the PVC and the POD, run:
kubectl apply -f examples/filesystem-workload.yamlpersistentvolumeclaim/example-fs-pvc createdpod/example-fs-pod createdVerifying Deployment
Using the following command, we will see the PV, PVC resources in Bound status and POD in READY state.
kubectl get pv,pvc,podNAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGEpersistentvolume/pvc-7680be61-0694-44cf-9d1b-1f69827d0b4b 10Gi RWO Delete Bound default/example-fs-pvc example-sc 69sNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGEpersistentvolumeclaim/example-fs-pvc Bound pvc-7680be61-0694-44cf-9d1b-1f69827d0b4b 10Gi RWO example-sc 70sNAME READY STATUS RESTARTS AGEpod/example-fs-pod 1/1 Running 0 70sIf there are any errors, use the command below to view the logs:
kubectl get events --all-namespaces --sort-by='.metadata.creationTimestamp'Verify that the Lightbits volume (PersistentVolume) is mounted to/mnt/test. There should be files in the directory such as an output of the hostname.
kubectl exec --stdin --tty example-fs-pod -- /bin/shls /mnt/testDeleting PVC and POD
kubectl delete -f examples/filesystem-workload.yamlpersistentvolumeclaim "example-fs-pvc" deletedpod "example-fs-pod" deleted