A Persistent Volume aka (PV) is a piece of storage in the cluster that has been provisioned or dynamically provisioned using Storage Classes. It is a resource in the cluster just like a node is a cluster resource. PVs have lifecycle independent of any individual Pod that uses the PV.
Longhorn is a lightweight, reliable and easy-to-use distributed block storage system for Kubernetes.
Because we’re running our cluster on physical hardware rather then a cloud provider we do not have the advantage of tapping into the quality of life perks that you normally get from the cloud like high availability, tools to automate backups etc. So when we use our own hardware we need to take on this responsibility for ourselves.
Containers should be starless but at times we need to maintain state, examples include:
Longhorn works as a deamonset thus by default for each storage is replicated across the notes of the cluster. The pro to this is if one drive becomes unavailable then the one of the replicas will become the active storage node. The cons is this duplication means for each node you have in the longhorn cluster will increase the storage required by X.
In my setup I have 4 nodes, which means for each 1GB of storage I will need 4GB.
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.3.2/deploy/longhorn.yaml
This can take a while… you can watch the status of the pods with the following command
watch kubectl get pods --namespace longhorn-system
Once all the nodes are running we can can look to create a new ingress rule for the service.
Create a file called ingress.yaml
. Replace the master node in the code below with the IP of one of your master nodes.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: longhorn-ingress
namespace: longhorn-system
annotations:
kubernetes.io/ingress.class: "traefik"
spec:
rules:
- host: "longhorn.<master_node>.nip.io"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: longhorn-frontend
port:
number: 80
Now run
kubectl apply -f ingress.yaml
once applied, you should be able to access the Longhorn dashboard from a browser via http://longhorn.<master_node>.nip.io
How to setup AWS S3 as a Backup For Longhorn