Skip to content

Commit

Permalink
fixing rpm build scripts and changing all instances of libnetwork-nua…
Browse files Browse the repository at this point in the history
…ge to nuage-libnetwork
  • Loading branch information
sareti committed Jun 8, 2017
1 parent e269dd1 commit 1c80154
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 58 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM centos

# Copy the local package files to the container's workspace.
ADD nuage-libnetwork /libnetwork-nuage
ADD nuage-libnetwork /nuage-libnetwork

# Create file that contains commands for both plugin and ipam
CMD /libnetwork-nuage -config /etc/default/libnetwork-nuage.yaml
CMD /nuage-libnetwork -config /etc/default/nuage-libnetwork.yaml
148 changes: 108 additions & 40 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,84 +26,153 @@ Docker Libnetwork Integration
.. ========= ======= =============================
Libnetwork Plugin
LibNetwork Plugin
========================

Nuage VSP Release 4.0.R6 and later supports Docker with libnetwork.

Overview
--------

The Nuage libnetwork plugin allows the user to create new networks of type Nuage. The new networks of type Nuage in Docker are implemented in the backend by a specific subnet in VSP. A specific Docker network needs to reference a specific subnet from VSP. This is done by giving extra parameters to Docker at network creation time. The user interacts with Docker network, which calls libnetwork. The Nuage implemented plugin serves the request coming from the libnetwork backend.
The Nuage libnetwork plugin allows the user to create new networks of type Nuage. The new networks of type Nuage in Docker are implemented in the backend by a specific subnet in VSP. A specific Docker network needs to reference a specific subnet from VSP. This is done by giving extra Nuage specific parameters to Docker at network creation time. The user interacts with Docker network, which calls libnetwork. The Nuage implemented plugin serves the request coming from the user.

The libnetwork plugin supports both local and global scope networks. The scope defines if your network is going to propagate to all the nodes as part of your cluster. The simplest use case is for single host networking. This translates to networks that are only visible on the host on which the network is added. This use case is configured with the configuration Scope="local". Multihost networking uses a backend store in order to propagate network information to all the cluster participants. As such, a network added on one node is available on all the nodes. This use case is configured with the configuration Scope="global".

Starting from VSP 4.0.R6.1, libnetwork plugin supports built in IPAM driver where the IP address management is done by VSP.

Nuage libnetwork plugin is qualified with Docker Version 1.12.1 and API Version 1.24.

Installing Libnetwork
-----------------------
Installing Nuage LibNetwork Drivers
-----------------------------------

:Step 1: Start the Docker daemon. If the plugin is to be run in "local" scope, then Docker daemon can be started on each host without any extra options. In order to run the plugin with "global" scope, docker-engines on multiple servers need to be started with a backend-store. Following commands show the commands to start Docker daemon with consul.
Nuage LibNetwork plugin can be installed either using a RPM file or using a Docker image.

::
[root@server1:~]# docker daemon --cluster-store=consul://$CONSULSERVER:8500 --cluster-advertise=$server1:2376
[root@server2:~]# docker daemon --cluster-store=consul://$CONSULSERVER:8500 --cluster-advertise=$server2:2376
Installation Using RPM file
^^^^^^^^^^^^^^^^^^^^^^^^^^^

:Step 1: Start the Docker daemon as a service. If the plugin is to be run in "local" scope, then Docker service can be started on each host without any extra options. In order to run the plugin with "global" scope, docker-engines on multiple servers need to be started with a backend-store. Following commands show the commands to start Docker daemon as a service with consul.

:Step 2: Install the Nuage libnetwork rpm using the following command. This installs libnetwork-nuage binary and the required configuration file templates.
::
a. Create a docker service directory as follows:
[root@server1:~]# mkdir /etc/systemd/system/docker.service.d/
b. Then add the docker conf file
[root@server1:~]# cat /etc/systemd/system/docker.service.d/docker.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -D --cluster-store=consul://$CONSULSERVER:8500 --cluster-advertise=$server2:2376
c. Create the docker socket file as follows:
[root@server2:~]# cat /usr/lib/systemd/system/docker.socket
[Unit]
Description=Docker Socket for the API
PartOf=docker.service
[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]
WantedBy=sockets.target
d. Restart the docker service after creating the the above files using the command - service docker restart

:Step 2: Install the Nuage libnetwork rpm using the following command. This installs nuage-libnetwork binary and the required configuration file templates.

::
[root@server1:~]# yum localinstall -y libnetwork-nuage-0-0-1.x86_64.rpm
[root@server1:~]# yum localinstall -y nuage-libnetwork-0-0-1.x86_64.rpm
Once the rpm is installed, you can verify that the Nuage IPAM and plugin are running in the background using following command.

