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