20836af704dea89911ae16dc96d5167c915a66ac
[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) Anuket and others
4 .. _barometer-docker-userguide:
5
6 =====================================
7 Anuket 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 8 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 .. ::
157          Userid     : "Docker Release (CE rpm) <docker@docker.com>"
158          Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
159          From       : https://download.docker.com/linux/centos/gpg
160         Is this ok [y/N]: y
161
162 Manual proxy configuration for docker
163 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
164
165 .. note::
166    This applies for both CentOS and Ubuntu.
167
168 If you are behind an HTTP or HTTPS proxy server, you will need to add this
169 configuration in the Docker systemd service file.
170
171 1. Create a systemd drop-in directory for the docker service:
172
173 .. code:: bash
174
175    $ sudo mkdir -p /etc/systemd/system/docker.service.d
176
177 2. Create a file
178 called /etc/systemd/system/docker.service.d/http-proxy.conf that adds
179 the HTTP_PROXY environment variable:
180
181 .. code:: bash
182
183    [Service]
184    Environment="HTTP_PROXY=http://proxy.example.com:80/"
185
186 Or, if you are behind an HTTPS proxy server, create a file
187 called /etc/systemd/system/docker.service.d/https-proxy.conf that adds
188 the HTTPS_PROXY environment variable:
189
190 .. code:: bash
191
192     [Service]
193     Environment="HTTPS_PROXY=https://proxy.example.com:443/"
194
195 Or create a single file with all the proxy configurations:
196 /etc/systemd/system/docker.service.d/proxy.conf
197
198 .. code:: bash
199
200     [Service]
201     Environment="HTTP_PROXY=http://proxy.example.com:80/"
202     Environment="HTTPS_PROXY=https://proxy.example.com:443/"
203     Environment="FTP_PROXY=ftp://proxy.example.com:443/"
204     Environment="NO_PROXY=localhost"
205
206 3. Flush changes:
207
208 .. code:: bash
209
210     $ sudo systemctl daemon-reload
211
212 4. Restart Docker:
213
214 .. code:: bash
215
216     $ sudo systemctl restart docker
217
218 5. Check docker environment variables:
219
220 .. code:: bash
221
222     sudo systemctl show --property=Environment docker
223
224 Test docker installation
225 ^^^^^^^^^^^^^^^^^^^^^^^^
226 .. note::
227    This applies for both CentOS and Ubuntu.
228
229 .. code:: bash
230
231    $ sudo docker run hello-world
232
233 The output should be something like:
234
235 .. code:: bash
236
237    Trying to pull docker.io/library/hello-world...Getting image source signatures
238    Copying blob 0e03bdcc26d7 done
239    Copying config bf756fb1ae done
240    Writing manifest to image destination
241    Storing signatures
242
243    Hello from Docker!
244    This message shows that your installation appears to be working correctly.
245
246    To generate this message, Docker took the following steps:
247     1. The Docker client contacted the Docker daemon.
248     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
249     3. The Docker daemon created a new container from that image which runs the
250        executable that produces the output you are currently reading.
251     4. The Docker daemon streamed that output to the Docker client, which sent it
252        to your terminal.
253
254    To try something more ambitious, you can run an Ubuntu container with:
255     $ docker run -it ubuntu bash
256
257    Share images, automate workflows, and more with a free Docker ID:
258     https://hub.docker.com/
259
260    For more examples and ideas, visit:
261     https://docs.docker.com/get-started/
262
263 Build and Run Collectd Docker Image
264 -----------------------------------
265
266 Collectd-barometer flavors
267 ^^^^^^^^^^^^^^^^^^^^^^^^^^
268
269 Before starting to build and run the Collectd container, understand the available
270 flavors of Collectd containers:
271
272 * barometer-collectd - stable release, based on collectd 5.12
273 * barometer-collectd-latest - release based on collectd 'main' branch
274 * barometer-collectd-experimental - release based on collectd 'main'
275   branch that can also include a set of experimental (not yet merged into
276   upstream) pull requests
277
278 .. note::
279    Experimental container is not tested across various OS'es and the stability
280    of the container can change. Usage of experimental flavor is at users risk.
281
282 Stable `barometer-collectd` container is intended for work in production
283 environment as it is based on latest collectd official release.
284 `barometer-collectd-latest` and `barometer-collectd-experimental` containers
285 can be used in order to try new collectd features.
286 All flavors are located in `barometer` git repository - respective Dockerfiles
287 are stored in subdirectories of `docker/` directory
288
289
290 .. code:: bash
291
292     $ git clone https://gerrit.opnfv.org/gerrit/barometer
293     $ ls barometer/docker|grep collectd
294     barometer-collectd
295     barometer-collectd-latest
296     barometer-collectd-experimental
297
298 .. note::
299    Main directory of barometer source code (directory that contains 'docker',
300    'docs', 'src' and systems sub-directories) will be referred as
301    ``<BAROMETER_REPO_DIR>``
302
303 Download the collectd docker image
304 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
305 If you wish to use a pre-built barometer image, you can pull the barometer
306 image from `dockerhub <https://hub.docker.com/r/opnfv/barometer-collectd/>`_
307
308 .. code:: bash
309
310     $ docker pull opnfv/barometer-collectd
311
312 Build stable collectd container
313 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
314
315 .. code:: bash
316
317     $ cd <BAROMETER_REPO_DIR>/docker/barometer-collectd
318     $ sudo docker build -t opnfv/barometer-collectd --build-arg http_proxy=`echo $http_proxy` \
319       --build-arg https_proxy=`echo $https_proxy` --network=host -f Dockerfile .
320
321 .. note::
322    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs to be
323    passed only if system is behind an HTTP or HTTPS proxy server.
324
325 Check the docker images:
326
327 .. code:: bash
328
329    $ sudo docker images
330
331 Output should contain a barometer-collectd image:
332
333 .. code::
334
335    REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
336    opnfv/barometer-collectd     latest              05f2a3edd96b        3 hours ago         1.2GB
337    centos                       7                   196e0ce0c9fb        4 weeks ago         197MB
338    centos                       latest              196e0ce0c9fb        4 weeks ago         197MB
339    hello-world                  latest              05a3bd381fc2        4 weeks ago         1.84kB
340
341 .. note::
342    If you do not plan to use `barometer-collectd-latest` and
343    `barometer-collectd-experimental` containers, then you can proceed directly
344    to section `Run the collectd stable docker image`_
345
346
347 Build barometer-collectd-latest container
348 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
349
350 .. code:: bash
351
352     $ cd <BAROMETER_REPO_DIR>
353     $ sudo docker build -t opnfv/barometer-collectd-latest \
354      --build-arg http_proxy=`echo $http_proxy` \
355      --build-arg https_proxy=`echo $https_proxy` --network=host -f \
356      docker/barometer-collectd-latest/Dockerfile .
357
358 .. note::
359    For `barometer-collectd-latest` and `barometer-collectd-experimental` containers
360    proxy parameters should be passed only if system is behind an HTTP or HTTPS
361    proxy server (same as for stable collectd container)
362
363 Build barometer-collectd-experimental container
364 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
365
366 The barometer-collectd-experimental container use the ``main`` branch of
367 collectd, but allows the user to apply a number of pull requests, which are
368 passed via the COLLECTD_PULL_REQUESTS build arg, which is passed to docker as
369 shown in the example below.
370 COLLECTD_PULL_REQUESTS should be a comma-delimited string of pull request IDs.
371
372 .. code:: bash
373
374     $ cd <BAROMETER_REPO_DIR>
375     $ sudo docker build -t opnfv/barometer-collectd-experimental \
376      --build-arg http_proxy=`echo $http_proxy` \
377      --build-arg https_proxy=`echo $https_proxy` \
378      --build-arg COLLECTD_PULL_REQUESTS=1234,5678 \
379      --network=host -f docker/barometer-collectd-experimental/Dockerfile .
380
381 .. note::
382    For `barometer-collectd-latest` and `barometer-collectd-experimental` containers
383    proxy parameters should be passed only if system is behind an HTTP or HTTPS
384    proxy server (same as for stable collectd container)
385
386 Build collectd-6
387 ^^^^^^^^^^^^^^^^
388
389 The barometer-collectd-experimental Dockerfile can be used to build
390 collectd-6.0, which is currently under development. In order to do this, the
391 ``COLLECTD_FLAVOR`` build arg can be passed to the docker build command.
392 The optional ``COLLECTD_PULL_REQUESTS`` arg can be passed as well, to test
393 proposed patches to collectd.
394
395 .. code:: bash
396
397    $ cd <BAROMETER_REPO_DIR>
398    $ sudo docker build -t opnfv/barometer-collectd-6 \
399      --build-arg COLLECTD_FLAVOR=collectd-6 \
400      --build-arg COLLECTD_PULL_REQUESTS=1234,5678 \
401      --network=host -f docker/barometer-collectd-experimental/Dockerfile .
402
403 The instructions for running the collectd-6 container are the same as for the
404 collectd-experimental container.
405
406 There are a few useful build args that can be used to further customise the
407 collectd-6 build:
408
409 * **COLLECTD_CONFIG_CMD_ARGS**
410   For testing with new plugins for collectd-6, as un-ported plugins are
411   disabled by default.
412   This new option lets the ./configure command be run with extra args,
413   e.g. --enable-cpu --enable-<my-newly-ported-plugin>, which means that
414   plugin can be enabled for the PR that is being tested.
415
416 * **COLLECTD_TAG**
417   This overrides the default tag selected by the flavors, and allows checking
418   out out an arbitrary branch (e.g. PR branch instead of using the
419   ``COLLECTD_PULL_REQUESTS`` arg, which rebases each PR on top of the
420   nominal branch.
421   To check out a PR, use the following args with the docker build command:
422   ``--build-arg COLLECTD_TAG=pull/<PR_ID>/head``
423
424 Run the collectd stable docker image
425 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
426 .. code:: bash
427
428    $ cd <BAROMETER_REPO_DIR>
429    $ sudo docker run -ti --net=host -v \
430    `pwd`/src/collectd/collectd_sample_configs:/opt/collectd/etc/collectd.conf.d \
431    -v /var/run:/var/run -v /tmp:/tmp -v /sys/fs/resctrl:/sys/fs/resctrl \
432    --privileged opnfv/barometer-collectd
433
434 .. note::
435    The docker collectd image contains configuration for all the collectd
436    plugins. In the command above we are overriding
437    /opt/collectd/etc/collectd.conf.d by mounting a host directory
438    src/collectd/collectd_sample_configs that contains only the sample
439    configurations we are interested in running.
440
441    *If some dependencies for plugins listed in configuration directory
442    aren't met, then collectd startup may fail(collectd tries to
443    initialize plugins configurations for all given config files that can
444    be found in shared configs directory and may fail if some dependency
445    is missing).*
446
447    If `DPDK` or `RDT` can't be installed on host, then corresponding config
448    files should be removed from shared configuration directory
449    (`<BAROMETER_REPO_DIR>/src/collectd/collectd_sample_configs/`) prior
450    to starting barometer-collectd container. By example: in case of missing
451    `DPDK` functionality on the host, `dpdkstat.conf` and `dpdkevents.conf`
452    should be removed.
453
454    Sample configurations can be found at:
455    https://github.com/opnfv/barometer/tree/master/src/collectd/collectd_sample_configs
456
457    List of barometer-collectd dependencies on host for various plugins
458    can be found at:
459    https://wiki.anuket.io/display/HOME/Barometer-collectd+host+dependencies
460
461    The Resource Control file system (/sys/fs/resctrl) can be bound from host to
462    container only if this directory exists on the host system. Otherwise omit
463    the '-v /sys/fs/resctrl:/sys/fs/resctrl' part in docker run command.
464    More information about resctrl can be found at:
465    https://github.com/intel/intel-cmt-cat/wiki/resctrl
466
467 Check your docker image is running
468
469 .. code:: bash
470
471    sudo docker ps
472
473 To make some changes when the container is running run:
474
475 .. code:: bash
476
477    sudo docker exec -ti <CONTAINER ID> /bin/bash
478
479 Run the barometer-collectd-latest docker image
480 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
481 Run command for ``barometer-collectd-latest`` container is very similar to
482 command used for stable container - the only differences are name of the image
483 and location of the sample configuration files (as different version of
484 collectd plugins requiring different configuration files)
485
486
487 .. code:: bash
488
489    $ cd <BAROMETER_REPO_DIR>
490    $ sudo docker run -ti --net=host -v \
491    `pwd`/src/collectd/collectd_sample_configs-latest:/opt/collectd/etc/collectd.conf.d \
492    -v /var/run:/var/run -v /tmp:/tmp -v /sys/fs/resctrl:/sys/fs/resctrl \
493    --privileged opnfv/barometer-collectd-latest
494
495 .. note::
496    Barometer collectd docker images are sharing some directories with host
497    (e.g. /tmp) therefore only one of collectd barometer flavors can be run
498    at a time. In other words, if you want to try `barometer-collectd-latest` or
499    `barometer-collectd-experimental` image, please stop instance of
500    `barometer-collectd(stable)` image first.
501
502    The Resource Control file system (/sys/fs/resctrl) can be bound from host to
503    container only if this directory exists on the host system. Otherwise omit
504    the '-v /sys/fs/resctrl:/sys/fs/resctrl' part in docker run command.
505    More information about resctrl can be found at:
506    https://github.com/intel/intel-cmt-cat/wiki/resctrl
507
508 Run the barometer-collectd-experimental docker image
509 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
510 Barometer-collectd-experimental container shares default configuration files
511 with 'barometer-collectd-latest' equivalent but some of experimental pull
512 requests may require modified configuration. Additional configuration files that
513 are required specifically by experimental container can be found in
514 `docker/barometer-collectd-experimental/experimental-configs/`
515 directory. Content of this directory (all \*.conf files) should be copied to
516 ``src/collectd/collectd_sample_configs-latest`` directory before first run of
517 experimental container.
518
519 .. code:: bash
520
521    $ cd <BAROMETER_REPO_DIR>
522    $ cp docker/barometer-collectd-experimental/experimental-configs/*.conf \
523      src/collectd/collectd_sample_configs-latest
524
525 When configuration files are up to date for experimental container, it can be
526 launched using following command (almost identical to run-command for ``latest``
527 collectd container)
528
529 .. code:: bash
530
531    $ cd <BAROMETER_REPO_DIR>
532    $ sudo docker run -ti --net=host -v \
533    `pwd`/src/collectd/collectd_sample_configs-latest:/opt/collectd/etc/collectd.conf.d \
534    -v /var/run:/var/run -v /tmp:/tmp -v /sys/fs/resctrl:/sys/fs/resctrl --privileged \
535    opnfv/barometer-collectd-experimental
536
537 .. note::
538    The Resource Control file system (/sys/fs/resctrl) can be bound from host to
539    container only if this directory exists on the host system. Otherwise omit
540    the '-v /sys/fs/resctrl:/sys/fs/resctrl' part in docker run command.
541    More information about resctrl can be found at:
542    https://github.com/intel/intel-cmt-cat/wiki/resctrl
543
544
545 Build and Run InfluxDB and Grafana docker images
546 ------------------------------------------------
547
548 Overview
549 ^^^^^^^^
550 The barometer-influxdb image is based on the influxdb:1.3.7 image from the influxdb dockerhub. To
551 view detils on the base image please visit
552 `https://hub.docker.com/_/influxdb/  <https://hub.docker.com/_/influxdb/>`_ Page includes details of
553 exposed ports and configurable enviromental variables of the base image.
554
555 The barometer-grafana image is based on grafana:4.6.3 image from the grafana dockerhub. To view
556 details on the base image please visit
557 `https://hub.docker.com/r/grafana/grafana/ <https://hub.docker.com/r/grafana/grafana/>`_ Page
558 includes details on exposed ports and configurable enviromental variables of the base image.
559
560 The barometer-grafana image includes pre-configured source and dashboards to display statistics exposed
561 by the barometer-collectd image. The default datasource is an influxdb database running on localhost
562 but the address of the influxdb server can be modified when launching the image by setting the
563 environmental variables influxdb_host to IP or hostname of host on which influxdb server is running.
564
565 Additional dashboards can be added to barometer-grafana by mapping a volume to /opt/grafana/dashboards.
566 Incase where a folder is mounted to this volume only files included in this folder will be visible
567 inside barometer-grafana. To ensure all default files are also loaded please ensure they are included in
568 volume folder been mounted. Appropriate example are given in section `Run the Grafana docker image`_
569
570 Download the InfluxDB and Grafana docker images
571 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
572 If you wish to use pre-built barometer project's influxdb and grafana images, you can pull the
573 images from https://hub.docker.com/r/opnfv/barometer-influxdb/ and https://hub.docker.com/r/opnfv/barometer-grafana/
574
575 .. note::
576    If your preference is to build images locally please see sections `Build InfluxDB Docker Image`_ and
577    `Build Grafana Docker Image`_
578
579 .. code:: bash
580
581     $ docker pull opnfv/barometer-influxdb
582     $ docker pull opnfv/barometer-grafana
583
584 .. note::
585    If you have pulled the pre-built barometer-influxdb and barometer-grafana images there is no
586    requirement to complete steps outlined in  sections `Build InfluxDB Docker Image`_ and
587    `Build Grafana Docker Image`_ and you can proceed directly to section
588    `Run the Influxdb and Grafana Images`_
589
590 Build InfluxDB docker image
591 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
592
593 Build influxdb image from Dockerfile
594
595 .. code:: bash
596
597   $ cd barometer/docker/barometer-influxdb
598   $ sudo docker build -t opnfv/barometer-influxdb --build-arg http_proxy=`echo $http_proxy` \
599     --build-arg https_proxy=`echo $https_proxy` --network=host -f Dockerfile .
600
601 .. note::
602    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs to
603    be passed only if system is behind an HTTP or HTTPS proxy server.
604
605 Check the docker images:
606
607 .. code:: bash
608
609    $ sudo docker images
610
611 Output should contain an influxdb image:
612
613 .. code::
614
615    REPOSITORY                   TAG                 IMAGE ID            CREATED            SIZE
616    opnfv/barometer-influxdb     latest              1e4623a59fe5        3 days ago         191MB
617
618 Build Grafana docker image
619 ^^^^^^^^^^^^^^^^^^^^^^^^^^
620
621 Build Grafana image from Dockerfile
622
623 .. code:: bash
624
625   $ cd barometer/docker/barometer-grafana
626   $ sudo docker build -t opnfv/barometer-grafana --build-arg http_proxy=`echo $http_proxy` \
627     --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
628
629 .. note::
630    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs to
631    be passed only if system is behind an HTTP or HTTPS proxy server.
632
633 Check the docker images:
634
635 .. code:: bash
636
637    $ sudo docker images
638
639 Output should contain an influxdb image:
640
641 .. code::
642
643    REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
644    opnfv/barometer-grafana      latest              05f2a3edd96b        3 hours ago         1.2GB
645
646 Run the Influxdb and Grafana Images
647 -----------------------------------
648
649 Run the InfluxDB docker image
650 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
651 .. code:: bash
652
653    $ sudo docker run -tid -v /var/lib/influxdb:/var/lib/influxdb --net=host\
654     --name bar-influxdb opnfv/barometer-influxdb
655
656 Check your docker image is running
657
658 .. code:: bash
659
660    sudo docker ps
661
662 To make some changes when the container is running run:
663
664 .. code:: bash
665
666    sudo docker exec -ti <CONTAINER ID> /bin/bash
667
668 When both collectd and InfluxDB containers are located
669 on the same host, then no additional configuration have to be added and you
670 can proceed directly to `Run the Grafana docker image`_ section.
671
672 Modify collectd to support InfluxDB on another host
673 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
674 If InfluxDB and collectd containers are located on separate hosts, then
675 additional configuration have to be done in ``collectd`` container - it
676 normally sends data using network plugin to 'localhost/127.0.0.1' therefore
677 changing output location is required:
678
679 1. Stop and remove running bar-collectd container (if it is running)
680
681    .. code:: bash
682
683       $ sudo docker ps #to get collectd container name
684       $ sudo docker rm -f <COLLECTD_CONTAINER_NAME>
685
686 2. Go to location where shared collectd config files are stored
687
688    .. code:: bash
689
690       $ cd <BAROMETER_REPO_DIR>
691       $ cd src/collectd/collectd_sample_configs
692
693 3. Edit content of ``network.conf`` file.
694    By default this file looks like that:
695
696    .. code::
697
698       LoadPlugin  network
699       <Plugin network>
700       Server "127.0.0.1" "25826"
701       </Plugin>
702
703    ``127.0.0.1`` string has to be replaced with the IP address of host where
704    InfluxDB container is running (e.g. ``192.168.121.111``). Edit this using your
705    favorite text editor.
706
707 4. Start again collectd container like it is described in
708    `Run the collectd stable docker image`_ chapter
709
710    .. code:: bash
711
712       $ cd <BAROMETER_REPO_DIR>
713       $ sudo docker run -ti --name bar-collectd --net=host -v \
714       `pwd`/src/collectd/collectd_sample_configs:/opt/collectd/etc/collectd.conf.d \
715       -v /var/run:/var/run -v /tmp:/tmp --privileged opnfv/barometer-collectd
716
717 Now collectd container will be sending data to InfluxDB container located on
718 remote Host pointed by IP configured in step 3.
719
720 Run the Grafana docker image
721 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
722
723 Connecting to an influxdb instance running on local system and adding own custom dashboards
724
725 .. code:: bash
726
727    $ cd <BAROMETER_REPO_DIR>
728    $ sudo docker run -tid -v /var/lib/grafana:/var/lib/grafana \
729      -v ${PWD}/docker/barometer-grafana/dashboards:/opt/grafana/dashboards \
730      --name bar-grafana --net=host opnfv/barometer-grafana
731
732 Connecting to an influxdb instance running on remote system with hostname of someserver and IP address
733 of 192.168.121.111
734
735 .. code:: bash
736
737    $ sudo docker run -tid -v /var/lib/grafana:/var/lib/grafana --net=host -e \
738      influxdb_host=someserver --add-host someserver:192.168.121.111 --name \
739      bar-grafana opnfv/barometer-grafana
740
741 Check your docker image is running
742
743 .. code:: bash
744
745    sudo docker ps
746
747 To make some changes when the container is running run:
748
749 .. code:: bash
750
751    sudo docker exec -ti <CONTAINER ID> /bin/bash
752
753 Connect to <host_ip>:3000 with a browser and log into grafana: admin/admin
754
755 Cleanup of influxdb/grafana configuration
756 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
757
758 When user wants to remove current grafana and influxdb configuration,
759 folowing actions have to be performed
760
761 1. Stop and remove running influxdb and grafana containers
762
763 .. code:: bash
764
765    sudo docker rm -f bar-grafana bar-influxdb
766
767 2. Remove shared influxdb and grafana folders from the Host
768
769 .. code:: bash
770
771    sudo rm -rf /var/lib/grafana
772    sudo rm -rf /var/lib/influxdb
773
774 .. note::
775    Shared folders are storing configuration of grafana and influxdb
776    containers. In case of changing influxdb or grafana configuration
777    (e.g. moving influxdb to another host) it is good to perform cleanup
778    on shared folders to not affect new setup with an old configuration.
779
780 Build and Run VES and Kafka Docker Images
781 -----------------------------------------
782
783 Download VES and Kafka docker images
784 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
785
786 If you wish to use pre-built barometer project's VES and kafka images, you can pull the
787 images from https://hub.docker.com/r/opnfv/barometer-ves/ and  https://hub.docker.com/r/opnfv/barometer-kafka/
788
789 .. note::
790    If your preference is to build images locally please see sections `Build Kafka Docker Image`_ and
791    `Build VES Docker Image`_
792
793 .. code:: bash
794
795     $ docker pull opnfv/barometer-kafka
796     $ docker pull opnfv/barometer-ves
797
798 .. note::
799    If you have pulled the pre-built images there is no requirement to complete steps outlined
800    in sections `Build Kafka Docker Image`_ and `Build VES Docker Image`_ and you can proceed directly to section
801    `Run Kafka Docker Image`_
802
803 Build Kafka docker image
804 ^^^^^^^^^^^^^^^^^^^^^^^^
805
806 Build Kafka docker image:
807
808 .. code:: bash
809
810     $ cd barometer/docker/barometer-kafka
811     $ sudo docker build -t opnfv/barometer-kafka --build-arg http_proxy=`echo $http_proxy` \
812       --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
813
814 .. note::
815    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs
816    to be passed only if system is behind an HTTP or HTTPS proxy server.
817
818 Check the docker images:
819
820 .. code:: bash
821
822    $ sudo docker images
823
824 Output should contain a barometer image:
825
826 .. code::
827
828    REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
829    opnfv/barometer-kafka     latest              05f2a3edd96b        3 hours ago         1.2GB
830
831 Build VES docker image
832 ^^^^^^^^^^^^^^^^^^^^^^
833
834 Build VES application docker image:
835
836 .. code:: bash
837
838     $ cd barometer/docker/barometer-ves
839     $ sudo docker build -t opnfv/barometer-ves --build-arg http_proxy=`echo $http_proxy` \
840       --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
841
842 .. note::
843    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs
844    to be passed only if system is behind an HTTP or HTTPS proxy server.
845
846 Check the docker images:
847
848 .. code:: bash
849
850    $ sudo docker images
851
852 Output should contain a barometer image:
853
854 .. code::
855
856    REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
857    opnfv/barometer-ves       latest              05f2a3edd96b        3 hours ago         1.2GB
858
859 Run Kafka docker image
860 ^^^^^^^^^^^^^^^^^^^^^^
861
862 .. note::
863    Before running Kafka an instance of Zookeeper must be running for the Kafka broker to register
864    with. Zookeeper can be running locally or on a remote platform. Kafka's broker_id and address of
865    its zookeeper instance can be configured by setting values for environmental variables 'broker_id'
866    and 'zookeeper_node'. In instance where 'broker_id' and/or 'zookeeper_node' is not set the default
867    setting of broker_id=0 and zookeeper_node=localhost is used. In intance where Zookeeper is running
868    on same node as Kafka and there is a one to one relationship between Zookeeper and Kafka, default
869    setting can be used. The docker argument `add-host` adds hostname and IP address to
870    /etc/hosts file in container
871
872 Run zookeeper docker image:
873
874 .. code:: bash
875
876    $ sudo docker run -tid --net=host -p 2181:2181 zookeeper:3.4.11
877
878 Run kafka docker image which connects with a zookeeper instance running on same node with a 1:1 relationship
879
880 .. code:: bash
881
882    $ sudo docker run -tid --net=host -p 9092:9092 opnfv/barometer-kafka
883
884
885 Run kafka docker image which connects with a zookeeper instance running on a node with IP address of
886 192.168.121.111 using broker ID of 1
887
888 .. code:: bash
889
890    $ sudo docker run -tid --net=host -p 9092:9092 --env broker_id=1 --env zookeeper_node=zookeeper --add-host \
891      zookeeper:192.168.121.111 opnfv/barometer-kafka
892
893 Run VES Application docker image
894 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
895 .. note::
896    VES application uses configuration file ves_app_config.conf from directory
897    barometer/3rd_party/collectd-ves-app/ves_app/config/ and host.yaml file from
898    barometer/3rd_party/collectd-ves-app/ves_app/yaml/ by default. If you wish to use a custom config
899    file it should be mounted to mount point /opt/ves/config/ves_app_config.conf. To use an alternative yaml
900    file from folder barometer/3rd_party/collectd-ves-app/ves_app/yaml the name of the yaml file to use
901    should be passed as an additional command. If you wish to use a custom file the file should be
902    mounted to mount point /opt/ves/yaml/ Please see examples below
903
904 Run VES docker image with default configuration
905
906 .. code:: bash
907
908    $ sudo docker run -tid --net=host opnfv/barometer-ves
909
910 Run VES docker image with guest.yaml files from barometer/3rd_party/collectd-ves-app/ves_app/yaml/
911
912 .. code:: bash
913
914    $ sudo docker run -tid --net=host opnfv/barometer-ves guest.yaml
915
916
917 Run VES docker image with using custom config and yaml files. In example below yaml/ folder cotains
918 file named custom.yaml
919
920 .. code:: bash
921
922    $ sudo docker run -tid --net=host -v ${PWD}/custom.config:/opt/ves/config/ves_app_config.conf \
923      -v ${PWD}/yaml/:/opt/ves/yaml/ opnfv/barometer-ves custom.yaml
924
925 Run VES Test Collector application
926 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
927
928 VES Test Collector application can be used for displaying platform
929 wide metrics that are collected by barometer-ves container.
930 Setup instructions are located in: :ref:`Setup VES Test Collector`
931
932 Build and Run DMA and Redis Docker Images
933 -----------------------------------------
934
935 Download DMA docker images
936 ^^^^^^^^^^^^^^^^^^^^^^^^^^
937
938 If you wish to use pre-built barometer project's DMA images, you can pull the
939 images from https://hub.docker.com/r/opnfv/barometer-dma/
940
941 .. note::
942    If your preference is to build images locally please see sections `Build DMA Docker Image`_
943
944 .. code:: bash
945
946     $ docker pull opnfv/barometer-dma
947
948 .. note::
949    If you have pulled the pre-built images there is no requirement to complete steps outlined
950    in sections `Build DMA Docker Image`_ and you can proceed directly to section
951    `Run DMA Docker Image`_
952
953 Build DMA docker image
954 ^^^^^^^^^^^^^^^^^^^^^^
955
956 Build DMA docker image:
957
958 .. code:: bash
959
960     $ cd barometer/docker/barometer-dma
961     $ sudo docker build -t opnfv/barometer-dma --build-arg http_proxy=`echo $http_proxy` \
962       --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
963
964 .. note::
965    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs
966    to be passed only if system is behind an HTTP or HTTPS proxy server.
967
968 Check the docker images:
969
970 .. code:: bash
971
972    $ sudo docker images
973
974 Output should contain a barometer image:
975
976 .. code::
977
978    REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
979    opnfv/barometer-dma          latest              2f14fbdbd498        3 hours ago         941 MB
980
981 Run Redis docker image
982 ^^^^^^^^^^^^^^^^^^^^^^
983
984 .. note::
985    Before running DMA, Redis must be running.
986
987 Run Redis docker image:
988
989 .. code:: bash
990
991    $ sudo docker run -tid -p 6379:6379 --name barometer-redis redis
992
993 Check your docker image is running
994
995 .. code:: bash
996
997    sudo docker ps
998
999 Run DMA docker image
1000 ^^^^^^^^^^^^^^^^^^^^
1001 .. note::
1002
1003   Run DMA docker image with default configuration
1004
1005 .. code:: bash
1006
1007    $ cd barometer/docker/barometer-dma
1008    $ sudo mkdir /etc/barometer-dma
1009    $ sudo cp ../../src/dma/examples/config.toml /etc/barometer-dma/
1010    $ sudo vi /etc/barometer-dma/config.toml
1011    (edit amqp_password and os_password:OpenStack admin password)
1012
1013    $ sudo su -
1014    (When there is no key for SSH access authentication)
1015    # ssh-keygen
1016    (Press Enter until done)
1017    (Backup if necessary)
1018    # cp ~/.ssh/authorized_keys ~/.ssh/authorized_keys_org
1019    # cat ~/.ssh/authorized_keys_org ~/.ssh/id_rsa.pub \
1020      > ~/.ssh/authorized_keys
1021    # exit
1022
1023    $ sudo docker run -tid --net=host --name server \
1024      -v /etc/barometer-dma:/etc/barometer-dma \
1025      -v /root/.ssh/id_rsa:/root/.ssh/id_rsa \
1026      -v /etc/collectd/collectd.conf.d:/etc/collectd/collectd.conf.d \
1027      opnfv/barometer-dma /server
1028
1029    $ sudo docker run -tid --net=host --name infofetch \
1030      -v /etc/barometer-dma:/etc/barometer-dma \
1031      -v /var/run/libvirt:/var/run/libvirt \
1032      opnfv/barometer-dma /infofetch
1033
1034    (Execute when installing the threshold evaluation binary)
1035    $ sudo docker cp infofetch:/threshold ./
1036    $ sudo ln -s ${PWD}/threshold /usr/local/bin/
1037
1038 References
1039 ^^^^^^^^^^
1040 .. [1] https://docs.docker.com/config/daemon/systemd/#httphttps-proxy
1041 .. [2] https://docs.docker.com/engine/install/centos/#install-using-the-repository
1042 .. [3] https://docs.docker.com/engine/userguide/
1043
1044