::
[root@server1:~]# systemctl status libnetwork-nuage
libnetwork-nuage.service - Nuage libnetwork plugin for docker
Loaded: loaded (/etc/systemd/system/libnetwork-nuage.service; enabled; vendor preset: disabled)
[root@server1:~]# systemctl status nuage-libnetwork
nuage-libnetwork.service - Nuage libnetwork plugin for docker
Loaded: loaded (/etc/systemd/system/nuage-libnetwork.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2017-01-10 17:55:16 UTC; 3h 22min ago
Main PID: 1516 (libnetwork-nuag)
CGroup: /system.slice/libnetwork-nuage.service
1516 /usr/bin/libnetwork-nuage -config /etc/default/libnetwork-nuage.yaml
CGroup: /system.slice/nuage-libnetwork.service
1516 /usr/bin/nuage-libnetwork -config /etc/default/nuage-libnetwork.yaml

:Step 3: Configure the plugin parameters inside the YAML configuration file. "loglevel" can be "Info", "Debug", "Warn" or "Error" and "scope" can be "local" or "global". 'username', 'password' and 'organization' must be base64 encoded values of their string values. Values shown below are default values that are used if there are no specified values. Place the YAML configuration file under ``/etc/default/nuage-libnetwork.yaml`` on each host where Nuage plugin is run. A sample YAML configuration file for plugin input parameters looks like the following:

::
[root@server1 ~]# cat /etc/default/nuage-libnetwork.yaml
vrssocketfile: "/var/run/openvswitch/db.sock"
dockersocketfile: "unix:///var/run/docker.sock"
vrsbridge: "alubr0"
loglevel: "Debug"
logfilesize: 10
scope: "global"
numofretries: 5
timeinterval: 100
username: Y3Nwcm9vdA==
password: Y3Nwcm9vdA==
organization: Y3Nw
url: https://<VSD URL>:8443

:Step 3: Configure the plugin parameters inside the YAML configuration file. "loglevel" can be "Info", "Debug", "Warn" or "Error" and "logfilesize" is an integer representing the upper limit on the size(in MB) of log file before it gets rotated. "scope" can be "local" or "global". 'username', 'password' and 'organization' must be base64 encoded values of their string values. Values shown below are default values that are used if there are no specified values. Place the YAML configuration file under ``/etc/default/libnetwork-nuage.yaml`` on each host where Nuage plugin is run. A sample YAML configuration file for plugin input parameters looks like the following:
:Step 4: Start the plugin on each host on which it has to run using the following command.

::
[root@server1 ~]# cat /etc/default/libnetwork-nuage.yaml
vrsendpoint: "/var/run/openvswitch/db.sock"
dockerdndpoint: "unix:///var/run/docker.sock"
vrsbridge: "alubr0"
loglevel: "Warn"
logfilesize: 10
scope: "global"
numofretries: 5
timeinterval: 100
username: Y3Nwcm9vdA==
password: Y3Nwcm9vdA==
organization: Y3Nw
url: https://127.0.0.1:8443
systemctl start nuage-libnetwork

Installation using Docker Image
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

:Step 4: Start the plugin on each host on which it has to run using the following command.
:Step 1: Start the docker daemon. If the plugin is to be run in "local" scope, then docker daemon can be started on each host without any extra options. In order to run the plugin with "global" scope, docker-engines on multiple servers need to be started with a backend-store. Following commands show the commands to start docker daemon with consul.

::
systemctl start libnetwork-nuage
::
[root@server1:~]# docker daemon --cluster-store=consul://$CONSULSERVER:8500 --cluster-advertise=$server1:2376
[root@server2:~]# docker daemon --cluster-store=consul://$CONSULSERVER:8500 --cluster-advertise=$server2:2376

:Step 2: Load the containerized plugin into docker images. This can be acheived with the help of following command.

::
[root@server1:~]# docker load -i nuage-plugin.tar
Loaded image can be listed using ``docker images`` command

[root@server1:~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nuage-plugin 4.0R6 18dea274c251 6 hours ago 219.9 MB
busybox latest e02e811dd08f 5 weeks ago 1.093 MB
golang latest 47734a1408b7 7 weeks ago 672.4 MB

:Step 3: Configure the plugin parameters inside the YAML configuration file. "loglevel" can be "Info", "Debug", "Warn" or "Error" and "scope" can be "local" or "global". 'username', 'password' and 'organization' must be base64 encoded values of their string values. Values shown below are default values that are used if there are no specified values. Place the YAML configuration file under ``/etc/default/nuage-libnetwork.yaml`` on each host where Nuage plugin is run. A sample YAML configuration file for plugin input parameters looks like the following:

::
[root@server1 ~]# cat /etc/default/nuage-libnetwork.yaml
vrsendpoint: "/var/run/openvswitch/db.sock"
dockerdndpoint: "unix:///var/run/docker.sock"
vrsbridge: "alubr0"
loglevel: "Warn"
scope: "global"
numofretries: 5
timeinterval: 100
username: Y3Nwcm9vdA==
password: Y3Nwcm9vdA==
organization: Y3Nw
url: https://127.0.0.1:8443

:Step 4: Start the Nuage Libnetwork plugin. Start the plugin on each host on which it has to run using the following command.

:Important Things to Remember:
::

* Plugin needs a restart whenever docker daemon is restarted
* Plugin needs a restart whenever VRS services are restarted
* Plugin needs a restart whenever the input configuration changes
docker run -v /usr/bin/:/usr/bin/ -v /usr/lib64/:/usr/lib64 -v /var/run:/var/run -v /var/log:/var/log -v /etc/default:/etc/default --net=host --privileged -dt nuage-plugin:4.0R7

Notes
^^^^^

::
Plugin needs a restart whenever the input configuration changes


Configuring Single Host Networking
Expand Down Expand Up @@ -207,4 +276,3 @@ That network is now available and ready for consumption on server2:
967ad3ccb5af none null



4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (

//Config data used across packages
const (
LOGDIR = "/var/log/libnetwork-nuage"
LOGFILE = "/var/log/libnetwork-nuage/libnetwork-nuage.log"
LOGDIR = "/var/log/nuage-libnetwork"
LOGFILE = "/var/log/nuage-libnetwork/nuage-libnetwork.log"
PluginDir = "/run/docker/plugins"
PluginName = "nuage"
ContainerIfacePrefix = "eth"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
%define libnetwork_nuage_binary libnetwork-nuage
%define libnetwork_nuage_service libnetwork-nuage.service
%define libnetwork_nuage_yaml libnetwork-nuage.yaml
%define libnetwork_nuage_service_file scripts/libnetwork-nuage.service
%define libnetwork_nuage_binary nuage-libnetwork
%define libnetwork_nuage_service nuage-libnetwork.service
%define libnetwork_nuage_yaml nuage-libnetwork.yaml
%define libnetwork_nuage_service_file scripts/nuage-libnetwork.service
%undefine _missing_build_ids_terminate_build

Name: libnetwork-nuage
Name: nuage-libnetwork
Version: 0.0
Release: 1%{?dist}
Summary: Nuage Libnetwork Plugin
Group: System Environments/Daemons
License: ALU EULA and ASL 2.0
Source0: libnetwork-nuage-%{version}.tar.gz
Source0: nuage-libnetwork-%{version}.tar.gz

BuildRequires: %{?go_compiler:compiler(go_compiler)}%{!?go_compiler:golang}

Expand Down
7 changes: 3 additions & 4 deletions scripts/buildRPM.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ rm -rf /tmp/nuage-libnetwork*

cd $GOPATH/src/github.com/nuagenetworks/nuage-libnetwork
go build
cp nuage-libnetwork libnetwork-nuage

cd /tmp
cp -r $GOPATH/src/github.com/nuagenetworks/nuage-libnetwork libnetwork-nuage-${version}
tar -czvf $HOME/rpmbuild/SOURCES/libnetwork-nuage-${version}.tar.gz libnetwork-nuage-${version}
rpmbuild --nodeps -ba $GOPATH/src/github.com/nuagenetworks/nuage-libnetwork/rpmbuild/libnetwork-nuage.spec
cp -r $GOPATH/src/github.com/nuagenetworks/nuage-libnetwork nuage-libnetwork-${version}
tar -czvf $HOME/rpmbuild/SOURCES/nuage-libnetwork-${version}.tar.gz nuage-libnetwork-${version}
rpmbuild --nodeps -ba $GOPATH/src/github.com/nuagenetworks/nuage-libnetwork/rpmbuild/nuage-libnetwork.spec
4 changes: 2 additions & 2 deletions scripts/create-v2-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ cat <<EOF > $TMPDIR/config.json
"Description": "Docker 1.13 Remote Driver",
"Documentation": "https://docs.docker.com/engine/extend/plugins/",
"Entrypoint": [
"/libnetwork-nuage",
"/nuage-libnetwork",
"-config",
"/etc/default/libnetwork-nuage.yaml"
"/etc/default/nuage-libnetwork.yaml"
],
"Network": {
"type": "host"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Wants=docker.service
After=network.target docker.service

[Service]
ExecStart=/usr/bin/libnetwork-nuage -config /etc/default/libnetwork-nuage.yaml
ExecStart=/usr/bin/nuage-libnetwork -config /etc/default/nuage-libnetwork.yaml
Type=simple
PIDFile=/var/run/libnetwork-nuage/libnetwork-nuage.pid
PIDFile=/var/run/nuage-libnetwork/nuage-libnetwork.pid
Restart=always

[Install]
Expand Down

0 comments on commit 1c80154

Please sign in to comment.