Dgraph's configs assume a Kubernetes cluster with a working volume plugin (provisioner). In managed Kubernetes offerings (aws, GKE, DO etc) this step is already taken care by the provider.
I think the goal should be to achieve par functionality with cloud providers, that is the provisioning must be dynamic (in contrast for example with OP's own answer which is correct but statically provisioned - k8s docs).
When running bare-metal you have to manually configure a volume plugin before being able to dynamically provision volumes (k8s docs) and thus use StatefulSets, PersistentVolumeClaims etc. Thankfully there are many provisioners available (k8s docs). For out of the box support for dynamic provisioning every item in the list that has 'Internal Provisioner' checked will do.
So while the problem has many solutions I ended up using NFS. To achieve dynamic provisioning I had to use an external provisioner. Hopefully this is as simple as installing a Helm Chart.
- Install NFS (original guide) on master node.
ssh via terminal and run
sudo apt update
sudo apt install nfs-kernel-server nfs-common
- Create the directory Kubernetes is going to use and change ownership
sudo mkdir /var/nfs/kubernetes -p
sudo chown nobody:nogroup /var/nfs/kubernetes
- Configure NFS
Open the file /etc/exports
sudo nano /etc/exports
Add the following line at the bottom
/var/nfs/kubernetes client_ip(rw,sync,no_subtree_check)
Replace client_ip
with you master node ip.
In my case this IP was the DHCP server IP leased by my router to the machine running master node (192.168.1.7)
- Restart NFS to apply the changes.
sudo systemctl restart nfs-kernel-server
- After setting up NFS on master and assuming Helm is present, installing the provisioner is as simple as running
helm install nfs-provisioner --set nfs.server=XXX.XXX.XXX.XXX --set nfs.path=/var/nfs/kubernetes --set storageClass.defaultClass=true stable/nfs-client-provisioner
Replace nfs.server
flag with the appropriate IP/hostname of master node/NFS server.
Note flag storageClass.defaultClass
has to be true
in order for Kubernetes to default use the plugin (provisioner) for volume creation.
Flag nfs.path
is the same path as the one created in step 2.
In case Helm complains that can not find the chart run helm repo add stable https://kubernetes-charts.storage.googleapis.com/
- After successfully completing previous steps proceed installing Dgraph configs as described in their docs and enjoy you bare-metal dynamically provisioned cluster with out-of-the-box working Dgraph deployment.
Single server
kubectl create --filename https://raw.githubusercontent.com/dgraph-io/dgraph/master/contrib/config/kubernetes/dgraph-single/dgraph-single.yaml
HA Cluster
kubectl create --filename https://raw.githubusercontent.com/dgraph-io/dgraph/master/contrib/config/kubernetes/dgraph-ha/dgraph-ha.yaml