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