Storage Provisioning for K3s

We have gone trough quite a lot of hassle building our cluster. If we came this far, is time to enjoy its full potential. During the series, we will deploy multiple services, one of which for starters, storage provisioners. When we want to serve web content, we need multiple pods on different nodes, to be able to access the same folder where our web content is stored (ex. /var/www/html) at the same time. To accomplish this, we will use an NFS share, accessible from every node in our cluster. The storage provisioner will take care of providing and mounting persistent storage to each pod.
Clone the repo :

git clone https://github.com/kubernetes-incubator/external-storage

Navigate to the external-storage/nfs-clientfolder. Edit the contents of the deploy/deployment-arm.yaml file to adapt to your NFS server, change the PROVISIONER_NAME value to e.g. nfs-storage, change the NFS_SERVER value to your NFS server IP-address and the NFS_PATH value to suite your NFS server.

NOTE: 5 lines in total should be modified.


Edit the contents of the deploy/class.yaml file and change the provisioner: to what you used for PROVISIONER_NAME value above. The deploy/rbac.yaml file contains config needed for role based access control. Time to apply the 3 yaml-files:

k apply -f deploy/rbac.yaml -f deploy/class.yaml -f deploy/deployment-arm.yaml

We still have the database part to deal with. Ensuring high availability and performance will be a priority. For replicated local storage provisioner, the best fit with K3s ended up with Longhorn.
Install Helm

helm repo add longhorn https://charts.longhorn.io
Fetch the latest charts from the repository:
helm repo update
Install Longhorn in the longhorn-system namespace. To install Longhorn with Helm 2, use this command:
helm install longhorn/longhorn --name longhorn --namespace longhorn-system
git clone https://github.com/longhorn/longhorn
Now use the following command(s) to install Longhorn in the longhorn-system namespace: Helm 2:
helm install ./longhorn/chart --name longhorn --namespace longhorn-system
Helm 3: When installing Longhorn with Helm 3, the namespace is created separately.
kubectl create namespace longhorn-system
helm install longhorn ./longhorn/chart/ --namespace longhorn-system

Comments

Subscribe to our Newsletter