Longhorn: Understanding How It Works with Practical Examples
59%
Using Longhorn Storage Class
As soon as the installation is complete, new storage classes are created in the cluster. You can check them by running the following command:
# SSH into the RKE2 CP
ssh root@$WORKLOAD_CONTROLPLANE_01_PUBLIC_IP
# List the storage classes
kubectl get sc
In order to test it, let's update our application manifest to use the longhorn storage class and push it to Gitea. Fleet should take care of the rest and update the application on the RKE2 cluster.
# SSH into the workspace server
ssh root@$WORKSPACE_PUBLIC_IP
# Update ``local-path`` to ``longhorn`` in the application manifest
sed -i 's/storageClassName: local-path/storageClassName: longhorn/' \
$HOME/todo/app/kube/todo-app-manifests.yaml
# Git commit and push the changes
cd $HOME/todo/app
git add .
git commit -m "Use Longhorn storage class"
git push origin main
Let's also delete the old application from the cluster to avoid PVC conflicts when Fleet tries to apply the new changes.
# SSH into the RKE2 CP
ssh root@$WORKLOAD_CONTROLPLANE_01_PUBLIC_IP
# SSH into the RKE2 CP
ssh root@$WORKLOAD_CONTROLPLANE_01_PUBLIC_IP
# Delete all resources in the namespace
kubectl delete all,secret,pvc,ingress --all -n todo-app-namespace \End-to-End Kubernetes with Rancher, RKE2, K3s, Fleet, Longhorn, and NeuVector
The full journey from nothing to productionEnroll now to unlock all content and receive all future updates for free.
