Integrate Nomad & Elastifile Docker Plugin

In Order to integrate Elastifile Docker plugin with NOMAD please use the following procedure :


NOMAD

  1. Follow this instructions: https://www.nomadproject.io/docs/install/index.html
  2. Deploy Docker


ELastifile Docker Plugin installation


# docker plugin install --grant-all-permissions elastifileio/edvp:
#  docker plugin disable elastifileio/edvp
#  docker plugin set elastifileio/edvp:next MGMT_ADDRESS=10.11.209.222 NFS_ADDRESS=172.16.0.1
#  docker plugin enable elastifileio/edvp:

Or: 

# docker plugin install --grant-all-permissions elastifileio/edvp MGMT_ADDRESS=1.1.1.1 NFS_ADDRESS=2.2.2.2  MGMT_USERNAME=admin MGMT_PASSWORD=changeme CRUD_IDEMPOTENT=true 



Test the Elastifile docker plugin :


# docker plugin ls
ID                  NAME                     DESCRIPTION                           ENABLED
6c75a49ea6bb        elastifileio/edvp:next   Elastifile volume plugin for Docker   true


Deploy docker that will use the Elastifile Docker plugin


# docker volume create -d elastifileio/edvp  --name test-nfs-1 -o size=20GiB
# docker volume ls
DRIVER                   VOLUME NAME
elastifileio/edvp   test-nfs-1


# docker volume inspect test-nfs-1
[
    {
        "Driver": "elastifileio/edvp",
        "Labels": {},
        "Mountpoint": "/mnt/volumes/test-nfs-1",
        "Name": "test-nfs-1",
        "Options": {
            "size": "20GiB"
        },
        "Scope": "local"
    }
]

# docker run -t -d -v test-nfs-1:/data --name TEST_DOCKER_NAME DOCKER_IMAGE


# docker exec -ti TEST_DOCKER_NAME bash

# df -h 
Filesystem               Size  Used Avail Use% Mounted on
overlay                  7.9G  3.6G  4.3G  45% /
tmpfs                    3.9G     0  3.9G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
172.16.0.1:test-nfs-1/e   20G     0   20G   0% /data


# mount 
172.16.0.1:test-nfs-1/e on /data type nfs (rw,relatime,vers=3,rsize=262144,wsize=1048576,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=172.16.0.1,mountvers=3,mountproto=tcp,local_lock=all,addr=172.16.0.1)



Nomad integration with Elastifile Docker Plugin 


  1. Create JOB.nomad and add the following Lines to your nomad job file :


mounts = [
    {
      target = "/data/"
      source = "nomad-test-db-1"
      readonly = false
      volume_options {
        driver_config {
          name = "elastifileio/edvp"
          options = {
      size = "250GiB" --- (Dc Size/Volume Size)
          }
        }
      }
    }
  ]



Example : 


# nomad run mysql-server.nomad
==> Monitoring evaluation "6fa73283"
    Evaluation triggered by job "mysql-server"
    Allocation "6975ea9a" created: node "1da0da89", group "mysql-server"
    Evaluation status changed: "pending" -> "complete"
==> Evaluation "6fa73283" finished with status "complete"

# nomad status mysql-server
ID            = mysql-server
Name          = mysql-server
Submit Date   = 2018-09-13T07:45:50Z
Type          = service
Priority      = 50
Datacenters   = dc1
Status        = running
Periodic      = false
Parameterized = false

Summary
Task Group    Queued  Starting  Running  Failed  Complete  Lost
mysql-server  0       0         1        14      12        0

Allocations
ID        Node ID   Task Group    Version  Desired  Status    Created    Modified
6975ea9a  1da0da89  mysql-server  33       run      running   19s ago    15s ago

# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                        PORTS                                                                     NAMES
98d7f114aac6        1fdf3806e715        "/entrypoint.sh my..."   About a minute ago   Up About a minute (healthy)   33060/tcp, 10.11.184.208:24521->3306/tcp, 10.11.184.208:24521->3306/udp   mysql-server-6975ea9a-8a88-d0e6-ec09-b12ae56b0bb4

# docker exec -ti mysql-server-6975ea9a-8a88-d0e6-ec09-b12ae56b0bb4 bash

# df -h
Filesystem                                                                     Size  Used Avail Use% Mounted on

172.16.0.1:b8680d62dcdb6317ba76e19d1c7f13538be334085311ac2b31d92d00ca463534/e  100G  172M  100G   1% /var/lib/mysql

# docker volume ls
DRIVER                   VOLUME NAME
elastifileio/edvp:next   b8680d62dcdb6317ba76e19d1c7f13538be334085311ac2b31d92d00ca463534




Nomad.job Example File


job "mysql-server" {
  datacenters = ["dc1"]
  type        = "service"

  group "mysql-server" {
    count = 1

    restart {
      attempts = 10
      interval = "5m"
      delay    = "25s"
      mode     = "delay"
    }

    ephemeral_disk {
      migrate = true
      size    = 300
      sticky  = true
    }

    task "mysql-server" {
      driver = "docker"

      config {
        image = "mysql/mysql-server:8.0"

        port_map {
          db = 3306
        }

       mounts = [
    {
      target = "/data/"
      source = "nomad-test-db-1"
      readonly = false
      volume_options {
        driver_config {
          name = "elastifileio/edvp"
          options = {
      size = "250GiB"
          }
        }
      }
    }
  ]

      }

      template {
        data = <<EOH
CREATE DATABASE dbwebappdb;
CREATE USER 'dbwebapp'@'%' IDENTIFIED BY 'dbwebapp';
GRANT ALL PRIVILEGES ON dbwebappdb.* TO 'dbwebapp'@'%';
EOH

        destination = "/docker-entrypoint-initdb.d/db.sql"
      }

      resources {
        cpu    = 500
        memory = 1024

        network {
          mbits = 10

          port "db" {}
        }
      }

      service {
        name = "mysql-server"
        port = "db"

        check {
          type     = "tcp"
          interval = "10s"
          timeout  = "2s"
        }
      }
    }
  }
}


R
Ronen is the author of this solution article.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.