ec856555b995d14f2e7cbc22bc5e4c8ae670dd24
[barometer.git] / docs / release / userguide / docker.userguide.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. (c) <optionally add copywriters name>
4 .. _barometer-docker-userguide:
5
6 ===================================
7 OPNFV Barometer Docker User 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 Barometer Docker Images Description
35 -----------------------------------
36
37 .. Describe the specific features and how it is realised in the scenario in a brief manner
38 .. to ensure the user understand the context for the user guide instructions to follow.
39
40 Barometer Collectd Image
41 ^^^^^^^^^^^^^^^^^^^^^^^^
42 The barometer collectd docker image gives you a collectd installation that includes all
43 the barometer plugins.
44
45 .. note::
46    The Dockerfile is available in the docker/barometer-collectd directory in the barometer repo.
47    The Dockerfile builds a CentOS 7 docker image.
48    The container MUST be run as a privileged container.
49
50 Collectd is a daemon which collects system performance statistics periodically
51 and provides a variety of mechanisms to publish the collected metrics. It
52 supports more than 90 different input and output plugins. Input plugins
53 retrieve metrics and publish them to the collectd deamon, while output plugins
54 publish the data they receive to an end point. Collectd also has infrastructure
55 to support thresholding and notification.
56
57 Collectd docker image has enabled the following collectd plugins (in addition
58 to the standard collectd plugins):
59
60 * hugepages plugin
61 * Open vSwitch events Plugin
62 * Open vSwitch stats Plugin
63 * mcelog plugin
64 * PMU plugin
65 * RDT plugin
66 * virt
67 * SNMP Agent
68 * Kafka_write plugin
69
70 Plugins and third party applications in Barometer repository that will be available in the
71 docker image:
72
73 * Open vSwitch PMD stats
74 * ONAP VES application
75 * gnocchi plugin
76 * aodh plugin
77 * Legacy/IPMI
78
79 InfluxDB + Grafana Docker Images
80 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
81
82 The Barometer project's InfluxDB and Grafana docker images are 2 docker images that database and graph
83 statistics reported by the Barometer collectd docker. InfluxDB is an open-source time series database
84 tool which stores the data from collectd for future analysis via Grafana, which is a open-source
85 metrics anlytics and visualisation suite which can be accessed through any browser.
86
87 VES + Kafka Docker Images
88 ^^^^^^^^^^^^^^^^^^^^^^^^^
89
90 The Barometer project's VES application and Kafka docker images are based on a CentOS 7 image. Kafka
91 docker image has a dependancy on `Zookeeper <https://zookeeper.apache.org/>`_. Kafka must be able to
92 connect and register with an instance of Zookeeper that is either running on local or remote host.
93 Kafka recieves and stores metrics recieved from Collectd. VES application pulls latest metrics from Kafka
94 which it normalizes into VES format for sending to a VES collector. Please see details in 
95 :ref:`VES Application User Guide <barometer-ves-userguide>`
96
97 One Click Install with Ansible
98 ------------------------------
99
100 Proxy for package manager on host
101 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
102 .. note::
103    This step has to be performed only if host is behind HTTP/HTTPS proxy
104
105 Proxy URL have to be set in dedicated config file
106
107 1. CentOS - /etc/yum.conf
108
109 .. code:: bash
110
111     proxy=http://your.proxy.domain:1234
112
113 2. Ubuntu - /etc/apt/apt.conf
114
115 .. code:: bash
116
117     Acquire::http::Proxy "http://your.proxy.domain:1234"
118
119 After update of config file, apt mirrors have to be updated via 'apt-get update'
120
121 .. code:: bash
122
123     $ sudo apt-get update
124
125 Proxy environment variables(for docker and pip)
126 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127 .. note::
128    This step has to be performed only if host is behind HTTP/HTTPS proxy
129
130 Configuring proxy for packaging system is not enough, also some proxy
131 environment variables have to be set in the system before ansible scripts
132 can be started.
133 Barometer configures docker proxy automatically via ansible task as a part
134 of 'one click install' process - user only has to provide proxy URL using common
135 shell environment variables and ansible will automatically configure proxies
136 for docker(to be able to fetch barometer images). Another component used by
137 ansible (e.g. pip is used for downloading python dependencies) will also benefit
138 from setting proxy variables properly in the system.
139
140 Proxy variables used by ansible One Click Install:
141    * http_proxy
142    * https_proxy
143    * ftp_proxy
144    * no_proxy
145
146 Variables mentioned above have to be visible for superuser (because most
147 actions involving ansible-barometer installation require root privileges).
148 Proxy variables are commonly defined in '/etc/environment' file (but any other
149 place is good as long as variables can be seen by commands using 'su').
150
151 Sample proxy configuration in /etc/environment:
152
153 .. code:: bash
154
155     http_proxy=http://your.proxy.domain:1234
156     https_proxy=http://your.proxy.domain:1234
157     ftp_proxy=http://your.proxy.domain:1234
158     no_proxy=localhost
159
160 Install Ansible
161 ^^^^^^^^^^^^^^^
162 .. note::
163    * sudo permissions or root access are required to install ansible.
164    * ansible version needs to be 2.4+, because usage of import/include statements
165
166 The following steps have been verified with Ansible 2.6.3 on Ubuntu 16.04 and 18.04.
167 To install Ansible 2.6.3 on Ubuntu:
168
169 .. code:: bash
170
171     $ sudo apt-get install python
172     $ sudo apt-get install python-pip
173     $ sudo pip install 'ansible==2.6.3'
174
175 The following steps have been verified with Ansible 2.6.3 on Centos 7.5.
176 To install Ansible 2.6.3 on Centos:
177
178 .. code:: bash
179
180     $ sudo yum install python
181     $ sudo yum install epel-release
182     $ sudo yum install python-pip
183     $ sudo pip install 'ansible==2.6.3'
184
185 Clone barometer repo
186 ^^^^^^^^^^^^^^^^^^^^
187
188 .. code:: bash
189
190     $ git clone https://gerrit.opnfv.org/gerrit/barometer
191     $ cd barometer/docker/ansible
192
193 Edit inventory file
194 ^^^^^^^^^^^^^^^^^^^
195 Edit inventory file and add hosts: $barometer_dir/docker/ansible/default.inv
196
197 .. code:: bash
198
199     [collectd_hosts]
200     localhost
201
202     [collectd_hosts:vars]
203     install_mcelog=true
204     insert_ipmi_modules=true
205
206     [influxdb_hosts]
207     localhost
208
209     [grafana_hosts]
210     localhost
211
212     [prometheus_hosts]
213     #localhost
214
215     [kafka_hosts]
216     #localhost
217
218     [ves_hosts]
219     #localhost
220
221 Change localhost to different hosts where neccessary.
222 Hosts for influxdb and grafana are required only for collectd_service.yml.
223 Hosts for kafka and ves are required only for collectd_ves.yml.
224
225 To change host for kafka edit kafka_ip_addr in ./roles/config_files/vars/main.yml.
226
227 Additional plugin dependencies
228 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
229
230 By default ansible will try to fulfill dependencies for mcelog and ipmi plugin.
231 For mcelog plugin it installs mcelog daemon. For ipmi it tries to insert ipmi_devintf
232 and ipmi_si kernel modules.
233 This can be changed in inventory file with use of variables install_mcelog
234 and insert_ipmi_modules, both variables are independent:
235
236 .. code:: bash
237
238     [collectd_hosts:vars]
239     install_mcelog=false
240     insert_ipmi_modules=false
241
242 .. note::
243    On Ubuntu 18.04 to use mcelog plugin the user has to install mcelog daemon
244    manually ahead of installing from ansible scripts as the deb package is not
245    available in official Ubuntu 18.04 repo. It means that setting install_mcelog
246    to true is ignored.
247
248 Configure ssh keys
249 ^^^^^^^^^^^^^^^^^^
250
251 Generate ssh keys if not present, otherwise move onto next step.
252
253 .. code:: bash
254
255     $ sudo ssh-keygen
256
257 Copy ssh key to all target hosts. It requires to provide root password.
258 The example is for localhost.
259
260 .. code:: bash
261
262     $ sudo ssh-copy-id root@localhost
263
264 Verify that key is added and password is not required to connect.
265
266 .. code:: bash
267
268     $ sudo ssh root@localhost
269
270 .. note::
271    Keys should be added to every target host and [localhost] is only used as an
272    example. For multinode installation keys need to be copied for each node:
273    [collectd_hostname], [influxdb_hostname] etc.
274
275 Download and run Collectd+Influxdb+Grafana containers
276 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
277
278 The One Click installation features easy and scalable deployment of Collectd,
279 Influxdb and Grafana containers using Ansible playbook. The following steps goes
280 through more details.
281
282 .. code:: bash
283
284     $ sudo ansible-playbook -i default.inv collectd_service.yml
285
286 Check the three containers are running, the output of docker ps should be similar to:
287
288 .. code:: bash
289
290     $ sudo docker ps
291     CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS               NAMES
292     a033aeea180d        opnfv/barometer-grafana    "/run.sh"                9 days ago          Up 7 minutes                            bar-grafana
293     1bca2e4562ab        opnfv/barometer-influxdb   "/entrypoint.sh in..."   9 days ago          Up 7 minutes                            bar-influxdb
294     daeeb68ad1d5        opnfv/barometer-collectd   "/run_collectd.sh ..."   9 days ago          Up 7 minutes                            bar-collectd
295
296 To make some changes when a container is running run:
297
298 .. code:: bash
299
300     $ sudo docker exec -ti <CONTAINER ID> /bin/bash
301
302 Connect to <host_ip>:3000 with a browser and log into Grafana: admin/admin.
303 For short introduction please see the:
304 `Grafana guide <http://docs.grafana.org/guides/getting_started/>`_.
305
306 The collectd configuration files can be accessed directly on target system in '/opt/collectd/etc/collectd.conf.d'.
307 It can be used for manual changes or enable/disable plugins. If configuration has been modified it is required to
308 restart collectd:
309
310 .. code:: bash
311
312     $ sudo docker restart bar-collectd
313
314 Download collectd+kafka+ves containers
315 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
316
317 Before running Kafka an instance of zookeeper is required. See `Run Kafka docker image`_ for notes on how to run it.
318 The 'zookeeper_hostname' and 'broker_id' can be set in ./roles/run_kafka/vars/main.yml.
319
320 .. code:: bash
321
322     $ sudo ansible-playbook -i default.inv collectd_ves.yml
323
324 Check the three containers are running, the output of docker ps should be similar to:
325
326 .. code:: bash
327
328     $ sudo docker ps
329     CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS                     PORTS               NAMES
330     8b095ad94ea1        zookeeper:3.4.11           "/docker-entrypoin..."   7 minutes ago       Up 7 minutes                                   awesome_jennings
331     eb8bba3c0b76        opnfv/barometer-ves        "./start_ves_app.s..."   21 minutes ago      Up 6 minutes                                   bar-ves
332     86702a96a68c        opnfv/barometer-kafka      "/src/start_kafka.sh"    21 minutes ago      Up 6 minutes                                   bar-kafka
333     daeeb68ad1d5        opnfv/barometer-collectd   "/run_collectd.sh ..."   13 days ago         Up 6 minutes                                   bar-collectd
334
335
336 To make some changes when a container is running run:
337
338 .. code:: bash
339
340     $ sudo docker exec -ti <CONTAINER ID> /bin/bash
341
342 List of default plugins for collectd container
343 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
344
345 By default the collectd is started with default configuration which includes the followin plugins:
346    * csv, contextswitch, cpu, cpufreq, df, disk, ethstat, ipc, irq, load, memory, numa, processes,
347      swap, turbostat, uuid, uptime, exec, hugepages, intel_pmu, ipmi, write_kafka, logfile, mcelog,
348      network, intel_rdt, rrdtool, snmp_agent, syslog, virt, ovs_stats, ovs_events
349
350 Some of the plugins are loaded depending on specific system requirements and can be omitted if
351 dependency is not met, this is the case for:
352    * hugepages, ipmi, mcelog, intel_rdt, virt, ovs_stats, ovs_events
353
354 List and description of tags used in ansible scripts
355 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
356
357 Tags can be used to run a specific part of the configuration without running the whole playbook.
358 To run a specific parts only:
359
360 .. code:: bash
361
362     $ sudo ansible-playbook -i default.inv collectd_service.yml --tags "syslog,cpu,uuid"
363
364 To disable some parts or plugins:
365
366 .. code:: bash
367
368     $ sudo ansible-playbook -i default.inv collectd_service.yml --skip-tags "en_default_all,syslog,cpu,uuid"
369
370 List of available tags:
371
372 install_docker
373   Install docker and required dependencies with package manager.
374
375 add_docker_proxy
376   Configure proxy file for docker service if proxy is set on host environment.
377
378 rm_config_dir
379   Remove collectd config files.
380
381 copy_additional_configs
382   Copy additional configuration files to target system. Path to additional configuration
383   is stored in $barometer_dir/docker/ansible/roles/config_files/vars/main.yml as additional_configs_path.
384
385 en_default_all
386   Set of default read plugins: contextswitch, cpu, cpufreq, df, disk, ethstat, ipc, irq,
387   load, memory, numa, processes, swap, turbostat, uptime.
388
389 plugins tags
390   The following tags can be used to enable/disable plugins: csv, contextswitch, cpu,
391   cpufreq, df, disk, ethstat, ipc, irq, load, memory, numa, processes, swap, turbostat,
392   uptime, exec, hugepages, ipmi, kafka, logfile, mcelogs, network, pmu, rdt, rrdtool,
393   snmp, syslog, virt, ovs_stats, ovs_events, uuid.
394
395 Installing Docker
396 -----------------
397 .. Describe the specific capabilities and usage for <XYZ> feature.
398 .. Provide enough information that a user will be able to operate the feature on a deployed scenario.
399
400 .. note::
401    The below sections provide steps for manual installation and configuration
402    of docker images. They are not neccessary if docker images were installed with
403    use of Ansible-Playbook.
404
405 On Ubuntu
406 ^^^^^^^^^^
407 .. note::
408    * sudo permissions are required to install docker.
409    * These instructions are for Ubuntu 16.10
410
411 To install docker:
412
413 .. code:: bash
414
415     $ sudo apt-get install curl
416     $ sudo curl -fsSL https://get.docker.com/ | sh
417     $ sudo usermod -aG docker <username>
418     $ sudo systemctl status docker
419
420 Replace <username> above with an appropriate user name.
421
422 On CentOS
423 ^^^^^^^^^^
424 .. note::
425    * sudo permissions are required to install docker.
426    * These instructions are for CentOS 7
427
428 To install docker:
429
430 .. code:: bash
431
432     $ sudo yum remove docker docker-common docker-selinux docker-engine
433     $ sudo yum install -y yum-utils  device-mapper-persistent-data  lvm2
434     $ sudo yum-config-manager   --add-repo    https://download.docker.com/linux/centos/docker-ce.repo
435     $ sudo yum-config-manager --enable docker-ce-edge
436     $ sudo yum-config-manager --enable docker-ce-test
437     $ sudo yum install docker-ce
438     $ sudo usermod -aG docker <username>
439     $ sudo systemctl status docker
440
441 Replace <username> above with an appropriate user name.
442
443 .. note::
444    If this is the first time you are installing a package from a recently added
445    repository, you will be prompted to accept the GPG key, and the key’s
446    fingerprint will be shown. Verify that the fingerprint is correct, and if so,
447    accept the key. The fingerprint should match060A 61C5 1B55 8A7F 742B 77AA C52F
448    EB6B 621E 9F35.
449
450         Retrieving key from https://download.docker.com/linux/centos/gpg
451         Importing GPG key 0x621E9F35:
452          Userid     : "Docker Release (CE rpm) <docker@docker.com>"
453          Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
454          From       : https://download.docker.com/linux/centos/gpg
455         Is this ok [y/N]: y
456
457 Manual proxy configuration for docker
458 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
459
460 .. note::
461    This applies for both CentOS and Ubuntu.
462
463 If you are behind an HTTP or HTTPS proxy server, you will need to add this
464 configuration in the Docker systemd service file.
465
466 1. Create a systemd drop-in directory for the docker service:
467
468 .. code:: bash
469
470    $ sudo mkdir -p /etc/systemd/system/docker.service.d
471
472 2. Create a file
473 called /etc/systemd/system/docker.service.d/http-proxy.conf that adds
474 the HTTP_PROXY environment variable:
475
476 .. code:: bash
477
478    [Service]
479    Environment="HTTP_PROXY=http://proxy.example.com:80/"
480
481 Or, if you are behind an HTTPS proxy server, create a file
482 called /etc/systemd/system/docker.service.d/https-proxy.conf that adds
483 the HTTPS_PROXY environment variable:
484
485 .. code:: bash
486
487     [Service]
488     Environment="HTTPS_PROXY=https://proxy.example.com:443/"
489
490 Or create a single file with all the proxy configurations:
491 /etc/systemd/system/docker.service.d/proxy.conf
492
493 .. code:: bash
494
495     [Service]
496     Environment="HTTP_PROXY=http://proxy.example.com:80/"
497     Environment="HTTPS_PROXY=https://proxy.example.com:443/"
498     Environment="FTP_PROXY=ftp://proxy.example.com:443/"
499     Environment="NO_PROXY=localhost"
500
501 3. Flush changes:
502
503 .. code:: bash
504
505     $ sudo systemctl daemon-reload
506
507 4. Restart Docker:
508
509 .. code:: bash
510
511     $ sudo systemctl restart docker
512
513 5. Check docker environment variables:
514
515 .. code:: bash
516
517     sudo systemctl show --property=Environment docker
518
519 Test docker installation
520 ^^^^^^^^^^^^^^^^^^^^^^^^
521 .. note::
522    This applies for both CentOS and Ubuntu.
523
524 .. code:: bash
525
526    $ sudo docker run hello-world
527
528 The output should be something like:
529
530 .. code:: bash
531
532    Unable to find image 'hello-world:latest' locally
533    latest: Pulling from library/hello-world
534    5b0f327be733: Pull complete
535    Digest: sha256:07d5f7800dfe37b8c2196c7b1c524c33808ce2e0f74e7aa00e603295ca9a0972
536    Status: Downloaded newer image for hello-world:latest
537
538    Hello from Docker!
539    This message shows that your installation appears to be working correctly.
540
541    To generate this message, Docker took the following steps:
542     1. The Docker client contacted the Docker daemon.
543     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
544     3. The Docker daemon created a new container from that image which runs the
545        executable that produces the output you are currently reading.
546     4. The Docker daemon streamed that output to the Docker client, which sent it
547        to your terminal.
548
549 To try something more ambitious, you can run an Ubuntu container with:
550
551 .. code:: bash
552
553     $ docker run -it ubuntu bash
554
555 Build and Run Collectd Docker Image
556 -----------------------------------
557
558 Download the collectd docker image
559 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
560 If you wish to use a pre-built barometer image, you can pull the barometer
561 image from https://hub.docker.com/r/opnfv/barometer-collectd/
562
563 .. code:: bash
564
565     $ docker pull opnfv/barometer-collectd
566
567 Build the collectd docker image
568 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
569
570 .. code:: bash
571
572     $ git clone https://gerrit.opnfv.org/gerrit/barometer
573     $ cd barometer/docker/barometer-collectd
574     $ sudo docker build -t opnfv/barometer-collectd --build-arg http_proxy=`echo $http_proxy` \
575       --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
576
577 .. note::
578    Main directory of barometer source code (directory that contains 'docker',
579    'docs', 'src' and systems sub-directories) will be referred as
580    ``<BAROMETER_REPO_DIR>``
581
582
583 .. note::
584    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs to be
585    passed only if system is behind an HTTP or HTTPS proxy server.
586
587 Check the docker images:
588
589 .. code:: bash
590
591    $ sudo docker images
592
593 Output should contain a barometer-collectd image:
594
595 .. code::
596
597    REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
598    opnfv/barometer-collectd     latest              05f2a3edd96b        3 hours ago         1.2GB
599    centos                       7                   196e0ce0c9fb        4 weeks ago         197MB
600    centos                       latest              196e0ce0c9fb        4 weeks ago         197MB
601    hello-world                  latest              05a3bd381fc2        4 weeks ago         1.84kB
602
603 Run the collectd docker image
604 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
605 .. code:: bash
606
607    $ cd <BAROMETER_REPO_DIR>
608    $ sudo docker run -ti --net=host -v \
609    `pwd`/src/collectd/collectd_sample_configs:/opt/collectd/etc/collectd.conf.d \
610    -v /var/run:/var/run -v /tmp:/tmp --privileged opnfv/barometer-collectd
611
612 .. note::
613    The docker collectd image contains configuration for all the collectd
614    plugins. In the command above we are overriding
615    /opt/collectd/etc/collectd.conf.d by mounting a host directory
616    src/collectd/collectd_sample_configs that contains only the sample
617    configurations we are interested in running. *It's important to do
618    this if you don't have DPDK, or RDT installed on the host*.
619    Sample configurations can be found at:
620    https://github.com/opnfv/barometer/tree/master/src/collectd/collectd_sample_configs
621
622 Check your docker image is running
623
624 .. code:: bash
625
626    sudo docker ps
627
628 To make some changes when the container is running run:
629
630 .. code:: bash
631
632    sudo docker exec -ti <CONTAINER ID> /bin/bash
633
634 Build and Run InfluxDB and Grafana docker images
635 ------------------------------------------------
636
637 Overview
638 ^^^^^^^^
639 The barometer-influxdb image is based on the influxdb:1.3.7 image from the influxdb dockerhub. To
640 view detils on the base image please visit
641 `https://hub.docker.com/_/influxdb/  <https://hub.docker.com/_/influxdb/>`_ Page includes details of
642 exposed ports and configurable enviromental variables of the base image.
643
644 The barometer-grafana image is based on grafana:4.6.3 image from the grafana dockerhub. To view
645 details on the base image please visit
646 `https://hub.docker.com/r/grafana/grafana/ <https://hub.docker.com/r/grafana/grafana/>`_ Page
647 includes details on exposed ports and configurable enviromental variables of the base image.
648
649 The barometer-grafana image includes pre-configured source and dashboards to display statistics exposed
650 by the barometer-collectd image. The default datasource is an influxdb database running on localhost
651 but the address of the influxdb server can be modified when launching the image by setting the
652 environmental variables influxdb_host to IP or hostname of host on which influxdb server is running.
653
654 Additional dashboards can be added to barometer-grafana by mapping a volume to /opt/grafana/dashboards.
655 Incase where a folder is mounted to this volume only files included in this folder will be visible
656 inside barometer-grafana. To ensure all default files are also loaded please ensure they are included in
657 volume folder been mounted. Appropriate example are given in section `Run the Grafana docker image`_
658
659 Download the InfluxDB and Grafana docker images
660 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
661 If you wish to use pre-built barometer project's influxdb and grafana images, you can pull the
662 images from https://hub.docker.com/r/opnfv/barometer-influxdb/ and https://hub.docker.com/r/opnfv/barometer-grafana/
663
664 .. note::
665    If your preference is to build images locally please see sections `Build InfluxDB Docker Image`_ and
666    `Build Grafana Docker Image`_
667
668 .. code:: bash
669
670     $ docker pull opnfv/barometer-influxdb
671     $ docker pull opnfv/barometer-grafana
672
673 .. note::
674    If you have pulled the pre-built barometer-influxdb and barometer-grafana images there is no
675    requirement to complete steps outlined in  sections `Build InfluxDB Docker Image`_ and
676    `Build Grafana Docker Image`_ and you can proceed directly to section
677    `Run the Influxdb and Grafana Images`_ If you wish to run the barometer-influxdb and
678    barometer-grafana images via Docker Compose proceed directly to section
679    `Docker Compose`_.
680
681 Build InfluxDB docker image
682 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
683
684 Build influxdb image from Dockerfile
685
686 .. code:: bash
687
688   $ cd barometer/docker/barometer-influxdb
689   $ sudo docker build -t opnfv/barometer-influxdb --build-arg http_proxy=`echo $http_proxy` \
690     --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
691
692 .. note::
693    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs to
694    be passed only if system is behind an HTTP or HTTPS proxy server.
695
696 Check the docker images:
697
698 .. code:: bash
699
700    $ sudo docker images
701
702 Output should contain an influxdb image:
703
704 .. code::
705
706    REPOSITORY                   TAG                 IMAGE ID            CREATED            SIZE
707    opnfv/barometer-influxdb     latest              1e4623a59fe5        3 days ago         191MB
708
709 Build Grafana docker image
710 ^^^^^^^^^^^^^^^^^^^^^^^^^^
711
712 Build Grafana image from Dockerfile
713
714 .. code:: bash
715
716   $ cd barometer/docker/barometer-grafana
717   $ sudo docker build -t opnfv/barometer-grafana --build-arg http_proxy=`echo $http_proxy` \
718     --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
719
720 .. note::
721    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs to
722    be passed only if system is behind an HTTP or HTTPS proxy server.
723
724 Check the docker images:
725
726 .. code:: bash
727
728    $ sudo docker images
729
730 Output should contain an influxdb image:
731
732 .. code::
733
734    REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
735    opnfv/barometer-grafana      latest              05f2a3edd96b        3 hours ago         1.2GB
736
737 Run the Influxdb and Grafana Images
738 -----------------------------------
739
740 Run the InfluxDB docker image
741 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
742 .. code:: bash
743
744    $ sudo docker run -tid -v /var/lib/influxdb:/var/lib/influxdb -p 8086:8086 -p 25826:25826  opnfv/barometer-influxdb
745
746 Check your docker image is running
747
748 .. code:: bash
749
750    sudo docker ps
751
752 To make some changes when the container is running run:
753
754 .. code:: bash
755
756    sudo docker exec -ti <CONTAINER ID> /bin/bash
757
758 Run the Grafana docker image
759 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
760
761 Connecting to an influxdb instance running on local system and adding own custom dashboards
762
763 .. code:: bash
764
765    $ cd <BAROMETER_REPO_DIR>
766    $ sudo docker run -tid -v /var/lib/grafana:/var/lib/grafana -v ${PWD}/docker/barometer-grafana/dashboards:/opt/grafana/dashboards \
767      -p 3000:3000 opnfv/barometer-grafana
768
769 Connecting to an influxdb instance running on remote system with hostname of someserver and IP address
770 of 192.168.121.111
771
772 .. code:: bash
773
774    $ sudo docker run -tid -v /var/lib/grafana:/var/lib/grafana -p 3000:3000 -e \
775      influxdb_host=someserver --add-host someserver:192.168.121.111 opnfv/barometer-grafana
776
777 Check your docker image is running
778
779 .. code:: bash
780
781    sudo docker ps
782
783 To make some changes when the container is running run:
784
785 .. code:: bash
786
787    sudo docker exec -ti <CONTAINER ID> /bin/bash
788
789 Connect to <host_ip>:3000 with a browser and log into grafana: admin/admin
790
791
792 Build and Run VES and Kafka Docker Images
793 ------------------------------------------
794
795 Download VES and Kafka docker images
796 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
797
798 If you wish to use pre-built barometer project's VES and kafka images, you can pull the
799 images from https://hub.docker.com/r/opnfv/barometer-ves/ and  https://hub.docker.com/r/opnfv/barometer-kafka/
800
801 .. note::
802    If your preference is to build images locally please see sections `Build the Kafka Image`_ and
803    `Build VES Image`_
804
805 .. code:: bash
806
807     $ docker pull opnfv/barometer-kafka
808     $ docker pull opnfv/barometer-ves
809
810 .. note::
811    If you have pulled the pre-built images there is no requirement to complete steps outlined
812    in sections `Build Kafka Docker Image`_ and `Build VES Docker Image`_ and you can proceed directly to section
813    `Run Kafka Docker Image`_ If you wish to run the docker images via Docker Compose proceed directly to section `Docker Compose`_.
814
815 Build Kafka docker image
816 ^^^^^^^^^^^^^^^^^^^^^^^^
817
818 Build Kafka docker image:
819
820 .. code:: bash
821
822     $ cd barometer/docker/barometer-kafka
823     $ sudo docker build -t opnfv/barometer-kafka --build-arg http_proxy=`echo $http_proxy` \
824       --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
825
826 .. note::
827    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs
828    to be passed only if system is behind an HTTP or HTTPS proxy server.
829
830 Check the docker images:
831
832 .. code:: bash
833
834    $ sudo docker images
835
836 Output should contain a barometer image:
837
838 .. code::
839
840    REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
841    opnfv/barometer-kafka     latest              05f2a3edd96b        3 hours ago         1.2GB
842
843 Build VES docker image
844 ^^^^^^^^^^^^^^^^^^^^^^
845
846 Build VES application docker image:
847
848 .. code:: bash
849
850     $ cd barometer/docker/barometer-ves
851     $ sudo docker build -t opnfv/barometer-ves --build-arg http_proxy=`echo $http_proxy` \
852       --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
853
854 .. note::
855    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs
856    to be passed only if system is behind an HTTP or HTTPS proxy server.
857
858 Check the docker images:
859
860 .. code:: bash
861
862    $ sudo docker images
863
864 Output should contain a barometer image:
865
866 .. code::
867
868    REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
869    opnfv/barometer-ves       latest              05f2a3edd96b        3 hours ago         1.2GB
870
871 Run Kafka docker image
872 ^^^^^^^^^^^^^^^^^^^^^^
873
874 .. note::
875    Before running Kafka an instance of Zookeeper must be running for the Kafka broker to register
876    with. Zookeeper can be running locally or on a remote platform. Kafka's broker_id and address of
877    its zookeeper instance can be configured by setting values for environmental variables 'broker_id'
878    and 'zookeeper_node'. In instance where 'broker_id' and/or 'zookeeper_node' is not set the default
879    setting of broker_id=0 and zookeeper_node=localhost is used. In intance where Zookeeper is running
880    on same node as Kafka and there is a one to one relationship between Zookeeper and Kafka, default
881    setting can be used. The docker argument `add-host` adds hostname and IP address to
882    /etc/hosts file in container
883
884 Run zookeeper docker image:
885
886 .. code:: bash
887
888    $ sudo docker run -tid --net=host -p 2181:2181 zookeeper:3.4.11
889
890 Run kafka docker image which connects with a zookeeper instance running on same node with a 1:1 relationship
891
892 .. code:: bash
893
894    $ sudo docker run -tid --net=host -p 9092:9092 opnfv/barometer-kafka
895
896
897 Run kafka docker image which connects with a zookeeper instance running on a node with IP address of
898 192.168.121.111 using broker ID of 1
899
900 .. code:: bash
901
902    $ sudo docker run -tid --net=host -p 9092:9092 --env broker_id=1 --env zookeeper_node=zookeeper --add-host \
903      zookeeper:192.168.121.111 opnfv/barometer-kafka
904
905 Run VES Application docker image
906 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
907 .. note::
908    VES application uses configuration file ves_app_config.conf from directory
909    barometer/3rd_party/collectd-ves-app/ves_app/config/ and host.yaml file from
910    barometer/3rd_party/collectd-ves-app/ves_app/yaml/ by default. If you wish to use a custom config
911    file it should be mounted to mount point /opt/ves/config/ves_app_config.conf. To use an alternative yaml
912    file from folder barometer/3rd_party/collectd-ves-app/ves_app/yaml the name of the yaml file to use
913    should be passed as an additional command. If you wish to use a custom file the file should be
914    mounted to mount point /opt/ves/yaml/ Please see examples below
915
916 Run VES docker image with default configuration
917
918 .. code:: bash
919
920    $ sudo docker run -tid --net=host opnfv/barometer-ves
921
922 Run VES docker image with guest.yaml files from barometer/3rd_party/collectd-ves-app/ves_app/yaml/
923
924 .. code:: bash
925
926    $ sudo docker run -tid --net=host opnfv/barometer-ves guest.yaml
927
928
929 Run VES docker image with using custom config and yaml files. In example below yaml/ folder cotains
930 file named custom.yaml
931
932 .. code:: bash
933
934    $ sudo docker run -tid --net=host -v ${PWD}/custom.config:/opt/ves/config/ves_app_config.conf \
935      -v ${PWD}/yaml/:/opt/ves/yaml/ opnfv/barometer-ves custom.yaml
936
937 Build and Run LocalAgent and Redis Docker Images
938 -----------------------------------------------------
939
940 Download LocalAgent docker images
941 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
942
943 If you wish to use pre-built barometer project's LocalAgent images, you can pull the
944 images from https://hub.docker.com/r/opnfv/barometer-localagent/
945
946 .. note::
947    If your preference is to build images locally please see sections `Build LocalAgent Docker Image`_
948
949 .. code:: bash
950
951     $ docker pull opnfv/barometer-localagent
952
953 .. note::
954    If you have pulled the pre-built images there is no requirement to complete steps outlined
955    in sections `Build LocalAgent Docker Image`_ and you can proceed directly to section
956    `Run LocalAgent Docker Image`_ If you wish to run the docker images via Docker Compose proceed directly to section `Docker Compose`_.
957
958 Build LocalAgent docker image
959 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
960
961 Build LocalAgent docker image:
962
963 .. code:: bash
964
965     $ cd barometer/docker/barometer-dma
966     $ sudo docker build -t opnfv/barometer-dma --build-arg http_proxy=`echo $http_proxy` \
967       --build-arg https_proxy=`echo $https_proxy` -f Dockerfile .
968
969 .. note::
970    In the above mentioned ``docker build`` command, http_proxy & https_proxy arguments needs
971    to be passed only if system is behind an HTTP or HTTPS proxy server.
972
973 Check the docker images:
974
975 .. code:: bash
976
977    $ sudo docker images
978
979 Output should contain a barometer image:
980
981 .. code::
982
983    REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
984    opnfv/barometer-dma          latest              2f14fbdbd498        3 hours ago         941 MB
985
986 Run Redis docker image
987 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
988
989 .. note::
990    Before running LocalAgent, Redis must be running.
991
992 Run Redis docker image:
993
994 .. code:: bash
995
996    $ sudo docker run -tid -p 6379:6379 --name barometer-redis redis
997
998 Check your docker image is running
999
1000 .. code:: bash
1001
1002    sudo docker ps
1003
1004 Run LocalAgent docker image
1005 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1006 .. note::
1007
1008 Run LocalAgent docker image with default configuration
1009
1010 .. code:: bash
1011
1012    $ cd barometer/docker/barometer-dma
1013    $ sudo mkdir /etc/barometer-dma
1014    $ sudo cp ../../src/dma/examples/config.toml /etc/barometer-dma/
1015    $ sudo vi /etc/barometer-dma/config.toml
1016    (edit amqp_password and os_password:OpenStack admin password)
1017
1018    $ sudo su -
1019    (When there is no key for SSH access authentication)
1020    # ssh-keygen
1021    (Press Enter until done)
1022    (Backup if necessary)
1023    # cp ~/.ssh/authorized_keys ~/.ssh/authorized_keys_org
1024    # cat ~/.ssh/authorized_keys_org ~/.ssh/id_rsa.pub \
1025      > ~/.ssh/authorized_keys
1026    # exit
1027
1028    $ sudo docker run -tid --net=host --name server \
1029      -v /etc/barometer-dma:/etc/barometer-dma \
1030      -v /root/.ssh/id_rsa:/root/.ssh/id_rsa \
1031      -v /etc/collectd/collectd.conf.d:/etc/collectd/collectd.conf.d \
1032      opnfv/barometer-dma /server
1033
1034    $ sudo docker run -tid --net=host --name infofetch \
1035      -v /etc/barometer-dma:/etc/barometer-dma \
1036      -v /var/run/libvirt:/var/run/libvirt \
1037      opnfv/barometer-dma /infofetch
1038
1039    (Execute when installing the threshold evaluation binary)
1040    $ sudo docker cp infofetch:/threshold ./
1041    $ sudo ln -s ${PWD}/threshold /usr/local/bin/
1042
1043 Docker Compose
1044 --------------
1045
1046 Install docker-compose
1047 ^^^^^^^^^^^^^^^^^^^^^^
1048
1049 On the node where you want to run influxdb + grafana or the node where you want to run the VES app
1050 zookeeper and Kafka containers together:
1051
1052 .. note::
1053    The default configuration for all these containers is to run on the localhost. If this is not
1054    the model you want to use then please make the appropriate configuration changes before launching
1055    the docker containers.
1056
1057 1. Start by installing docker compose
1058
1059 .. code:: bash
1060
1061    $ sudo curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/bin/docker-compose
1062
1063 .. note::
1064    Use the latest Compose release number in the download command. The above command is an example,
1065    and it may become out-of-date. To ensure you have the latest version, check the Compose repository
1066    release page on GitHub.
1067
1068 2. Apply executable permissions to the binary:
1069
1070 .. code:: bash
1071
1072    $ sudo chmod +x /usr/bin/docker-compose
1073
1074 3. Test the installation.
1075
1076 .. code:: bash
1077
1078   $ sudo docker-compose --version
1079
1080 Run the InfluxDB and Grafana containers using docker compose
1081 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1082
1083 Launch containers:
1084
1085 .. code:: bash
1086
1087    $ cd barometer/docker/compose/influxdb-grafana/
1088    $ sudo docker-compose up -d
1089
1090 Check your docker images are running
1091
1092 .. code:: bash
1093
1094    $ sudo docker ps
1095
1096 Connect to <host_ip>:3000 with a browser and log into grafana: admin/admin
1097
1098 Run the Kafka, zookeeper and VES containers using docker compose
1099 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1100
1101 Launch containers:
1102
1103 .. code:: bash
1104
1105    $ cd barometer/docker/compose/ves/
1106    $ sudo docker-compose up -d
1107
1108 Check your docker images are running
1109
1110 .. code:: bash
1111
1112    $ sudo docker ps
1113
1114 Testing the docker image
1115 ^^^^^^^^^^^^^^^^^^^^^^^^
1116 TODO
1117
1118 References
1119 ^^^^^^^^^^^
1120 .. [1] https://docs.docker.com/engine/admin/systemd/#httphttps-proxy
1121 .. [2] https://docs.docker.com/engine/installation/linux/docker-ce/centos/#install-using-the-repository
1122 .. [3] https://docs.docker.com/engine/userguide/
1123
1124