Develop RackHD with Docker

Prerequisites

Developing with the RackHD Docker files and infrsaim requires the use to have Docker and Docker-compose installed (https://www.docker.com).  This environment will use a virtual open switch to connect the Docker RackHD instance to the virutal nodes from Infrasim.  This requires virtual openswitch to be installed (http://openvswitch.org)

Fetching and building RackHD source code

  1. The first step is to clone all of the RackHD code to your local workstation.  You need to perform a recursive clone to ensure all the submodules have been initailzed.  

    Clone RackHD source code:
    git clone --recursive http://github.com/rackhd/rackhd
  2. Set the TAG environment variable, this is the tag used by the docker-compose scripts for the rackhd images.  This write-up uses the tag "latest", which points to the most recent RackHD release, however any valid tag from the RackHD dockerhub can be used. 

    Set TAG
    export TAG=latest
  3. Run the script setup-network.sh as sudo from the rackhd/docker direcotory.  This script will create a dummy network adapter, eth1, and a ovs bridge, ovs-br0.  The ovs-br0 bridge will be assigned the default ip address of 172.31.128.1.  This bridge will be used to connect the Infrasim virtual nodes to RackHD. 

    Setup Networking
    ○ → cd rackhd/docker/
    
     2017-12-04 10:16:30 ⌚  florida in ~/.../rackhd/docker
    ○ → sudo ./setup-network.sh 
    [sudo] password for tom: 
    eth1      Link encap:Ethernet  HWaddr 6a:fe:c6:b8:32:01  
              inet6 addr: fe80::68fe:c6ff:feb8:3201/64 Scope:Link
              UP BROADCAST RUNNING NOARP  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:0 (0.0 B)  TX bytes:70 (70.0 B)
    
    /usr/bin/ovs-vsctl
    eth1 is a port on ovs-br0
    ovs-br0   Link encap:Ethernet  HWaddr fe:ef:dd:07:11:4e  
              inet addr:172.31.128.1  Bcast:0.0.0.0  Mask:255.255.255.0
              inet6 addr: fe80::fcef:ddff:fe07:114e/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
  4. Use Docker-Compose to pull the docker images from the RackHD dockerhub.  See step 7 below if you wish to build and run your own source code for any of the RackHD services.  

    Fetch Docker Images
    ○ → docker-compose -f docker-compose.yml pull
    Pulling files (rackhd/files:latest)...
    latest: Pulling from rackhd/files
    b56ae66c2937: Already exists
    e93041fc333e: Pull complete
    4fdf57d8c38a: Pull complete
    a96dcce0e684: Pull complete
    079444bcbb62: Downloading [=====>                                             ]  22.69MB/200.6MB
    ...
    
    
  5. Now use docker-compose to start all of the RackHD services.  They will remain running in the window they are started in.  

    Start RackHD
    ○ → docker-compose -f docker-compose.yml up
    Starting docker_rabbitmq_1 ... 
    Recreating docker_files_1 ... 
    Starting docker_rabbitmq_1
    Recreating docker_files_1
    Recreating docker_tasks_1 ... 
    Recreating docker_core_1 ... 
    Recreating docker_core_1
    Recreating docker_tasks_1
    Starting docker_mongo_1 ... 
    Starting docker_mongo_1
    Recreating docker_dhcp_1 ... 
    Starting docker_rabbitmq_1 ... done
    Recreating docker_syslog_1 ... 
    Recreating docker_files_1 ... done
    Recreating docker_http_1 ... 
    Recreating docker_dhcp-proxy_1 ... 
    Recreating docker_http_1
    Recreating docker_syslog_1 ... done
    Recreating docker_tftp_1 ... 
    Recreating docker_tftp_1
    Recreating docker_taskgraph_1 ... 
    Recreating docker_tasks_1 ... done
    
  6. Once RackHD is up and running, you need to open a new shell window then you can use the start-node.sh script to start up a InfraSim vNode.  This script will prompt you for the sudo password so it can set up the vNode network.  

    Start vNode
    ○ → ./start-node.sh 
    Going to stop and remove container infrasim because it's running.
    3.5.1: Pulling from infrasim/infrasim-compute
    Digest: sha256:4373ceea679128e5135f33c0e80822016f4588e9e158fcd72a2d0fb3898ac213
    Status: Image is up to date for infrasim/infrasim-compute:3.5.1
    a1faebb4305d1d860fc2565ccc7b7c0aeb3e3d51b8af97209a4f9a5d04ce4914
    Cloning pipework
    Cloning into 'pipework'...
    remote: Counting objects: 501, done.
    remote: Total 501 (delta 0), reused 0 (delta 0), pack-reused 501
    Receiving objects: 100% (501/501), 172.97 KiB | 0 bytes/s, done.
    Resolving deltas: 100% (264/264), done.
    Checking connectivity... done.
    IP assigned for eth1 is: 172.31.128.169
    [ 93     ] default-socat starts to run
    [ 96     ] default-bmc starts to run
    [ 106    ] default-node is running
    Infrasim service started.
    Node default graphic interface accessible via: 
    VNC port: 5901 
    Either host IP: ['172.17.0.2', '127.0.0.1', '172.31.128.169'] 
    depending on host in which network VNC viewer is running 
    Node log folder: /var/log/infrasim/default
    

    You can connect to the vNode with vncviewer on port 5901 using the 172.31.128.xx IP address output by the start_vnode.sh script.  After the node has started, RackHD should start to discover the node.  This can be verifed by watching the RackHD log output in your origianl terminal window.  

  7.   Finally, it you wish to run your own RackHD source code, you should make your changes to the appropriate modue, and the you can re-build the docker image using the command "docker-compose build <service>" where service is one of core, tasks, dchp-proxy, http, syslog, taskgraph or tftp.  Once your custom image has been build it can be run with the docker-compose up command

    Build Docker Images
    ○ → docker-compose -f docker-compose.yml build http
    Building http
    Step 1/9 : ARG repo=rackhd
    Step 2/9 : ARG tag=devel
    Step 3/9 : FROM ${repo}/on-tasks:${tag}
     ---> 7e3418c19e66
    Step 4/9 : COPY . /RackHD/on-http/
    ...
    
    
    ○ → docker-compose -f docker-compose.yml up
    Starting docker_rabbitmq_1 ... 
    Recreating docker_files_1 ... 
    Starting docker_rabbitmq_1
    ...