CORD : Using Volumes for Initial ONOS Configuration

ONOS uses several files in the the /root/onos/config directory within the running Docker container to establish an initial configuration:

  • network-cfg.json - the initial netcfg values, including configuration for the applications that can be established via this file
  • component-cfg.json - the initial component configuration options that can be set via the cfg set command from the ONOS CLI
  • cluster.json - the cluster configuration for ONOS 

NOTE: For the purposes of this guide the cluster.json file will be ignored. There are several ways to establish a cluster in ONOS and that is outside the scope of this guide.

Establishing A Configuration Volume

The best practice for sharing file system information into a Docker container is to do so via a Docker Volume. As ONOS will be running in a Docker Swarm cluster, the node on which ONOS is executing cannot be determined as such to use a volume to configure ONOS a distributed volume should be used. By default VOLTHA installs with glusterfs installed, so within an "installed" VOLTHA instance a glusterfs volume can be used. Docker supports many additional Volume Plugins that could be leveraged as well.

NOTE: glusterfs is not used in VOLTHA via the glusterfs volume plugin, instead it is used by providing mount points on the hosts through which containers can access the distributed file system.

NOTE: while glusterfs is available on a VOLTHA cluster, the rest of this guide will use an NFS mounted volume. Installing and setting up NFS is left as an exercise for the reader as many Google pages describe how to configure NFS.

For the purpose of this guide we will create the directory structure we wish to export as /var/onos_config and populate it with a network-cfg.json and component-cfg.json file.

 

sudo mkdir /var/onos_config
sudo cp <desired-network-cfg.json> /var/onos_config
sudo cp <desired-component-cfg.json> /var/onos_config

 

The local directory /var/onos_config then needs to be exported so that it can be nfs mounted on other systems.

Creating Volumes

The first step when working with volume is making sure that the volume is available on every node in the cluster. When working with several volume plugins this involves installing and running daemon processes to manage volume across the cluster. When working with NFS you can simply create a local volume on each node in the cluster that represents an NFS mount. The following can be executed on each node in the cluster:

docker volume create --name onos_config -d local -o type=nfs -o o=addr=172.42.43.101,ro -o device=:/var/onos_config

NOTE: the IP address, 172.42.43.101, should be the IP address of the NFS server

Configure Volume on ONOS

services:
    onos:
        deploy:
           replicas: 1
        image: "cord/onos"
        ports:
            - 8100:8101 # ssh
            - 6652:6653 # OF
            - 8180:8181 # UI
        volumes:
            - onos_config:/root/onos/config:ro

volumes:
    onos_config:
        external:
            name: onos_config