Installing LongHorn on GKE

How to install LongHorn storage on GKE to provide a self managed shared storage class.

Installing LongHorn on GKE
Photo by Mitchell Luo / Unsplash

Google Kubernetes Engines does not provide an RWX storage class out of the box which is required to deploy Mayan EDMS on Kubernetes.

Without a shared volume, separate Cloud Storage buckets need to be created for each app that uses storage. This works, but there is a perfomance penalty.

LongHorn emulates a shared storage using the local drives of each node and replicating the data accross the network using iSCSI.

1-Obtain Kubernetes credentials

gcloud container clusters get-credentials CLUSTER_NAME --zone us-south1

2-Change cluster context

kubectx

3-Create clusterrolebinding

kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --user=<name@example.com>

4-Install LongHorn

helm repo add longhorn https://charts.longhorn.io

helm repo update

kubectl create namespace longhorn-system

helm install longhorn longhorn/longhorn --namespace longhorn-system

kubectl -n longhorn-system get pod --watch

5-Unset LongHorn as the default storage class

kubectl patch storageclass longhorn -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'

This step is required otherwise two storage classes will be marked as default which will not allow new deployments that use automated provisioning using persistent volume claims