Fix the Makefile for intel-cmt-cat so it can be build without errors on
[barometer.git] / docs / release / userguide / installguide.docker.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 .. _barometer-docker-userguide:
5
6 ====================================
7 OPNFV Barometer Docker Install Guide
8 ====================================
9
10 .. contents::
11    :depth: 3
12    :local:
13
14 The intention of this user guide is to outline how to install and test the Barometer project's
15 docker images. The `OPNFV docker hub <https://hub.docker.com/u/opnfv/?page=1>`_ contains 5 docker
16 images from the Barometer project:
17
18  1. `Collectd docker image <https://hub.docker.com/r/opnfv/barometer-collectd/>`_
19  2. `Influxdb docker image <https://hub.docker.com/r/opnfv/barometer-influxdb/>`_
20  3. `Grafana docker image <https://hub.docker.com/r/opnfv/barometer-grafana/>`_
21  4. `Kafka docker image <https://hub.docker.com/r/opnfv/barometer-kafka/>`_
22  5. `VES application docker image <https://hub.docker.com/r/opnfv/barometer-ves/>`_
23
24 For description of images please see section `Barometer Docker Images Description`_
25
26 For steps to build and run Collectd image please see section `Build and Run Collectd Docker Image`_
27
28 For steps to build and run InfluxDB and Grafana images please see section `Build and Run InfluxDB and Grafana Docker Images`_
29
30 For steps to build and run VES and Kafka images please see section `Build and Run VES and Kafka Docker Images`_
31
32 For overview of running VES application with Kafka please see the :ref:`VES Application User Guide <barometer-ves-userguide>`
33
34 For an alternative installation method using ansible, please see the :ref:`Barometer One Click Install Guide <barometer-oneclick-userguide>`. 
35
36 Barometer Docker Images Description
37 -----------------------------------
38
39 .. Describe the specific features and how it is realised in the scenario in a brief manner
40 .. to ensure the user understand the context for the user guide instructions to follow.
41
42 Barometer Collectd Image
43 ^^^^^^^^^^^^^^^^^^^^^^^^
44 The barometer collectd docker image gives you a collectd installation that includes all
45 the barometer plugins.
46
47 .. note::
48    The Dockerfile is available in the docker/barometer-collectd directory in the barometer repo.
49    The Dockerfile builds a CentOS 7 docker image.
50    The container MUST be run as a privileged container.
51
52 Collectd is a daemon which collects system performance statistics periodically
53 and provides a variety of mechanisms to publish the collected metrics. It
54 supports more than 90 different input and output plugins. Input plugins
55 retrieve metrics and publish them to the collectd deamon, while output plugins
56 publish the data they receive to an end point. Collectd also has infrastructure
57 to support thresholding and notification.
58
59 Collectd docker image has enabled the following collectd plugins (in addition
60 to the standard collectd plugins):
61
62 * hugepages plugin
63 * Open vSwitch events Plugin
64 * Open vSwitch stats Plugin
65 * mcelog plugin
66 * PMU plugin
67 * RDT plugin
68 * virt
69 * SNMP Agent
70 * Kafka_write plugin
71
72 Plugins and third party applications in Barometer repository that will be available in the
73 docker image:
74
75 * Open vSwitch PMD stats
76 * ONAP VES application
77 * gnocchi plugin
78 * aodh plugin
79 * Legacy/IPMI
80
81 InfluxDB + Grafana Docker Images
82 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
83
84 The Barometer project's InfluxDB and Grafana docker images are 2 docker images that database and graph
85 statistics reported by the Barometer collectd docker. InfluxDB is an open-source time series database
86 tool which stores the data from collectd for future analysis via Grafana, which is a open-source
87 metrics anlytics and visualisation suite which can be accessed through any browser.
88
89 VES + Kafka Docker Images
90 ^^^^^^^^^^^^^^^^^^^^^^^^^
91
92 The Barometer project's VES application and Kafka docker images are based on a CentOS 7 image. Kafka
93 docker image has a dependancy on `Zookeeper <https://zookeeper.apache.org/>`_. Kafka must be able to
94 connect and register with an instance of Zookeeper that is either running on local or remote host.
95 Kafka recieves and stores metrics recieved from Collectd. VES application pulls latest metrics from Kafka
96 which it normalizes into VES format for sending to a VES collector. Please see details in 
97 :ref:`VES Application User Guide <barometer-ves-userguide>`
98
99 Installing Docker
100 -----------------
101 .. Describe the specific capabilities and usage for <XYZ> feature.
102 .. Provide enough information that a user will be able to operate the feature on a deployed scenario.
103
104 .. note::
105    The below sections provide steps for manual installation and configuration
106    of docker images. They are not neccessary if docker images were installed with
107    use of Ansible-Playbook.
108
109 On Ubuntu
110 ^^^^^^^^^
111 .. note::
112    * sudo permissions are required to install docker.
113    * These instructions are for Ubuntu 16.10
114
115 To install docker:
116
117 .. code:: bash
118
119     $ sudo apt-get install curl
120     $ sudo curl -fsSL https://get.docker.com/ | sh
121     $ sudo usermod -aG docker <username>
122     $ sudo systemctl status docker
123
124 Replace <username> above with an appropriate user name.
125
126 On CentOS
127 ^^^^^^^^^^
128 .. note::
129    * sudo permissions are required to install docker.
130    * These instructions are for CentOS 7
131
132 To install docker:
133
134 .. code:: bash
135
136     $ sudo yum remove docker docker-common docker-selinux docker-engine
137     $ sudo yum install -y yum-utils  device-mapper-persistent-data  lvm2
138     $ sudo yum-config-manager   --add-repo    https://download.docker.com/linux/centos/docker-ce.repo
139     $ sudo yum-config-manager --enable docker-ce-edge
140     $ sudo yum-config-manager --enable docker-ce-test
141     $ sudo yum install docker-ce
142     $ sudo usermod -aG docker <username>
143     $ sudo systemctl status docker
144
145 Replace <username> above with an appropriate user name.
146
147 .. note::
148    If this is the first time you are installing a package from a recently added
149    repository, you will be prompted to accept the GPG key, and the key’s
150    fingerprint will be shown. Verify that the fingerprint is correct, and if so,
151    accept the key. The fingerprint should match060A 61C5 1B55 8A7F 742B 77AA C52F
152    EB6B 621E 9F35.
153
154         Retrieving key from https://download.docker.com/linux/centos/gpg
155         Importing GPG key 0x621E9F35:
156          Userid     : "Docker Release (CE rpm) <docker@docker.com>"
157          Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
158          From       : https://download.docker.com/linux/centos/gpg
159         Is this ok [y/N]: y
160
161 Manual proxy configuration for docker
162 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
163
164 .. note::
165    This applies for both CentOS and Ubuntu.
166
167 If you are behind an HTTP or HTTPS proxy server, you will need to add this
168 configuration in the Docker systemd service file.
169
170 1. Create a systemd drop-in directory for the docker service:
171
172 .. code:: bash
173
174    $ sudo mkdir -p /etc/systemd/system/docker.service.d
175
176 2. Create a file
177 called /etc/systemd/system/docker.service.d/http-proxy.conf that adds
178 the HTTP_PROXY environment variable:
179
180 .. code:: bash
181
182    [Service]
183    Environment="HTTP_PROXY=http://proxy.example.com:80/"
184
185 Or, if you are behind an HTTPS proxy server, create a file
186 called /etc/systemd/system/docker.service.d/https-proxy.conf that adds
187 the HTTPS_PROXY environment variable:
188
189 .. code:: bash
190
191     [Service]
192     Environment="HTTPS_PROXY=https://proxy.example.com:443/"
193
194 Or create a single file with all the proxy configurations:
195 /etc/systemd/system/docker.service.d/proxy.conf
196
197 .. code:: bash
198
199     [Service]
200     Environment="HTTP_PROXY=http://proxy.example.com:80/"
201     Environment="HTTPS_PROXY=https://proxy.example.com:443/"
202     Environment="FTP_PROXY=ftp://proxy.example.com:443/"
203     Environment="NO_PROXY=localhost"
204
205 3. Flush changes:
206
207 .. code:: bash
208
209     $ sudo systemctl daemon-reload
210
211 4. Restart Docker:
212
213 .. code:: bash
214
215     $ sudo systemctl restart docker
216
217 5. Check docker environment variables:
218
219 .. code:: bash
220
221     sudo systemctl show --property=Environment docker
222
223 Test docker installation
224 ^^^^^^^^^^^^^^^^^^^^^^^^
225 .. note::
226    This applies for both CentOS and Ubuntu.
227
228 .. code:: bash
229
230    $ sudo docker run hello-world
231
232 The output should be something like:
233
234 .. code:: bash
235
236    Unable to find image 'hello-world:latest' locally
237    latest: Pulling from library/hello-world
238    5b0f327be733: Pull complete
239    Digest: sha256:07d5f7800dfe37b8c2196c7b1c524c33808ce2e0f74e7aa00e603295ca9a0972
240    Status: Downloaded newer image for hello-world:latest
241
242    Hello from Docker!
243    This message shows that your installation appears to be working correctly.
244
245    To generate this message, Docker took the following steps:
246     1. The Docker client contacted the Docker daemon.
247     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
248     3. The Docker daemon created a new container from that image which runs the
249        executable that produces the output you are currently reading.
250     4. The Docker daemon streamed that output to the Docker client, which sent it
251        to your terminal.
252
253 To try something more ambitious, you can run an Ubuntu container with:
254
255 .. code:: bash
256
257     $ docker run -it ubuntu bash
258
259 Build and Run Collectd Docker Image
260 -----------------------------------
261
262 Collectd-barometer flavors
263 ^^^^^^^^^^^^^^^^^^^^^^^^^^
264
265 Before starting to build and run the Collectd container, understand the available
266 flavors of Collectd containers:
267   * barometer-collectd - stable release, based on collectd 5.8
268   * barometer-collectd-master - release based on collectd 'master' branch
269   * barometer-collectd-experimental - release based on collectd 'master'
270     branch that also includes set of experimental(not yet merged into upstream)
271     pull requests
272
273 .. note::
274    Experimental container is not tested across various OS'es and the stability
275    of the container can change. Usage of experimental flavor is at users risk.
276
277 Stable barometer-collectd container is intended for work in production
278 environment as it is based on latest collectd official release.
279 `Barometer-collectd-master` and `barometer-collectd-experimental` containers
280 can be used in order to try new collectd features.
281 All flavors are located in `barometer` git repository - respective dockerfiles
282 are stored in subdirectories of 'docker/' directory
283
284
285 .. code:: bash
286
287     $ git clone https://gerrit.opnfv.org/gerrit/barometer
288     $ ls barometer/docker|grep collectd
289     barometer-collectd
290     barometer-collectd-master
291     barometer-collectd-experimental
292
293 .. note::
294    Main directory of barometer source code (directory that contains 'docker',
295    'docs', 'src' and systems sub-directories) will be referred as
296    ``<BAROMETER_REPO_DIR>``
297
298 Download the collectd docker image
299 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
300 If you wish to use a pre-built barometer image, you can pull the barometer
301 image from https://hub.docker.com/r/opnfv/barometer-collectd/
302
303 .. code:: bash
304
305     $ docker pull opnfv/barometer-collectd
306
307 Build stable collectd container
308 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
309
310 .. code:: bash
311
312     $ cd <BAROMETER_REPO_DIR>/docker/barometer-collectd
313     $ sudo docker build -t opnfv/barometer-collectd --build-arg http_proxy=`echo $http_proxy` \
314       --build-arg https_proxy=`echo $https_proxy` --network=host -f Dockerfile .
315
316 .. note::
317    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs to be
318    passed only if system is behind an HTTP or HTTPS proxy server.
319
320 Check the docker images:
321
322 .. code:: bash
323
324    $ sudo docker images
325
326 Output should contain a barometer-collectd image:
327
328 .. code::
329
330    REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
331    opnfv/barometer-collectd     latest              05f2a3edd96b        3 hours ago         1.2GB
332    centos                       7                   196e0ce0c9fb        4 weeks ago         197MB
333    centos                       latest              196e0ce0c9fb        4 weeks ago         197MB
334    hello-world                  latest              05a3bd381fc2        4 weeks ago         1.84kB
335
336 .. note::
337    If you do not plan to use collectd-master and collectd-experimental barometer
338    containers, then you can proceed directly to section `Run the collectd stable docker image`_
339
340
341 Build collectd-master container
342 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
343
344 .. code:: bash
345
346     $ cd <BAROMETER_REPO_DIR>
347     $ sudo docker build -t opnfv/barometer-collectd-master \
348      --build-arg http_proxy=`echo $http_proxy` \
349      --build-arg https_proxy=`echo $https_proxy` --network=host -f \
350      docker/barometer-collectd-master/Dockerfile .
351
352 .. note::
353    For `barometer-collectd-master` and `barometer-collectd-experimental` containers
354    proxy parameters should be passed only if system is behind an HTTP or HTTPS
355    proxy server (same as for stable collectd container)
356
357 Build collectd-experimental container
358 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
359
360 .. code:: bash
361
362     $ cd <BAROMETER_REPO_DIR>
363     $ sudo docker build -t opnfv/barometer-collectd-experimental \
364      --build-arg http_proxy=`echo $http_proxy` \
365      --build-arg https_proxy=`echo $https_proxy` \
366      --network=host -f docker/barometer-collectd-experimental/Dockerfile .
367
368 .. note::
369    For `barometer-collectd-master` and `barometer-collectd-experimental` containers
370    proxy parameters should be passed only if system is behind an HTTP or HTTPS
371    proxy server (same as for stable collectd container)
372
373 Run the collectd stable docker image
374 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
375 .. code:: bash
376
377    $ cd <BAROMETER_REPO_DIR>
378    $ sudo docker run -ti --net=host -v \
379    `pwd`/src/collectd/collectd_sample_configs:/opt/collectd/etc/collectd.conf.d \
380    -v /var/run:/var/run -v /tmp:/tmp -v /sys/fs/resctrl:/sys/fs/resctrl \
381    --privileged opnfv/barometer-collectd
382
383 .. note::
384    The docker collectd image contains configuration for all the collectd
385    plugins. In the command above we are overriding
386    /opt/collectd/etc/collectd.conf.d by mounting a host directory
387    src/collectd/collectd_sample_configs that contains only the sample
388    configurations we are interested in running.
389
390    *If some dependencies for plugins listed in configuration directory
391    aren't met, then collectd startup may fail(collectd tries to
392    initialize plugins configurations for all given config files that can
393    be found in shared configs directory and may fail if some dependency
394    is missing).*
395
396    If `DPDK` or `RDT` can't be installed on host, then corresponding config
397    files should be removed from shared configuration directory
398    (`<BAROMETER_REPO_DIR>/src/collectd/collectd_sample_configs/`) prior
399    to starting barometer-collectd container. By example: in case of missing
400    `DPDK` functionality on the host, `dpdkstat.conf` and `dpdkevents.conf`
401    should be removed.
402
403    Sample configurations can be found at:
404    https://github.com/opnfv/barometer/tree/master/src/collectd/collectd_sample_configs
405
406    List of barometer-collectd dependencies on host for various plugins
407    can be found at:
408    https://wiki.opnfv.org/display/fastpath/Barometer-collectd+host+dependencies
409
410    The Resource Control file system (/sys/fs/resctrl) can be bound from host to
411    container only if this directory exists on the host system. Otherwise omit
412    the '-v /sys/fs/resctrl:/sys/fs/resctrl' part in docker run command.
413    More information about resctrl can be found at:
414    https://github.com/intel/intel-cmt-cat/wiki/resctrl
415
416 Check your docker image is running
417
418 .. code:: bash
419
420    sudo docker ps
421
422 To make some changes when the container is running run:
423
424 .. code:: bash
425
426    sudo docker exec -ti <CONTAINER ID> /bin/bash
427
428 Run the barometer-collectd-master docker image
429 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
430 Run command for `barometer-collectd-master` container is very similar to command
431 used for stable container - the only differences are name of the image
432 and location of the sample configuration files(as different version of collectd
433 plugins requiring different configuration files)
434
435
436 .. code:: bash
437
438    $ cd <BAROMETER_REPO_DIR>
439    $ sudo docker run -ti --net=host -v \
440    `pwd`/src/collectd/collectd_sample_configs-master:/opt/collectd/etc/collectd.conf.d \
441    -v /var/run:/var/run -v /tmp:/tmp -v /sys/fs/resctrl:/sys/fs/resctrl \
442    --privileged opnfv/barometer-collectd-master
443
444 .. note::
445    Barometer collectd docker images are sharing some directories with host
446    (e.g. /tmp) therefore only one of collectd barometer flavors can be run
447    at a time. In other words, if you want to try `barometer-collectd-master` or
448    `barometer-collectd-experimental` image, please stop instance of
449    `barometer-collectd(stable)` image first.
450
451    The Resource Control file system (/sys/fs/resctrl) can be bound from host to
452    container only if this directory exists on the host system. Otherwise omit
453    the '-v /sys/fs/resctrl:/sys/fs/resctrl' part in docker run command.
454    More information about resctrl can be found at:
455    https://github.com/intel/intel-cmt-cat/wiki/resctrl
456
457 Run the barometer-collectd-experimental docker image
458 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
459 Barometer-collectd-experimental container shares default configuration files
460 with 'barometer-collectd-master' equivalent but some of experimental pull
461 requests may require modified configuration. Additional configuration files that
462 are required specifically by experimental container can be found in
463 `docker/barometer-collectd-experimental/experimental-configs/`
464 directory. Content of this directory (all \*.conf files) should be copied to
465 `src/collectd/collectd_sample_configs-master` directory before first run of
466 experimental container.
467
468 .. code:: bash
469
470    $ cd <BAROMETER_REPO_DIR>
471    $ cp docker/barometer-collectd-experimental/experimental-configs/*.conf \
472      src/collectd/collectd_sample_configs-master
473
474 When configuration files are up to date for experimental container, it can be
475 launched using following command (almost identical to run-command for 'master'
476 collectd container)
477
478 .. code:: bash
479
480    $ cd <BAROMETER_REPO_DIR>
481    $ sudo docker run -ti --net=host -v \
482    `pwd`/src/collectd/collectd_sample_configs-master:/opt/collectd/etc/collectd.conf.d \
483    -v /var/run:/var/run -v /tmp:/tmp -v /sys/fs/resctrl:/sys/fs/resctrl --privileged \
484    opnfv/barometer-collectd-experimental
485
486 .. note::
487    The Resource Control file system (/sys/fs/resctrl) can be bound from host to
488    container only if this directory exists on the host system. Otherwise omit
489    the '-v /sys/fs/resctrl:/sys/fs/resctrl' part in docker run command.
490    More information about resctrl can be found at:
491    https://github.com/intel/intel-cmt-cat/wiki/resctrl
492
493
494 Build and Run InfluxDB and Grafana docker images
495 ------------------------------------------------
496
497 Overview
498 ^^^^^^^^
499 The barometer-influxdb image is based on the influxdb:1.3.7 image from the influxdb dockerhub. To
500 view detils on the base image please visit
501 `https://hub.docker.com/_/influxdb/  <https://hub.docker.com/_/influxdb/>`_ Page includes details of
502 exposed ports and configurable enviromental variables of the base image.
503
504 The barometer-grafana image is based on grafana:4.6.3 image from the grafana dockerhub. To view
505 details on the base image please visit
506 `https://hub.docker.com/r/grafana/grafana/ <https://hub.docker.com/r/grafana/grafana/>`_ Page
507 includes details on exposed ports and configurable enviromental variables of the base image.
508
509 The barometer-grafana image includes pre-configured source and dashboards to display statistics exposed
510 by the barometer-collectd image. The default datasource is an influxdb database running on localhost
511 but the address of the influxdb server can be modified when launching the image by setting the
512 environmental variables influxdb_host to IP or hostname of host on which influxdb server is running.
513
514 Additional dashboards can be added to barometer-grafana by mapping a volume to /opt/grafana/dashboards.
515 Incase where a folder is mounted to this volume only files included in this folder will be visible
516 inside barometer-grafana. To ensure all default files are also loaded please ensure they are included in
517 volume folder been mounted. Appropriate example are given in section `Run the Grafana docker image`_
518
519 Download the InfluxDB and Grafana docker images
520 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
521 If you wish to use pre-built barometer project's influxdb and grafana images, you can pull the
522 images from https://hub.docker.com/r/opnfv/barometer-influxdb/ and https://hub.docker.com/r/opnfv/barometer-grafana/
523
524 .. note::
525    If your preference is to build images locally please see sections `Build InfluxDB Docker Image`_ and
526    `Build Grafana Docker Image`_
527
528 .. code:: bash
529
530     $ docker pull opnfv/barometer-influxdb
531     $ docker pull opnfv/barometer-grafana
532
533 .. note::
534    If you have pulled the pre-built barometer-influxdb and barometer-grafana images there is no
535    requirement to complete steps outlined in  sections `Build InfluxDB Docker Image`_ and
536    `Build Grafana Docker Image`_ and you can proceed directly to section
537    `Run the Influxdb and Grafana Images`_
538
539 Build InfluxDB docker image
540 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
541
542 Build influxdb image from Dockerfile
543
544 .. code:: bash
545
546   $ cd barometer/docker/barometer-influxdb
547   $ sudo docker build -t opnfv/barometer-influxdb --build-arg http_proxy=`echo $http_proxy` \
548     --build-arg https_proxy=`echo $https_proxy` --network=host -f Dockerfile .
549
550 .. note::
551    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs to
552    be passed only if system is behind an HTTP or HTTPS proxy server.
553
554 Check the docker images:
555
556 .. code:: bash
557
558    $ sudo docker images
559
560 Output should contain an influxdb image:
561
562 .. code::
563
564    REPOSITORY                   TAG                 IMAGE ID            CREATED            SIZE
565    opnfv/barometer-influxdb     latest              1e4623a59fe5        3 days ago         191MB
566
567 Build Grafana docker image
568 ^^^^^^^^^^^^^^^^^^^^^^^^^^
569
570 Build Grafana image from Dockerfile
571
572 .. code:: bash
573
574   $ cd barometer/docker/barometer-grafana
575   $ sudo docker build -t opnfv/barometer-grafana --build-arg http_proxy=`echo $http_proxy` \
576     --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
577
578 .. note::
579    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs to
580    be passed only if system is behind an HTTP or HTTPS proxy server.
581
582 Check the docker images:
583
584 .. code:: bash
585
586    $ sudo docker images
587
588 Output should contain an influxdb image:
589
590 .. code::
591
592    REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
593    opnfv/barometer-grafana      latest              05f2a3edd96b        3 hours ago         1.2GB
594
595 Run the Influxdb and Grafana Images
596 -----------------------------------
597
598 Run the InfluxDB docker image
599 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
600 .. code:: bash
601
602    $ sudo docker run -tid -v /var/lib/influxdb:/var/lib/influxdb --net=host\
603     --name bar-influxdb opnfv/barometer-influxdb
604
605 Check your docker image is running
606
607 .. code:: bash
608
609    sudo docker ps
610
611 To make some changes when the container is running run:
612
613 .. code:: bash
614
615    sudo docker exec -ti <CONTAINER ID> /bin/bash
616
617 When both collectd and InfluxDB containers are located
618 on the same host, then no additional configuration have to be added and you
619 can proceed directly to `Run the Grafana docker image`_ section.
620
621 Modify collectd to support InfluxDB on another host
622 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
623 If InfluxDB and collectd containers are located on separate hosts, then
624 additional configuration have to be done in ``collectd`` container - it
625 normally sends data using network plugin to 'localhost/127.0.0.1' therefore
626 changing output location is required:
627
628 1. Stop and remove running bar-collectd container (if it is running)
629
630    .. code:: bash
631
632       $ sudo docker ps #to get collectd container name
633       $ sudo docker rm -f <COLLECTD_CONTAINER_NAME>
634
635 2. Go to location where shared collectd config files are stored
636
637    .. code:: bash
638
639       $ cd <BAROMETER_REPO_DIR>
640       $ cd src/collectd/collectd_sample_configs
641
642 3. Edit content of ``network.conf`` file.
643    By default this file looks like that:
644
645    .. code::
646
647       LoadPlugin  network
648       <Plugin network>
649       Server "127.0.0.1" "25826"
650       </Plugin>
651
652    ``127.0.0.1`` string has to be replaced with the IP address of host where
653    InfluxDB container is running (e.g. ``192.168.121.111``). Edit this using your
654    favorite text editor.
655
656 4. Start again collectd container like it is described in
657    `Run the collectd stable docker image`_ chapter
658
659    .. code:: bash
660
661       $ cd <BAROMETER_REPO_DIR>
662       $ sudo docker run -ti --name bar-collectd --net=host -v \
663       `pwd`/src/collectd/collectd_sample_configs:/opt/collectd/etc/collectd.conf.d \
664       -v /var/run:/var/run -v /tmp:/tmp --privileged opnfv/barometer-collectd
665
666 Now collectd container will be sending data to InfluxDB container located on
667 remote Host pointed by IP configured in step 3.
668
669 Run the Grafana docker image
670 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
671
672 Connecting to an influxdb instance running on local system and adding own custom dashboards
673
674 .. code:: bash
675
676    $ cd <BAROMETER_REPO_DIR>
677    $ sudo docker run -tid -v /var/lib/grafana:/var/lib/grafana \
678      -v ${PWD}/docker/barometer-grafana/dashboards:/opt/grafana/dashboards \
679      --name bar-grafana --net=host opnfv/barometer-grafana
680
681 Connecting to an influxdb instance running on remote system with hostname of someserver and IP address
682 of 192.168.121.111
683
684 .. code:: bash
685
686    $ sudo docker run -tid -v /var/lib/grafana:/var/lib/grafana --net=host -e \
687      influxdb_host=someserver --add-host someserver:192.168.121.111 --name \
688      bar-grafana opnfv/barometer-grafana
689
690 Check your docker image is running
691
692 .. code:: bash
693
694    sudo docker ps
695
696 To make some changes when the container is running run:
697
698 .. code:: bash
699
700    sudo docker exec -ti <CONTAINER ID> /bin/bash
701
702 Connect to <host_ip>:3000 with a browser and log into grafana: admin/admin
703
704 Cleanup of influxdb/grafana configuration
705 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
706
707 When user wants to remove current grafana and influxdb configuration,
708 folowing actions have to be performed
709
710 1. Stop and remove running influxdb and grafana containers
711
712 .. code:: bash
713
714    sudo docker rm -f bar-grafana bar-influxdb
715
716 2. Remove shared influxdb and grafana folders from the Host
717
718 .. code:: bash
719
720    sudo rm -rf /var/lib/grafana
721    sudo rm -rf /var/lib/influxdb
722
723 .. note::
724    Shared folders are storing configuration of grafana and influxdb
725    containers. In case of changing influxdb or grafana configuration
726    (e.g. moving influxdb to another host) it is good to perform cleanup
727    on shared folders to not affect new setup with an old configuration.
728
729 Build and Run VES and Kafka Docker Images
730 -----------------------------------------
731
732 Download VES and Kafka docker images
733 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
734
735 If you wish to use pre-built barometer project's VES and kafka images, you can pull the
736 images from https://hub.docker.com/r/opnfv/barometer-ves/ and  https://hub.docker.com/r/opnfv/barometer-kafka/
737
738 .. note::
739    If your preference is to build images locally please see sections `Build the Kafka Image`_ and
740    `Build VES Image`_
741
742 .. code:: bash
743
744     $ docker pull opnfv/barometer-kafka
745     $ docker pull opnfv/barometer-ves
746
747 .. note::
748    If you have pulled the pre-built images there is no requirement to complete steps outlined
749    in sections `Build Kafka Docker Image`_ and `Build VES Docker Image`_ and you can proceed directly to section
750    `Run Kafka Docker Image`_
751
752 Build Kafka docker image
753 ^^^^^^^^^^^^^^^^^^^^^^^^
754
755 Build Kafka docker image:
756
757 .. code:: bash
758
759     $ cd barometer/docker/barometer-kafka
760     $ sudo docker build -t opnfv/barometer-kafka --build-arg http_proxy=`echo $http_proxy` \
761       --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
762
763 .. note::
764    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs
765    to be passed only if system is behind an HTTP or HTTPS proxy server.
766
767 Check the docker images:
768
769 .. code:: bash
770
771    $ sudo docker images
772
773 Output should contain a barometer image:
774
775 .. code::
776
777    REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
778    opnfv/barometer-kafka     latest              05f2a3edd96b        3 hours ago         1.2GB
779
780 Build VES docker image
781 ^^^^^^^^^^^^^^^^^^^^^^
782
783 Build VES application docker image:
784
785 .. code:: bash
786
787     $ cd barometer/docker/barometer-ves
788     $ sudo docker build -t opnfv/barometer-ves --build-arg http_proxy=`echo $http_proxy` \
789       --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
790
791 .. note::
792    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs
793    to be passed only if system is behind an HTTP or HTTPS proxy server.
794
795 Check the docker images:
796
797 .. code:: bash
798
799    $ sudo docker images
800
801 Output should contain a barometer image:
802
803 .. code::
804
805    REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
806    opnfv/barometer-ves       latest              05f2a3edd96b        3 hours ago         1.2GB
807
808 Run Kafka docker image
809 ^^^^^^^^^^^^^^^^^^^^^^
810
811 .. note::
812    Before running Kafka an instance of Zookeeper must be running for the Kafka broker to register
813    with. Zookeeper can be running locally or on a remote platform. Kafka's broker_id and address of
814    its zookeeper instance can be configured by setting values for environmental variables 'broker_id'
815    and 'zookeeper_node'. In instance where 'broker_id' and/or 'zookeeper_node' is not set the default
816    setting of broker_id=0 and zookeeper_node=localhost is used. In intance where Zookeeper is running
817    on same node as Kafka and there is a one to one relationship between Zookeeper and Kafka, default
818    setting can be used. The docker argument `add-host` adds hostname and IP address to
819    /etc/hosts file in container
820
821 Run zookeeper docker image:
822
823 .. code:: bash
824
825    $ sudo docker run -tid --net=host -p 2181:2181 zookeeper:3.4.11
826
827 Run kafka docker image which connects with a zookeeper instance running on same node with a 1:1 relationship
828
829 .. code:: bash
830
831    $ sudo docker run -tid --net=host -p 9092:9092 opnfv/barometer-kafka
832
833
834 Run kafka docker image which connects with a zookeeper instance running on a node with IP address of
835 192.168.121.111 using broker ID of 1
836
837 .. code:: bash
838
839    $ sudo docker run -tid --net=host -p 9092:9092 --env broker_id=1 --env zookeeper_node=zookeeper --add-host \
840      zookeeper:192.168.121.111 opnfv/barometer-kafka
841
842 Run VES Application docker image
843 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
844 .. note::
845    VES application uses configuration file ves_app_config.conf from directory
846    barometer/3rd_party/collectd-ves-app/ves_app/config/ and host.yaml file from
847    barometer/3rd_party/collectd-ves-app/ves_app/yaml/ by default. If you wish to use a custom config
848    file it should be mounted to mount point /opt/ves/config/ves_app_config.conf. To use an alternative yaml
849    file from folder barometer/3rd_party/collectd-ves-app/ves_app/yaml the name of the yaml file to use
850    should be passed as an additional command. If you wish to use a custom file the file should be
851    mounted to mount point /opt/ves/yaml/ Please see examples below
852
853 Run VES docker image with default configuration
854
855 .. code:: bash
856
857    $ sudo docker run -tid --net=host opnfv/barometer-ves
858
859 Run VES docker image with guest.yaml files from barometer/3rd_party/collectd-ves-app/ves_app/yaml/
860
861 .. code:: bash
862
863    $ sudo docker run -tid --net=host opnfv/barometer-ves guest.yaml
864
865
866 Run VES docker image with using custom config and yaml files. In example below yaml/ folder cotains
867 file named custom.yaml
868
869 .. code:: bash
870
871    $ sudo docker run -tid --net=host -v ${PWD}/custom.config:/opt/ves/config/ves_app_config.conf \
872      -v ${PWD}/yaml/:/opt/ves/yaml/ opnfv/barometer-ves custom.yaml
873
874 Run VES Test Collector application
875 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
876
877 VES Test Collector application can be used for displaying platform
878 wide metrics that are collected by barometer-ves container.
879 Setup instructions are located in: :ref:`Setup VES Test Collector`
880
881 Build and Run DMA and Redis Docker Images
882 -----------------------------------------
883
884 Download DMA docker images
885 ^^^^^^^^^^^^^^^^^^^^^^^^^^
886
887 If you wish to use pre-built barometer project's DMA images, you can pull the
888 images from https://hub.docker.com/r/opnfv/barometer-dma/
889
890 .. note::
891    If your preference is to build images locally please see sections `Build DMA Docker Image`_
892
893 .. code:: bash
894
895     $ docker pull opnfv/barometer-dma
896
897 .. note::
898    If you have pulled the pre-built images there is no requirement to complete steps outlined
899    in sections `Build DMA Docker Image`_ and you can proceed directly to section
900    `Run DMA Docker Image`_
901
902 Build DMA docker image
903 ^^^^^^^^^^^^^^^^^^^^^^
904
905 Build DMA docker image:
906
907 .. code:: bash
908
909     $ cd barometer/docker/barometer-dma
910     $ sudo docker build -t opnfv/barometer-dma --build-arg http_proxy=`echo $http_proxy` \
911       --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
912
913 .. note::
914    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs
915    to be passed only if system is behind an HTTP or HTTPS proxy server.
916
917 Check the docker images:
918
919 .. code:: bash
920
921    $ sudo docker images
922
923 Output should contain a barometer image:
924
925 .. code::
926
927    REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
928    opnfv/barometer-dma          latest              2f14fbdbd498        3 hours ago         941 MB
929
930 Run Redis docker image
931 ^^^^^^^^^^^^^^^^^^^^^^
932
933 .. note::
934    Before running DMA, Redis must be running.
935
936 Run Redis docker image:
937
938 .. code:: bash
939
940    $ sudo docker run -tid -p 6379:6379 --name barometer-redis redis
941
942 Check your docker image is running
943
944 .. code:: bash
945
946    sudo docker ps
947
948 Run DMA docker image
949 ^^^^^^^^^^^^^^^^^^^^
950 .. note::
951
952 Run DMA docker image with default configuration
953
954 .. code:: bash
955
956    $ cd barometer/docker/barometer-dma
957    $ sudo mkdir /etc/barometer-dma
958    $ sudo cp ../../src/dma/examples/config.toml /etc/barometer-dma/
959    $ sudo vi /etc/barometer-dma/config.toml
960    (edit amqp_password and os_password:OpenStack admin password)
961
962    $ sudo su -
963    (When there is no key for SSH access authentication)
964    # ssh-keygen
965    (Press Enter until done)
966    (Backup if necessary)
967    # cp ~/.ssh/authorized_keys ~/.ssh/authorized_keys_org
968    # cat ~/.ssh/authorized_keys_org ~/.ssh/id_rsa.pub \
969      > ~/.ssh/authorized_keys
970    # exit
971
972    $ sudo docker run -tid --net=host --name server \
973      -v /etc/barometer-dma:/etc/barometer-dma \
974      -v /root/.ssh/id_rsa:/root/.ssh/id_rsa \
975      -v /etc/collectd/collectd.conf.d:/etc/collectd/collectd.conf.d \
976      opnfv/barometer-dma /server
977
978    $ sudo docker run -tid --net=host --name infofetch \
979      -v /etc/barometer-dma:/etc/barometer-dma \
980      -v /var/run/libvirt:/var/run/libvirt \
981      opnfv/barometer-dma /infofetch
982
983    (Execute when installing the threshold evaluation binary)
984    $ sudo docker cp infofetch:/threshold ./
985    $ sudo ln -s ${PWD}/threshold /usr/local/bin/
986
987 References
988 ^^^^^^^^^^
989 .. [1] https://docs.docker.com/engine/admin/systemd/#httphttps-proxy
990 .. [2] https://docs.docker.com/engine/installation/linux/docker-ce/centos/#install-using-the-repository
991 .. [3] https://docs.docker.com/engine/userguide/
992
993