Merge "ci: build 5.8.0 packages for Apex"
[barometer.git] / docs / release / userguide / docker.userguide.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. (c) <optionally add copywriters name>
4
5 ===================================
6 OPNFV Barometer Docker User Guide
7 ===================================
8
9 .. contents::
10    :depth: 3
11    :local:
12
13 The intention of this user guide is to outline how to install and test the
14 Barometer projects Collectd, Influxdb and Grafana docker images which can be built from the Dockerfiles
15 available within the barometer repository.
16
17
18 Barometer docker images description
19 -----------------------------------
20
21 .. Describe the specific features and how it is realised in the scenario in a brief manner
22 .. to ensure the user understand the context for the user guide instructions to follow.
23
24 Barometer Collectd Image
25 ^^^^^^^^^^^^^^^^^^^^^^^^
26 The barometer collectd docker image gives you a collectd installation that includes all
27 the barometer plugins.
28
29 .. note::
30    The Dockerfile is available in the docker/barometer-collectd directory in the barometer repo.
31    The Dockerfile builds a CentOS 7 docker image.
32    The container MUST be run as a privileged container.
33
34 Collectd is a daemon which collects system performance statistics periodically
35 and provides a variety of mechanisms to publish the collected metrics. It
36 supports more than 90 different input and output plugins. Input plugins
37 retrieve metrics and publish them to the collectd deamon, while output plugins
38 publish the data they receive to an end point. Collectd also has infrastructure
39 to support thresholding and notification.
40
41 Collectd docker image has enabled the following collectd plugins (in addition
42 to the standard collectd plugins):
43
44 * hugepages plugin
45 * Open vSwitch events Plugin
46 * Open vSwitch stats Plugin
47 * mcelog plugin
48 * PMU plugin
49 * RDT plugin
50 * virt
51 * SNMP Agent
52 * Kafka_write plugin
53
54 Plugins and third party applications in Barometer repository that will be available in the
55 docker image:
56
57 * Open vSwitch PMD stats
58 * ONAP VES application
59 * gnocchi plugin
60 * aodh plugin
61 * Legacy/IPMI
62
63 InfluxDB + Grafana Images
64 ^^^^^^^^^^^^^^^^^^^^^^^^^
65
66 The Barometer project's InfluxDB and Grafana docker images are 2 docker images that database and graph
67 statistics reported by the Barometer collectd docker. InfluxDB is an open-source time series database
68 tool which stores the data from collectd for future analysis via Grafana, which is a open-source
69 metrics anlytics and visualisation suite which can be accessed through any browser.
70
71 Installing Docker
72 -----------------
73 .. Describe the specific capabilities and usage for <XYZ> feature.
74 .. Provide enough information that a user will be able to operate the feature on a deployed scenario.
75
76 On Ubuntu
77 ^^^^^^^^^^
78 .. note::
79  * sudo permissions are required to install docker.
80  * These instructions are for Ubuntu 16.10
81
82 To install docker:
83
84 .. code:: bash
85
86     $ sudo apt-get install curl
87     $ sudo curl -fsSL https://get.docker.com/ | sh
88     $ sudo usermod -aG docker <username>
89     $ sudo systemctl status docker
90
91 Replace <username> above with an appropriate user name.
92
93 On CentOS
94 ^^^^^^^^^^
95 .. note::
96  * sudo permissions are required to install docker.
97  * These instructions are for CentOS 7
98
99 To install docker:
100
101 .. code:: bash
102
103     $ sudo yum remove docker docker-common docker-selinux docker-engine
104     $ sudo yum install -y yum-utils  device-mapper-persistent-data  lvm2
105     $ sudo yum-config-manager   --add-repo    https://download.docker.com/linux/centos/docker-ce.repo
106     $ sudo yum-config-manager --enable docker-ce-edge
107     $ sudo yum-config-manager --enable docker-ce-test
108     $ sudo yum install docker-ce
109     $ sudo usermod -aG docker <username>
110     $ sudo systemctl status docker
111
112 Replace <username> above with an appropriate user name.
113
114 .. note::
115    If this is the first time you are installing a package from a recently added
116    repository, you will be prompted to accept the GPG key, and the key’s
117    fingerprint will be shown. Verify that the fingerprint is correct, and if so,
118    accept the key. The fingerprint should match060A 61C5 1B55 8A7F 742B 77AA C52F
119    EB6B 621E 9F35.
120
121         Retrieving key from https://download.docker.com/linux/centos/gpg
122         Importing GPG key 0x621E9F35:
123          Userid     : "Docker Release (CE rpm) <docker@docker.com>"
124          Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
125          From       : https://download.docker.com/linux/centos/gpg
126         Is this ok [y/N]: y
127
128 Proxy Configuration:
129 ^^^^^^^^^^^^^^^^^^^^
130 .. note::
131    This applies for both CentOS and Ubuntu.
132
133 If you are behind an HTTP or HTTPS proxy server, you will need to add this
134 configuration in the Docker systemd service file.
135
136 1. Create a systemd drop-in directory for the docker service:
137
138 .. code:: bash
139
140    $ sudo mkdir -p /etc/systemd/system/docker.service.d
141
142 2. Create a file
143 called /etc/systemd/system/docker.service.d/http-proxy.conf that adds
144 the HTTP_PROXY environment variable:
145
146 .. code:: bash
147
148    [Service]
149    Environment="HTTP_PROXY=http://proxy.example.com:80/"
150
151 Or, if you are behind an HTTPS proxy server, create a file
152 called /etc/systemd/system/docker.service.d/https-proxy.conf that adds
153 the HTTPS_PROXY environment variable:
154
155 .. code:: bash
156
157     [Service]
158     Environment="HTTPS_PROXY=https://proxy.example.com:443/"
159
160 Or create a single file with all the proxy configurations:
161 /etc/systemd/system/docker.service.d/proxy.conf
162
163 .. code:: bash
164
165     [Service]
166     Environment="HTTP_PROXY=http://proxy.example.com:80/"
167     Environment="HTTPS_PROXY=https://proxy.example.com:443/"
168     Environment="FTP_PROXY=ftp://proxy.example.com:443/"
169     Environment="NO_PROXY=localhost"
170
171 3. Flush changes:
172
173 .. code:: bash
174
175     $ sudo systemctl daemon-reload
176
177 4. Restart Docker:
178
179 .. code:: bash
180
181     $ sudo systemctl restart docker
182
183 5. Check docker environment variables:
184
185 .. code:: bash
186
187     sudo systemctl show --property=Environment docker
188
189 Test docker installation
190 ^^^^^^^^^^^^^^^^^^^^^^^^
191 .. note::
192       This applies for both CentOS and Ubuntu.
193
194 .. code:: bash
195
196    $ sudo docker run hello-world
197
198 The output should be something like:
199
200 .. code:: bash
201
202    Unable to find image 'hello-world:latest' locally
203    latest: Pulling from library/hello-world
204    5b0f327be733: Pull complete
205    Digest: sha256:07d5f7800dfe37b8c2196c7b1c524c33808ce2e0f74e7aa00e603295ca9a0972
206    Status: Downloaded newer image for hello-world:latest
207
208    Hello from Docker!
209    This message shows that your installation appears to be working correctly.
210
211    To generate this message, Docker took the following steps:
212     1. The Docker client contacted the Docker daemon.
213     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
214     3. The Docker daemon created a new container from that image which runs the
215        executable that produces the output you are currently reading.
216     4. The Docker daemon streamed that output to the Docker client, which sent it
217        to your terminal.
218
219 To try something more ambitious, you can run an Ubuntu container with:
220
221 .. code:: bash
222
223     $ docker run -it ubuntu bash
224
225 Build the collectd docker image
226 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
227
228 .. code:: bash
229
230     $ git clone https://gerrit.opnfv.org/gerrit/barometer
231     $ cd barometer/docker/barometer-collectd
232     $ sudo docker build -t opnfv/barometer-collectd --build-arg http_proxy=`echo $http_proxy` \
233       --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
234
235 .. note::
236    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs to be
237    passed only if system is behind an HTTP or HTTPS proxy server.
238
239 Check the docker images:
240
241 .. code:: bash
242
243    $ sudo docker images
244
245 Output should contain a barometer-collectd image:
246
247 .. code::
248
249    REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
250    opnfv/barometer-collectd     latest              05f2a3edd96b        3 hours ago         1.2GB
251    centos                       7                   196e0ce0c9fb        4 weeks ago         197MB
252    centos                       latest              196e0ce0c9fb        4 weeks ago         197MB
253    hello-world                  latest              05a3bd381fc2        4 weeks ago         1.84kB
254
255 Download the collectd docker image
256 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
257 If you want to use a pre-built barometer image, you can pull the barometer
258 image from https://hub.docker.com/r/opnfv/barometer-collectd/
259
260 .. code:: bash
261
262     $ docker pull opnfv/barometer-collectd
263
264
265 Run the collectd docker image
266 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
267 .. code:: bash
268
269    $ sudo docker run -tid --net=host -v `pwd`/../src/collectd_sample_configs:/opt/collectd/etc/collectd.conf.d \
270     -v /var/run:/var/run -v /tmp:/tmp --privileged opnfv/barometer-collectd /run_collectd.sh
271
272 .. note::
273   The docker collectd image contains configuration for all the collectd plugins. In the command
274   above we are overriding /opt/collectd/etc/collectd.conf.d by mounting a host directory
275   `pwd`/../src/collectd_sample_configs that contains only the sample configurations we are interested
276   in running. *It's important to do this if you don't have DPDK, or RDT installed on the host*.
277   Sample configurations can be found at:
278   https://github.com/opnfv/barometer/tree/master/src/collectd/collectd_sample_configs
279
280 To make some changes when the container is running run:
281
282 .. code:: bash
283
284    sudo docker exec -ti opnfv/barometer-collectd /bin/bash
285
286 Check your docker image is running
287
288 .. code:: bash
289
290    sudo docker ps
291
292 Build the influxdb + Grafana docker images
293 ------------------------------------------
294
295 Overview
296 ^^^^^^^^
297 The barometer-influxdb image is based on the influxdb:1.3.7 image from the influxdb dockerhub. To
298 view detils on the base image please visit
299 `https://hub.docker.com/_/influxdb/  <https://hub.docker.com/_/influxdb/>`_ Page includes details of
300 exposed ports and configurable enviromental variables of the base image.
301
302 The barometer-grafana image is based on grafana:4.6.3 image from the grafana dockerhub. To view
303 details on the base image please visit
304 `https://hub.docker.com/r/grafana/grafana/ <https://hub.docker.com/r/grafana/grafana/>`_ Page
305 includes details on exposed ports and configurable enviromental variables of the base image.
306
307 The barometer-grafana image includes pre-configured source and dashboards to display statistics exposed
308 by the barometer-collectd image. The default datasource is an influxdb database running on localhost
309 but the address of the influxdb server can be modified when launching the image by setting the
310 environmental variables influxdb_host to IP or hostname of host on which influxdb server is running.
311
312 Additional dashboards can be added to barometer-grafana by mapping a volume to /opt/grafana/dashboards.
313 Incase where a folder is mounted to this volume only files included in this folder will be visible
314 inside barometer-grafana. To ensure all default files are also loaded please ensure they are included in
315 volume folder been mounted. Appropriate example are given in section `Run the Grafana docker image`_
316
317 Download the InfluxDB and Grafana docker image
318 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
319 If you wish to use pre-built barometer project's influxdb and grafana images, you can pull the
320 images from https://hub.docker.com/r/opnfv/barometer-influxdb/ and https://hub.docker.com/r/opnfv/barometer-grafana/
321
322 .. note::
323      If your preference is to build images locally please see sections `Build the InfluxDB Image`_ and
324      `Build the Grafana Image`_
325
326 .. code:: bash
327
328     $ docker pull opnfv/barometer-influxdb
329     $ docker pull opnfv/barometer-grafana
330
331 .. note::
332      If you have pulled the pre-built barometer-influxdb and barometer-grafana images there is no
333      requirement to complete steps outlined in  sections `Build the InfluxDB Image`_ and
334      `Build the Grafana Image`_ and you can proceed directly to section
335      `Run the Influxdb and Grafana Images`_ If you wish to run the barometer-influxdb and
336      barometer-grafana images via Docker Compose proceed directly to section
337      `Docker Compose`_.
338
339 Build the InfluxDB Image
340 ^^^^^^^^^^^^^^^^^^^^^^^^^
341
342 Build influxdb image from Dockerfile
343
344 .. code:: bash
345
346   $ cd barometer/docker/barometer-influxdb
347   $ sudo docker build -t opnfv/barometer-influxdb --build-arg http_proxy=`echo $http_proxy` \
348       --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
349
350 .. note::
351       In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs to
352       be passed only if system is behind an HTTP or HTTPS proxy server.
353
354 Check the docker images:
355
356 .. code:: bash
357
358    $ sudo docker images
359
360 Output should contain an influxdb image:
361
362 .. code::
363
364    REPOSITORY                   TAG                 IMAGE ID            CREATED            SIZE
365    opnfv/barometer-influxdb     latest              1e4623a59fe5        3 days ago         191MB
366
367 Build the Grafana Image
368 ^^^^^^^^^^^^^^^^^^^^^^^
369
370 Build Grafana image from Dockerfile
371
372 .. code:: bash
373
374   $ cd barometer/docker/barometer-grafana
375   $ sudo docker build -t opnfv/barometer-grafana --build-arg http_proxy=`echo $http_proxy` \
376       --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
377
378 .. note::
379          In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs to be passed only if system is behind an HTTP or HTTPS proxy server.
380
381 Check the docker images:
382
383 .. code:: bash
384
385    $ sudo docker images
386
387 Output should contain an influxdb image:
388
389 .. code::
390
391    REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
392    opnfv/barometer-grafana      latest              05f2a3edd96b        3 hours ago         1.2GB
393
394 Run the Influxdb and Grafana Images
395 -----------------------------------
396
397 Run the InfluxDB  docker image
398 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
399 .. code:: bash
400
401    $ sudo docker run -tid --net=host -v /var/lib/influxdb:/var/lib/influxdb -p 8086:8086 -p 25826:25826  opnfv/barometer-influxdb
402
403 To make some changes when the container is running run:
404
405 .. code:: bash
406
407    sudo docker exec -ti opnfv/barometer-influxdb /bin/bash
408
409 Check your docker image is running
410
411 .. code:: bash
412
413    sudo docker ps
414
415 Run the Grafana docker image
416 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
417
418 Connecting to an influxdb instance running on local system and adding own custom dashboards
419
420 .. code:: bash
421
422    $ sudo docker run -tid --net=host -v /var/lib/grafana:/var/lib/grafana -v ${PWD}/dashboards:/opt/grafana/dashboards -p 3000:3000 opnfv/barometer-grafana
423
424 Connecting to an influxdb instance running on remote system with hostname of someserver and IP address of 192.168.121.111
425
426 .. code:: bash
427
428    $ sudo docker run -tid --net=host -v /var/lib/grafana:/var/lib/grafana -p 3000:3000 -e influxdb_host=someserver --add-host someserver:192.168.121.111 opnfv/barometer-grafana
429
430 To make some changes when the container is running run:
431
432 .. code:: bash
433
434    sudo docker exec -ti opnfv/barometer-grafana /bin/bash
435
436 Check your docker image is running
437
438 .. code:: bash
439
440    sudo docker ps
441
442 Connect to <host_ip>:3000 with a browser and log into grafana: admin/admin
443
444 Docker Compose
445 --------------
446
447 Install docker-compose
448 ^^^^^^^^^^^^^^^^^^^^^^
449
450 On the node where you want to run influxdb + grafana or the node where you want to run the VES app
451 zookeeper and Kafka containers together:
452
453 .. note::
454       The default configuration for all these containers is to run on the localhost. If this is not
455       the model you want to use then please make the appropriate configuration changes before launching
456       the docker containers.
457
458 1. Start by installing docker compose
459
460 .. code:: bash
461
462    $ sudo curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/bin/docker-compose
463
464 .. note::
465   Use the latest Compose release number in the download command. The above command is an example,
466   and it may become out-of-date. To ensure you have the latest version, check the Compose repository
467   release page on GitHub.
468
469 2. Apply executable permissions to the binary:
470
471 .. code:: bash
472
473    $ sudo chmod +x /usr/bin/docker-compose
474
475 3. Test the installation.
476
477 .. code:: bash
478
479   $ sudo docker-compose --version
480
481 Run the InfluxDB and Grafana containers using docker compose
482 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
483
484 Launch containers:
485
486 .. code:: bash
487
488    $ cd barometer/docker/compose/influxdb-grafana/
489    $ sudo docker-compose up -d
490
491 Check your docker images are running
492
493 .. code:: bash
494
495    $ sudo docker ps
496
497 Connect to <host_ip>:3000 with a browser and log into grafana: admin/admin
498
499 Run the Kafka, zookeeper and VES containers using docker compose
500 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
501
502 Launch containers:
503
504 .. code:: bash
505
506    $ cd barometer/docker/compose/ves/
507    $ sudo docker-compose up -d
508
509 Check your docker images are running
510
511 .. code:: bash
512
513    $ sudo docker ps
514
515 Testing the docker image
516 ^^^^^^^^^^^^^^^^^^^^^^^^
517 TODO
518
519 References
520 ^^^^^^^^^^^
521 .. [1] https://docs.docker.com/engine/admin/systemd/#httphttps-proxy
522 .. [2] https://docs.docker.com/engine/installation/linux/docker-ce/centos/#install-using-the-repository
523 .. [3] https://docs.docker.com/engine/userguide/
524