NFS Server

Mounting a shared network drive

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.

NOTE: This example uses CoreOS and systemd, and has not been tested in other environments.

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

  1. Log in to the master node using the DC/OS command line interface:

    1. dcos node ssh --master-proxy --leader
  2. Set up a folder for NFS runtime information:

    1. sudo mkdir /var/lib/nfs
  3. 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 range 10.0.1.0/24 with an appropriate range for your subnet:

    1. cat /etc/exports
    2. /data 10.0.1.0/24(rw,async,no_subtree_check,no_root_squash,fsid=0)
  4. Start rpc-mountd and nfsd:

    1. sudo systemctl start rpc-mountd
    2. sudo systemctl start nfsd
  5. Enable rpc-mountd and nfsd for automatic startup:

    1. sudo systemctl enable rpc-mountd
    2. sudo systemctl enable nfsd

Configure the agent(s) to mount the drive

  1. List nodes in the cluster:

    1. dcos node
    2. HOSTNAME IP ID
    3. 10.0.1.251 10.0.1.251 68ded4c8-8808-4a41-b460-7171355b2037-S1
    4. 10.0.1.252 10.0.1.252 68ded4c8-8808-4a41-b460-7171355b2037-S0
  2. SSH to a node:

    1. dcos node ssh --master-proxy --mesos-id=68ded4c8-8808-4a41-b460-7171355b2037-S0
  3. Make a new folder to mount into:

    1. sudo mkdir /mnt/data
  4. Set up a folder for NFS runtime information:

    1. sudo mkdir /var/lib/nfs
  5. 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 named mnt-data.mount. In addition, replace 10.0.7.181 with the IP of the NFS host. More information can be found in the CoreOS documentation:

    1. cat /etc/systemd/system/mnt-data.mount
    2. [Mount]
    3. What=10.0.7.181:/data
    4. Where=/mnt/data
    5. Type=nfs
  6. Test the new mount by using touch to create a file:

    1. touch /mnt/data/test.txt