Integration in the Cloudy ecosystem » History » Version 3

Luca Baldesi, 03/06/2018 02:35 PM

1 1 Luca Baldesi
h1. Integration in the Cloudy ecosystem
2 1 Luca Baldesi
3 1 Luca Baldesi
"Cloudy":http://cloudy.community is a project for service discovery and provisioning in community networks.
4 1 Luca Baldesi
5 1 Luca Baldesi
PeerStreamer-ng can be shipped for the Cloudy ecosystem easily through docker images.
6 1 Luca Baldesi
7 1 Luca Baldesi
The first part of this page will deal with the setup of a Cloudy node, while the second part with the creation of the PeerStreamer-ng docker image.
8 1 Luca Baldesi
9 1 Luca Baldesi
h2. Cloudy node setup
10 1 Luca Baldesi
11 1 Luca Baldesi
# Install a debian based distribution; by the time of writing debian 9 (Stretch) works just fine (even in the raspbian flavor).
12 1 Luca Baldesi
# Install cloudy installation dependencies:
13 1 Luca Baldesi
<pre>
14 1 Luca Baldesi
apt-get update; apt-get install -y curl lsb-release vim tmux git
15 1 Luca Baldesi
</pre> 
16 1 Luca Baldesi
# Install cloudy (you can find more detail on "cDistro repo":https://github.com/netCommonsEU/cDistro)
17 1 Luca Baldesi
<pre>
18 1 Luca Baldesi
sudo su
19 1 Luca Baldesi
curl -k https://raw.githubusercontent.com/Clommunity/cloudynitzar/master/cloudynitzar.sh | bash -
20 1 Luca Baldesi
</pre>
21 1 Luca Baldesi
# Setup a serf bootstrap node (otherwise "Serf":http://serf.io will not even start):
22 1 Luca Baldesi
** Edit /etc/avahi-ps-serf.conf
23 1 Luca Baldesi
** Change the parameter SERF_JOIN
24 1 Luca Baldesi
** In case you need, you can start a serf node to be used as bootstrap one with:
25 1 Luca Baldesi
 <pre>
26 1 Luca Baldesi
 serf agent -iface <net_interface> -bind <ip_addr>:<port> 
27 1 Luca Baldesi
 </pre> 
28 3 Luca Baldesi
** In case you have several ip addresses on the serf interface, edit /etc/init.d/serf, changing the line
29 3 Luca Baldesi
 <pre>
30 3 Luca Baldesi
 PUBLIC_IP=$(ip -4 -o addr show up primary scope global $SERF_INTERFACE | sed 's/  */ /g' | cut -d '/' -f1 | grep -o '[^ ]*$')
31 3 Luca Baldesi
</pre>with
32 3 Luca Baldesi
<pre>
33 3 Luca Baldesi
if [ -z "$PUBLIC_IP" ]; then PUBLIC_IP=$(ip -4 -o addr show up primary scope global $SERF_INTERFACE | sed 's/  */ /g' | cut -d '/' -f1 | grep -o '[^ ]*$'); fi
34 3 Luca Baldesi
</pre> and initialize a PUBLIC_IP variable in the /etc/avahi-ps-serf.conf file.
35 1 Luca Baldesi
** Browse localhost:7000 and go to Search->serf to start the Serf service
36 1 Luca Baldesi
# Setup docker
37 1 Luca Baldesi
* Browse localhost:7000 and go to Enterprise->docker, then click get docker
38 1 Luca Baldesi
* Repeat the previous step to install docker
39 1 Luca Baldesi
* Add PeerStreamer-ng docker image coordinates by editing var/local/cDistro/plug/resources/docker/containers/PeerStreamer-ng_latest.json:
40 1 Luca Baldesi
<pre>
41 1 Luca Baldesi
      {
42 1 Luca Baldesi
         "appname": "PeerStreamer-ng",
43 1 Luca Baldesi
         "description": "P2P live video streaming",
44 1 Luca Baldesi
         "arch": "<arch>",
45 1 Luca Baldesi
         "image": "--net host lbaldesi/peerstreamer:devel",
46 1 Luca Baldesi
         "name": "peerstreamer"
47 1 Luca Baldesi
        }
48 1 Luca Baldesi
</pre>
49 1 Luca Baldesi
* Change "<arch>" in the with your machine architecture (e.g., armhf, amd64)
50 1 Luca Baldesi
* Browse localhost:7000 and go to Enterprise->docker, then click "add predefined image" to select and install PeerStreamer-ng
51 1 Luca Baldesi
(it may take some time and the web interface does not show any progress; wait few minutes or check "top" to be sure the command failed) 
52 1 Luca Baldesi
53 1 Luca Baldesi
h2. PeerStreamer on docker
54 1 Luca Baldesi
55 1 Luca Baldesi
PeerStreamer-ng assumes a running instance of Serf is already setup, which goes reasonably well in the Cloudy environment.
56 1 Luca Baldesi
Serf is needed as PeerStreamer-ng uses it for channel discovery and advertisement.
57 1 Luca Baldesi
58 1 Luca Baldesi
To build the docker image from scratch:
59 1 Luca Baldesi
<pre>
60 1 Luca Baldesi
git clone	git@github.com:netCommonsEU/PeerStreamer-docker.git 
61 1 Luca Baldesi
cd PeerStreamer-docker/
62 2 Luca Baldesi
git checkout multiarch
63 1 Luca Baldesi
sudo docker build -t lbaldesi/psng_<arch>:devel .
64 1 Luca Baldesi
</pre>
65 1 Luca Baldesi
66 1 Luca Baldesi
67 1 Luca Baldesi
If you want to push it to docker hub:
68 1 Luca Baldesi
<pre>
69 1 Luca Baldesi
sudo docker login
70 1 Luca Baldesi
sudo docker push lbaldesi/psng_<arch>:devel
71 1 Luca Baldesi
</pre>
72 1 Luca Baldesi
73 1 Luca Baldesi
If you want to create a multiarch peerstreamer image ("tutorial":https://container-solutions.com/multi-arch-docker-images/):
74 1 Luca Baldesi
<pre>
75 1 Luca Baldesi
image: lbaldesi/peerstreamer:devel
76 1 Luca Baldesi
manifests:
77 1 Luca Baldesi
  - image: lbaldesi/psng_amd64:devel
78 1 Luca Baldesi
    platform:
79 1 Luca Baldesi
      architecture: amd64
80 1 Luca Baldesi
      os: linux
81 1 Luca Baldesi
  - image: lbaldesi/psng_arm:devel
82 1 Luca Baldesi
    platform:
83 1 Luca Baldesi
      architecture: arm
84 1 Luca Baldesi
      os: linux
85 1 Luca Baldesi
</pre>