From 1c80154e049c9921e4f66afa5034b6a5b2c57af7 Mon Sep 17 00:00:00 2001 From: sareti Date: Thu, 8 Jun 2017 10:13:19 -0400 Subject: [PATCH] fixing rpm build scripts and changing all instances of libnetwork-nuage to nuage-libnetwork --- Dockerfile | 4 +- README.rst | 148 +++++++++++++----- config/config.go | 4 +- ...template => nuage-libnetwork.yaml.template | 0 ...twork-nuage.spec => nuage-libnetwork.spec} | 12 +- scripts/buildRPM.sh | 7 +- scripts/create-v2-plugin.sh | 4 +- ...nuage.service => nuage-libnetwork.service} | 4 +- 8 files changed, 125 insertions(+), 58 deletions(-) rename libnetwork-nuage.yaml.template => nuage-libnetwork.yaml.template (100%) rename rpmbuild/{libnetwork-nuage.spec => nuage-libnetwork.spec} (83%) rename scripts/{libnetwork-nuage.service => nuage-libnetwork.service} (58%) diff --git a/Dockerfile b/Dockerfile index 8398d81..30d6024 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/README.rst b/README.rst index 725870c..64ab4a3 100644 --- a/README.rst +++ b/README.rst @@ -26,7 +26,7 @@ Docker Libnetwork Integration .. ========= ======= ============================= -Libnetwork Plugin +LibNetwork Plugin ======================== Nuage VSP Release 4.0.R6 and later supports Docker with libnetwork. @@ -34,7 +34,7 @@ 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". @@ -42,68 +42,137 @@ Starting from VSP 4.0.R6.1, libnetwork plugin supports built in IPAM driver wher 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://: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 @@ -207,4 +276,3 @@ That network is now available and ready for consumption on server2: 967ad3ccb5af none null - diff --git a/config/config.go b/config/config.go index b8d56a1..b5194f6 100644 --- a/config/config.go +++ b/config/config.go @@ -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" diff --git a/libnetwork-nuage.yaml.template b/nuage-libnetwork.yaml.template similarity index 100% rename from libnetwork-nuage.yaml.template rename to nuage-libnetwork.yaml.template diff --git a/rpmbuild/libnetwork-nuage.spec b/rpmbuild/nuage-libnetwork.spec similarity index 83% rename from rpmbuild/libnetwork-nuage.spec rename to rpmbuild/nuage-libnetwork.spec index 21b3e0b..b93d485 100644 --- a/rpmbuild/libnetwork-nuage.spec +++ b/rpmbuild/nuage-libnetwork.spec @@ -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} diff --git a/scripts/buildRPM.sh b/scripts/buildRPM.sh index 2af6d4b..4e15cd5 100755 --- a/scripts/buildRPM.sh +++ b/scripts/buildRPM.sh @@ -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 diff --git a/scripts/create-v2-plugin.sh b/scripts/create-v2-plugin.sh index 66bce4a..4a1171c 100755 --- a/scripts/create-v2-plugin.sh +++ b/scripts/create-v2-plugin.sh @@ -24,9 +24,9 @@ cat < $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" diff --git a/scripts/libnetwork-nuage.service b/scripts/nuage-libnetwork.service similarity index 58% rename from scripts/libnetwork-nuage.service rename to scripts/nuage-libnetwork.service index cf9a9a4..1e30e43 100644 --- a/scripts/libnetwork-nuage.service +++ b/scripts/nuage-libnetwork.service @@ -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]