Integration in the Cloudy ecosystem » History » Version 12

Luca Baldesi, 07/24/2018 02:42 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 11 Luca Baldesi
** Optionally (but recommended) you can specify in the same file the interface serf has to use, e.g.,
25 11 Luca Baldesi
<pre>
26 11 Luca Baldesi
SERF_INTERFACE=eth0
27 11 Luca Baldesi
</pre>
28 1 Luca Baldesi
** In case you need, you can start a serf node to be used as bootstrap one with:
29 1 Luca Baldesi
 <pre>
30 1 Luca Baldesi
 serf agent -iface <net_interface> -bind <ip_addr>:<port> 
31 1 Luca Baldesi
 </pre> 
32 3 Luca Baldesi
** In case you have several ip addresses on the serf interface, edit /etc/init.d/serf, changing the line
33 3 Luca Baldesi
 <pre>
34 3 Luca Baldesi
 PUBLIC_IP=$(ip -4 -o addr show up primary scope global $SERF_INTERFACE | sed 's/  */ /g' | cut -d '/' -f1 | grep -o '[^ ]*$')
35 3 Luca Baldesi
</pre>with
36 3 Luca Baldesi
<pre>
37 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
38 3 Luca Baldesi
</pre> and initialize a PUBLIC_IP variable in the /etc/avahi-ps-serf.conf file.
39 1 Luca Baldesi
** Browse localhost:7000 and go to Search->serf to start the Serf service
40 1 Luca Baldesi
# Setup docker
41 1 Luca Baldesi
* Browse localhost:7000 and go to Enterprise->docker, then click get docker
42 1 Luca Baldesi
* Repeat the previous step to install docker
43 1 Luca Baldesi
* Add PeerStreamer-ng docker image coordinates by editing var/local/cDistro/plug/resources/docker/containers/PeerStreamer-ng_latest.json:
44 1 Luca Baldesi
<pre>
45 1 Luca Baldesi
      {
46 1 Luca Baldesi
         "appname": "PeerStreamer-ng",
47 1 Luca Baldesi
         "description": "P2P live video streaming",
48 12 Luca Baldesi
         "arch": "[armhf,amd64]",
49 9 Luca Baldesi
         "image": "--net host lbaldesi/peerstreamer",
50 1 Luca Baldesi
         "name": "peerstreamer"
51 1 Luca Baldesi
        }
52 1 Luca Baldesi
</pre>
53 1 Luca Baldesi
* Change "<arch>" in the with your machine architecture (e.g., armhf, amd64)
54 1 Luca Baldesi
* Browse localhost:7000 and go to Enterprise->docker, then click "add predefined image" to select and install PeerStreamer-ng
55 7 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)
56 1 Luca Baldesi
57 1 Luca Baldesi
h2. PeerStreamer on docker
58 1 Luca Baldesi
59 1 Luca Baldesi
PeerStreamer-ng assumes a running instance of Serf is already setup, which goes reasonably well in the Cloudy environment.
60 1 Luca Baldesi
Serf is needed as PeerStreamer-ng uses it for channel discovery and advertisement.
61 1 Luca Baldesi
62 1 Luca Baldesi
To build the docker image from scratch:
63 1 Luca Baldesi
<pre>
64 8 Luca Baldesi
git clone	https://github.com/netCommonsEU/PeerStreamer-docker.git
65 2 Luca Baldesi
cd peerstreamer_docker
66 9 Luca Baldesi
sudo docker build -t lbaldesi/psng_<arch> .
67 1 Luca Baldesi
</pre>
68 1 Luca Baldesi
69 1 Luca Baldesi
70 1 Luca Baldesi
If you want to push it to docker hub:
71 1 Luca Baldesi
<pre>
72 1 Luca Baldesi
sudo docker login
73 9 Luca Baldesi
sudo docker push lbaldesi/psng_<arch>
74 1 Luca Baldesi
</pre>
75 1 Luca Baldesi
76 1 Luca Baldesi
If you want to create a multiarch peerstreamer image ("tutorial":https://container-solutions.com/multi-arch-docker-images/):
77 1 Luca Baldesi
<pre>
78 5 Luca Baldesi
git clone https://github.com/estesp/manifest-tool.git
79 5 Luca Baldesi
cd manifest-tool/
80 5 Luca Baldesi
sudo make build
81 5 Luca Baldesi
</pre>
82 5 Luca Baldesi
write the following specification file (spec.yml):
83 5 Luca Baldesi
<pre>
84 10 Luca Baldesi
image: lbaldesi/peerstreamer
85 1 Luca Baldesi
manifests:
86 10 Luca Baldesi
  - image: lbaldesi/psng_amd64
87 1 Luca Baldesi
    platform:
88 1 Luca Baldesi
      architecture: amd64
89 1 Luca Baldesi
      os: linux
90 10 Luca Baldesi
  - image: lbaldesi/psng_arm
91 1 Luca Baldesi
    platform:
92 1 Luca Baldesi
      architecture: arm
93 1 Luca Baldesi
      os: linux
94 1 Luca Baldesi
</pre>
95 5 Luca Baldesi
Then push
96 5 Luca Baldesi
<pre>
97 5 Luca Baldesi
sudo ./manifest-tool push from-spec spec.yml 
98 6 Luca Baldesi
</pre>