Overview
For some stateful services, such as Jenkins, it can be convenient to mount a shared network drive to every node. A shared network drive makes it possible to launch the task on a new node if the node in use becomes unavailable.
Notes
- These instructions are CoreOS-specific.
- This is not an HA NFS server. It runs on a single master and should only be used as a proof of concept.
- If you have access to a pre-existing NFS or another network store, skip to Configure the agent(s) to mount the drive .
Configure the master with the file-share
-
Log in to the master node using the DC/OS command line interface:
dcos node ssh --master-proxy --leader
-
Set up a folder for NFS runtime information:
sudo mkdir /var/lib/nfs
-
Write an
/etc/exports
file to describe the folders to export. Replace the path/data
with the absolute path to the export folder, and the CIDR range10.0.1.0/24
with an appropriate range for your subnet:cat /etc/exports /data 10.0.1.0/24(rw,async,no_subtree_check,no_root_squash,fsid=0)
-
Start
rpc-mountd
andnfsd
:sudo systemctl start rpc-mountd sudo systemctl start nfsd
-
Enable
rpc-mountd
andnfsd
for automatic startup:sudo systemctl enable rpc-mountd sudo systemctl enable nfsd
Configure the agent(s) to mount the drive
-
List nodes in the cluster:
dcos node HOSTNAME IP ID 10.0.1.251 10.0.1.251 68ded4c8-8808-4a41-b460-7171355b2037-S1 10.0.1.252 10.0.1.252 68ded4c8-8808-4a41-b460-7171355b2037-S0
-
SSH to a node:
dcos node ssh --master-proxy --mesos-id=68ded4c8-8808-4a41-b460-7171355b2037-S0
-
Make a new folder to mount into:
sudo mkdir /mnt/data
-
Set up a folder for NFS runtime information:
sudo mkdir /var/lib/nfs
-
Create a new
systemd
mount unit to describe the mount. The name of the.mount
file is the same as the path to the mount point, with the leading slash removed and other slashes converted to dash. Using/mnt/data
as an example, the file is namedmnt-data.mount
. In addition, replace10.0.7.181
with the IP of the NFS host. More information can be found in the CoreOS documentation:cat /etc/systemd/system/mnt-data.mount [Mount] What=10.0.7.181:/data Where=/mnt/data Type=nfs
-
Test the new mount by using
touch
to create a file:touch /mnt/data/test.txt