From da9564a9b0b78bbe341de9b039aab3c378eb027f Mon Sep 17 00:00:00 2001 From: Bryan Sullivan Date: Mon, 22 Jan 2018 15:25:53 -0800 Subject: Implement component deployment via cloudify JIRA: VES-2 Change-Id: Ic696f13d2a32e10663f50cd4e26b9a060525ff92 Signed-off-by: Bryan Sullivan --- build/ves-agent.sh | 5 +- build/ves-agent/Dockerfile | 29 +- build/ves-barometer.sh | 51 ++ build/ves-barometer/Dockerfile | 38 + build/ves-barometer/start.sh | 151 ++++ build/ves-collector.sh | 8 +- build/ves-collector/Dashboard.json | 996 ++++++++++++++++++++++++++ build/ves-collector/Dockerfile | 14 +- build/ves-collector/start.sh | 59 +- build/ves-kafka.sh | 2 +- build/ves-kafka/start.sh | 6 +- tools/cloudify/ves-agent/blueprint.yaml | 9 + tools/cloudify/ves-collector/blueprint.yaml | 183 +++++ tools/cloudify/ves-grafana/blueprint.yaml | 123 ++++ tools/cloudify/ves-influxdb/blueprint.yaml | 122 ++++ tools/cloudify/ves-kafka/blueprint.yaml | 142 ++++ tools/cloudify/ves-zookeeper/blueprint.yaml | 122 ++++ tools/demo_deploy.sh | 163 +++-- tools/grafana/Dashboard.json | 996 -------------------------- tools/kubernetes/ves-barometer/daemonset.yaml | 62 ++ tools/ves-setup.sh | 546 +++++++------- 21 files changed, 2419 insertions(+), 1408 deletions(-) create mode 100644 build/ves-barometer.sh create mode 100644 build/ves-barometer/Dockerfile create mode 100644 build/ves-barometer/start.sh create mode 100644 build/ves-collector/Dashboard.json create mode 100644 tools/cloudify/ves-collector/blueprint.yaml create mode 100644 tools/cloudify/ves-grafana/blueprint.yaml create mode 100644 tools/cloudify/ves-influxdb/blueprint.yaml create mode 100644 tools/cloudify/ves-kafka/blueprint.yaml create mode 100644 tools/cloudify/ves-zookeeper/blueprint.yaml delete mode 100644 tools/grafana/Dashboard.json create mode 100644 tools/kubernetes/ves-barometer/daemonset.yaml diff --git a/build/ves-agent.sh b/build/ves-agent.sh index 87d4b07..396d7ea 100644 --- a/build/ves-agent.sh +++ b/build/ves-agent.sh @@ -19,7 +19,7 @@ #. Docker hub user logged in e.g. via "sudo docker login" #. #. Usage: -#. bash ves-agent.sh +#. bash ves-agent.sh #. hub-user: username for dockerhub #. #. NOTE: To allow patch testing, this script will not reclone the VES repo @@ -31,9 +31,6 @@ echo; echo "$0 $(date): Update package repos" sudo apt-get update echo; echo "$0 $(date): Starting VES agent build process" -if [[ -d /tmp/ves ]]; then rm -rf /tmp/ves; fi - -echo; echo "$0 $(date): Starting VES kafka build process" if [[ ! -d /tmp/ves ]]; then echo; echo "$0 $(date): Cloning VES repo to /tmp/ves" git clone https://gerrit.opnfv.org/gerrit/ves /tmp/ves diff --git a/build/ves-agent/Dockerfile b/build/ves-agent/Dockerfile index 4c37197..293fcd5 100644 --- a/build/ves-agent/Dockerfile +++ b/build/ves-agent/Dockerfile @@ -21,26 +21,19 @@ FROM ubuntu:xenial MAINTAINER Bryan Sullivan -RUN apt-get update -RUN apt-get install -y apt-utils +RUN mkdir /opt/ves + +RUN apt-get update && apt-get install -y apt-utils RUN apt-get -y upgrade -RUN apt-get install -y git -# Required for kafka -RUN apt-get install -y default-jre -RUN apt-get install -y zookeeperd -RUN apt-get install -y python-pip +# Required for kafka: default-jre zookeeperd python-pip kafka-python +# Required for building librdkafka: git build-essential libpthread-stubs0-dev libssl-dev libsasl2-dev liblz4-dev +# Required for building collectd: pkg-config +RUN apt-get update && apt-get install -y default-jre \ +zookeeperd python-pip pkg-config \ +git build-essential libpthread-stubs0-dev libssl-dev libsasl2-dev liblz4-dev RUN pip install kafka-python -# Required for building collectd -RUN apt-get install -y pkg-config - -RUN mkdir /opt/ves # Build Kafka client -RUN apt-get install -y build-essential -RUN apt-get install -y libpthread-stubs0-dev -RUN apt-get install -y libssl-dev -RUN apt-get install -y libsasl2-dev -RUN apt-get install -y liblz4-dev RUN /bin/bash -c 'git clone --branch v0.9.5 \ https://github.com/edenhill/librdkafka.git /opt/ves/librdkafka; \ cd /opt/ves/librdkafka; ./configure --prefix=/usr; \ @@ -50,10 +43,6 @@ make; make install' RUN pip install pyaml RUN git clone https://gerrit.opnfv.org/gerrit/barometer /opt/ves/barometer -# Test patch -RUN /bin/bash -c 'cd /opt/ves/barometer; \ -git fetch https://gerrit.opnfv.org/gerrit/barometer \ -refs/changes/27/47427/1 && git checkout FETCH_HEAD' COPY start.sh /opt/ves/start.sh ENTRYPOINT ["/bin/bash", "/opt/ves/start.sh"] diff --git a/build/ves-barometer.sh b/build/ves-barometer.sh new file mode 100644 index 0000000..86e81f4 --- /dev/null +++ b/build/ves-barometer.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# Copyright 2018 AT&T Intellectual Property, Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +#. What this is: Build script for the OPNFV Barometer collectd agent docker image. +#. +#. Prerequisites: +#. Docker hub user logged in e.g. via "sudo docker login" +#. +#. Usage: +#. bash ves-barometer.sh [--no-cache] +#. hub-user: username for dockerhub +#. --no-cache +#. +#. NOTE: To allow patch testing, this script will not reclone the VES repo +#. if it exists under /tmp +#. +#. Status: this is a work in progress, under test. + +cache="$2" +echo; echo "$0 $(date): Update package repos" +sudo apt-get update + +echo; echo "$0 $(date): Starting VES agent build process" +if [[ ! -d /tmp/ves ]]; then + echo; echo "$0 $(date): Cloning VES repo to /tmp/ves" + git clone https://gerrit.opnfv.org/gerrit/ves /tmp/ves +fi + +echo; echo "$0 $(date): Building the image" +cd /tmp/ves/build/ves-barometer +sudo docker build $cache -t ves-barometer . + +echo; echo "$0 $(date): Tagging the image" +id=$(sudo docker images | grep ves-barometer | awk '{print $3}') +id=$(echo $id | cut -d ' ' -f 1) +sudo docker tag $id $1/ves-barometer:latest + +echo; echo "$0 $(date): Pushing the image to dockerhub as $1/ves-barometer" +sudo docker push $1/ves-barometer diff --git a/build/ves-barometer/Dockerfile b/build/ves-barometer/Dockerfile new file mode 100644 index 0000000..4bd4c51 --- /dev/null +++ b/build/ves-barometer/Dockerfile @@ -0,0 +1,38 @@ +# Copyright 2018 AT&T Intellectual Property, Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# What this is: A Dockerfile for building an OPFNV VES Agent container image. +# +# Status: this is a work in progress, under test. +# +FROM centos:7 +RUN yum update -y && yum install -y which sudo git +ENV DOCKER y +ENV repos_dir /src +ENV openstack_plugins /src/barometer/src/collectd-openstack-plugins +RUN git config --global http.sslVerify false + +WORKDIR ${repos_dir} +RUN git clone https://gerrit.opnfv.org/gerrit/barometer +WORKDIR ${repos_dir}/barometer/systems +RUN sh ./build_base_machine.sh + +RUN useradd -ms /bin/bash collectd_exec +RUN echo "collectd_exec ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers + +WORKDIR ${openstack_plugins} +RUN make + +COPY start.sh /opt/ves/start.sh +ENTRYPOINT ["/bin/bash", "/opt/ves/start.sh"] diff --git a/build/ves-barometer/start.sh b/build/ves-barometer/start.sh new file mode 100644 index 0000000..da452bf --- /dev/null +++ b/build/ves-barometer/start.sh @@ -0,0 +1,151 @@ +#!/bin/bash +# Copyright 2018 AT&T Intellectual Property, Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# What this is: Startup script for the OPNFV Barometer collectd agent running +# under docker. + +rm -f /opt/collectd/etc/collectd.conf.d/* + +if [[ "$ves_mode" == "node" ]]; then + cat </opt/collectd/etc/collectd.conf.d/collectd.conf +# for VES plugin +LoadPlugin logfile + + LogLevel debug + File STDOUT + Timestamp true + PrintSeverity false + + +LoadPlugin csv + + DataDir "/work-dir/collectd/install/var/lib/csv" + StoreRates false + + +LoadPlugin target_set +LoadPlugin match_regex + + + + Plugin "^memory$" + + + PluginInstance "host" + + + + +LoadPlugin cpu + + ReportByCpu true + ReportByState true + ValuesPercentage true + + +LoadPlugin interface +LoadPlugin memory +LoadPlugin load +LoadPlugin disk +# TODO: how to set this option only to apply to VMs (not nodes) +LoadPlugin uuid + +LoadPlugin write_kafka + + Property "metadata.broker.list" "$ves_kafka_hostname:$ves_kafka_port" + + Format JSON + + +EOF + + if [[ -d /etc/nova ]]; then + cat <>~/collectd/collectd.conf +LoadPlugin virt + + Connection "qemu:///system" + RefreshInterval 60 + HostnameFormat uuid + PluginInstanceFormat name + ExtraStats "cpu_util" + +EOF + fi +else + cat </opt/collectd/etc/collectd.conf.d/collectd.conf +# for VES plugin +LoadPlugin logfile + + LogLevel debug + File STDOUT + Timestamp true + PrintSeverity false + + +LoadPlugin cpu + + ReportByCpu true + ReportByState true + ValuesPercentage true + + +LoadPlugin csv + + DataDir "/tmp" + + +LoadPlugin interface +LoadPlugin memory +LoadPlugin load +LoadPlugin disk +LoadPlugin uuid + +LoadPlugin write_kafka + + Property "metadata.broker.list" "$ves_kafka_hostname:$ves_kafka_port" + + Format JSON + + + +LoadPlugin target_set +LoadPlugin match_regex + + + + Plugin "^memory$" + + + PluginInstance "guest" + + + +EOF +fi + +echo; echo "cat /opt/collectd/etc/collectd.conf.d/collectd.conf" +cat /opt/collectd/etc/collectd.conf.d/collectd.conf + +#echo "Delete conf files causing collectd to fail" +#rm -f /opt/collectd/etc/collectd.conf.d/dpdk*.conf +#rm -f /opt/collectd/etc/collectd.conf.d/snmp*.conf +#rm -f /opt/collectd/etc/collectd.conf.d/virt.conf +#rm -f /opt/collectd/etc/collectd.conf.d/mcelog.conf +#rm -f /opt/collectd/etc/collectd.conf.d/rdt.conf +#sed -i -- 's/LoadPlugin cpufreq/#LoadPlugin cpufreq/' /opt/collectd/etc/collectd.conf.d/default_plugins.conf + +/opt/collectd/sbin/collectd -f +echo "collectd has exited. sleeping for an hour to enable debugging" +sleep 3600 diff --git a/build/ves-collector.sh b/build/ves-collector.sh index 58aa354..a09eeec 100644 --- a/build/ves-collector.sh +++ b/build/ves-collector.sh @@ -31,10 +31,10 @@ echo; echo "$0 $(date): Update package repos" sudo apt-get update echo; echo "$0 $(date): Starting VES collector build process" -if [[ -d /tmp/ves ]]; then rm -rf /tmp/ves; fi - -echo; echo "$0 $(date): Cloning VES repo to /tmp/ves" -git clone https://gerrit.opnfv.org/gerrit/ves /tmp/ves +if [[ ! -d /tmp/ves ]]; then + echo; echo "$0 $(date): Cloning VES repo to /tmp/ves" + git clone https://gerrit.opnfv.org/gerrit/ves /tmp/ves +fi echo; echo "$0 $(date): Building the image" cd /tmp/ves/build/ves-collector diff --git a/build/ves-collector/Dashboard.json b/build/ves-collector/Dashboard.json new file mode 100644 index 0000000..b88646c --- /dev/null +++ b/build/ves-collector/Dashboard.json @@ -0,0 +1,996 @@ +{ +"dashboard": { + "description": "This Dashboard provides a general overview of a host, with templating to select the hostname.", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "hideControls": false, + "id": null, + "links": [], + "refresh": "10s", + "rows": [ + { + "collapse": false, + "height": 401, + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "VESEvents", + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null + }, + "id": 3, + "interval": "30s", + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "rightSide": false, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "system" + ], + "type": "tag" + } + ], + "measurement": "load", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"cpusystem\") FROM \"cpu\" WHERE $timeFilter GROUP BY time(1m) fill(null)", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load-shortterm" + ], + "type": "field" + }, + { + "params": [ + "5" + ], + "type": "moving_average" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=~", + "value": "/^$host$/" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "host load", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "x-axis": true, + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "y-axis": true, + "y_formats": [ + "short", + "short" + ], + "yaxes": [ + { + "format": "short", + "label": "Percent", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "VESEvents", + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null + }, + "id": 6, + "interval": "30s", + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "rightSide": false, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "system" + ], + "type": "tag" + }, + { + "params": [ + "cpu" + ], + "type": "tag" + } + ], + "measurement": "cpuUsage", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"cpusystem\") FROM \"cpu\" WHERE $timeFilter GROUP BY time(1m) fill(null)", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "cpuUsageUser" + ], + "type": "field" + }, + { + "params": [ + "5" + ], + "type": "moving_average" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=~", + "value": "/^$host$/" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "host CPU Usage User", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "x-axis": true, + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "y-axis": true, + "y_formats": [ + "short", + "short" + ], + "yaxes": [ + { + "format": "short", + "label": "Percent", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + } + ], + "repeat": null, + "repeatIteration": null, + "repeatRowId": null, + "showTitle": false, + "title": "Dashboard Row", + "titleSize": "h6" + }, + { + "collapse": false, + "height": 442, + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "VESEvents", + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null + }, + "id": 2, + "interval": "30s", + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "rightSide": false, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "system" + ], + "type": "tag" + }, + { + "params": [ + "vnic" + ], + "type": "tag" + } + ], + "measurement": "vNicPerformance", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT derivative(mean(\"rxoctetsacc\"), 10s) FROM \"vnic\" WHERE \"system\" = 'computehost' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "receivedTotalPacketsAccumulated" + ], + "type": "field" + }, + { + "params": [ + "5" + ], + "type": "moving_average" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=~", + "value": "/^$host$/" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Received Octets", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "x-axis": true, + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "y-axis": true, + "y_formats": [ + "short", + "short" + ], + "yaxes": [ + { + "format": "short", + "label": "Octets/Packets", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "VESEvents", + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null + }, + "id": 4, + "interval": "30s", + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "rightSide": false, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "system" + ], + "type": "tag" + }, + { + "params": [ + "vnic" + ], + "type": "tag" + } + ], + "measurement": "vNicPerformance", + "orderByTime": "ASC", + "policy": "default", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "receivedOctetsAccumulated" + ], + "type": "field" + }, + { + "params": [ + "5" + ], + "type": "moving_average" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=~", + "value": "/^$host$/" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Transmitted Octets", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "x-axis": true, + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "y-axis": true, + "y_formats": [ + "short", + "short" + ], + "yaxes": [ + { + "format": "short", + "label": "Octets/Packets", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + } + ], + "repeat": null, + "repeatIteration": null, + "repeatRowId": null, + "showTitle": false, + "title": "Dashboard Row", + "titleSize": "h6" + }, + { + "collapse": false, + "height": 362, + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "VESEvents", + "fill": 1, + "id": 7, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "system" + ], + "type": "tag" + }, + { + "params": [ + "disk" + ], + "type": "tag" + } + ], + "measurement": "diskUsage", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "diskOpsWriteLast" + ], + "type": "field" + }, + { + "params": [ + "5" + ], + "type": "moving_average" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=~", + "value": "/^$host$/" + }, + { + "condition": "AND", + "key": "disk", + "operator": "=", + "value": "sda" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Disk Usage SDA", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 10, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "VESEvents", + "fill": 1, + "id": 8, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "span": 6, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "system" + ], + "type": "tag" + }, + { + "params": [ + "disk" + ], + "type": "tag" + } + ], + "measurement": "diskUsage", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "diskOpsWriteLast" + ], + "type": "field" + }, + { + "params": [ + "5" + ], + "type": "moving_average" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=~", + "value": "/^$host$/" + }, + { + "condition": "AND", + "key": "disk", + "operator": "=", + "value": "sdb" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Disk Usage SDB", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 10, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + } + ], + "repeat": null, + "repeatIteration": null, + "repeatRowId": null, + "showTitle": false, + "title": "Dashboard Row", + "titleSize": "h6" + }, + { + "collapse": false, + "height": 250, + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "VESEvents", + "fill": 1, + "id": 5, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "system" + ], + "type": "tag" + } + ], + "measurement": "memoryUsage", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "memoryUsed" + ], + "type": "field" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=~", + "value": "/^$host$/" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Memory", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 10, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + } + ], + "repeat": null, + "repeatIteration": null, + "repeatRowId": null, + "showTitle": false, + "title": "Dashboard Row", + "titleSize": "h6" + } + ], + "schemaVersion": 14, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "allValue": null, + "current": {}, + "datasource": "VESEvents", + "hide": 0, + "includeAll": true, + "label": "host", + "multi": true, + "name": "host", + "options": [], + "query": "SHOW TAG VALUES WITH KEY=system", + "refresh": 1, + "regex": "", + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-30m", + "to": "now" + }, + "timepicker": { + "now": true, + "refresh_intervals": [ + "10s", + "20s", + "30s", + "1m" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "VES Demo", + "version": 4 +} +} diff --git a/build/ves-collector/Dockerfile b/build/ves-collector/Dockerfile index 9161871..4cd135f 100644 --- a/build/ves-collector/Dockerfile +++ b/build/ves-collector/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2017 AT&T Intellectual Property, Inc +# Copyright 2017-2018 AT&T Intellectual Property, Inc # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# What this is: A Dockerfile for building an OPFNV VES Agent container image. +# What this is: A Dockerfile for building an OPFNV VES Collector container image. # # Status: this is a work in progress, under test. # @@ -21,14 +21,9 @@ FROM ubuntu:xenial MAINTAINER Bryan Sullivan -RUN apt-get update -RUN apt-get install -y apt-utils +RUN apt-get update && apt-get install -y apt-utils RUN apt-get -y upgrade -RUN apt-get update -RUN apt-get install -y git - -# Required for VES collector -RUN apt-get install -y python-pip python-jsonschema +RUN apt-get update && apt-get install -y git python-pip python-jsonschema curl RUN pip install requests RUN mkdir /opt/ves @@ -37,5 +32,6 @@ RUN mkdir /opt/ves RUN git clone https://github.com/att/evel-test-collector.git /opt/ves/evel-test-collector COPY monitor.py /opt/ves/evel-test-collector/code/collector/monitor.py +COPY Dashboard.json /opt/ves/Dashboard.json COPY start.sh /opt/ves/start.sh ENTRYPOINT ["/bin/bash", "/opt/ves/start.sh"] diff --git a/build/ves-collector/start.sh b/build/ves-collector/start.sh index be30c9a..250af34 100644 --- a/build/ves-collector/start.sh +++ b/build/ves-collector/start.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2017 AT&T Intellectual Property, Inc +# Copyright 2017-2018 AT&T Intellectual Property, Inc # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,6 +23,8 @@ sed -i -- \ evel-test-collector/config/collector.conf sed -i -- "s/vel_domain = 127.0.0.1/vel_domain = $ves_host/g" \ evel-test-collector/config/collector.conf +sed -i -- "s/vel_port = 30000/vel_port = $ves_port/g" \ + evel-test-collector/config/collector.conf sed -i -- "s/vel_username =/vel_username = $ves_user/g" \ evel-test-collector/config/collector.conf sed -i -- "s/vel_password =/vel_password = $ves_pass/g" \ @@ -31,18 +33,65 @@ sed -i -- "s~vel_path = vendor_event_listener/~vel_path = $ves_path~g" \ evel-test-collector/config/collector.conf sed -i -- "s~vel_topic_name = example_vnf~vel_topic_name = $ves_topic~g" \ evel-test-collector/config/collector.conf -sed -i -- "/vel_topic_name = /a influxdb = $ves_influxdb_host" \ +sed -i -- "/vel_topic_name = /a influxdb = $ves_influxdb_host:$ves_influxdb_port" \ evel-test-collector/config/collector.conf +echo; echo "evel-test-collector/config/collector.conf" +cat evel-test-collector/config/collector.conf + +echo; echo "wait for InfluxDB API at $ves_influxdb_host:$ves_influxdb_port" +while ! curl http://$ves_influxdb_host:$ves_influxdb_port/ping ; do + echo "InfluxDB API is not yet responding... waiting 10 seconds" + sleep 10 +done + +echo; echo "setup veseventsdb in InfluxDB" +# TODO: check if pre-existing and skip +curl -X POST http://$ves_influxdb_host:$ves_influxdb_port/query \ + --data-urlencode "q=CREATE DATABASE veseventsdb" + +echo; echo "wait for Grafana API to be active" +while ! curl http://$ves_grafana_host:$ves_grafana_port ; do + echo "Grafana API is not yet responding... waiting 10 seconds" + sleep 10 +done + +echo; echo "add VESEvents datasource to Grafana" +# TODO: check if pre-existing and skip +cat </opt/ves/datasource.json +{ "name":"VESEvents", + "type":"influxdb", + "access":"direct", + "url":"http://$ves_influxdb_host:$ves_influxdb_port", + "password":"root", + "user":"root", + "database":"veseventsdb", + "basicAuth":false, + "basicAuthUser":"", + "basicAuthPassword":"", + "withCredentials":false, + "isDefault":false, + "jsonData":null +} +EOF + +curl -H "Accept: application/json" -H "Content-type: application/json" \ + -X POST -d @/opt/ves/datasource.json \ + http://$ves_grafana_auth@$ves_grafana_host:$ves_grafana_port/api/datasources + +echo; echo "add VES dashboard to Grafana" +curl -H "Accept: application/json" -H "Content-type: application/json" \ + -X POST -d @/opt/ves/Dashboard.json \ + http://$ves_grafana_auth@$ves_grafana_host:$ves_grafana_port/api/dashboards/db + if [[ "$ves_loglevel" != "" ]]; then python /opt/ves/evel-test-collector/code/collector/monitor.py \ --config /opt/ves/evel-test-collector/config/collector.conf \ - --influxdb $ves_influxdb_host \ + --influxdb $ves_influxdb_host:$ves_influxdb_port \ --section default > /opt/ves/monitor.log 2>&1 else python /opt/ves/evel-test-collector/code/collector/monitor.py \ --config /opt/ves/evel-test-collector/config/collector.conf \ - --influxdb $ves_influxdb_host \ + --influxdb $ves_influxdb_host:$ves_influxdb_port \ --section default fi - diff --git a/build/ves-kafka.sh b/build/ves-kafka.sh index 19a632b..c489535 100644 --- a/build/ves-kafka.sh +++ b/build/ves-kafka.sh @@ -19,7 +19,7 @@ #. Docker hub user logged in e.g. via "sudo docker login" #. #. Usage: -#. bash ves-kafka.sh +#. bash ves-kafka.sh #. hub-user: username for dockerhub #. #. NOTE: To allow patch testing, this script will not reclone the VES repo diff --git a/build/ves-kafka/start.sh b/build/ves-kafka/start.sh index ab4169b..37c36c2 100644 --- a/build/ves-kafka/start.sh +++ b/build/ves-kafka/start.sh @@ -16,14 +16,14 @@ #. What this is: Startup script for a kafka server as used by the OPNFV VES #. framework. -echo "$zookeeper $zookeeper_host" >>/etc/hosts +echo "$zookeeper_host $zookeeper_hostname" >>/etc/hosts cat /etc/hosts cd /opt/ves -sed -i "s/localhost:2181/$zookeeper_host:2181/" \ +sed -i "s/localhost:2181/$zookeeper_hostname:$zookeeper_port/" \ kafka_2.11-0.11.0.2/config/server.properties grep 2181 kafka_2.11-0.11.0.2/config/server.properties -sed -i "s~#advertised.listeners=PLAINTEXT://your.host.name:9092~advertised.listeners=PLAINTEXT://$kafka_hostname:9092~" \ +sed -i "s~#advertised.listeners=PLAINTEXT://your.host.name:9092~advertised.listeners=PLAINTEXT://$kafka_hostname:$kafka_port~" \ kafka_2.11-0.11.0.2/config/server.properties grep advertised.listeners kafka_2.11-0.11.0.2/config/server.properties diff --git a/tools/cloudify/ves-agent/blueprint.yaml b/tools/cloudify/ves-agent/blueprint.yaml index f7ef0a9..dc2f977 100644 --- a/tools/cloudify/ves-agent/blueprint.yaml +++ b/tools/cloudify/ves-agent/blueprint.yaml @@ -52,6 +52,11 @@ inputs: ves_loglevel: default: info + spec_port: + default: 80 + container_port: + default: 80 + kubernetes_configuration_file_content: default: kube.config @@ -114,6 +119,8 @@ node_templates: metadata: name: ves-agent-service spec: + ports: + - port: { get_input: spec_port } selector: app: ves-agent relationships: @@ -164,6 +171,8 @@ node_templates: value: { get_input: ves_mode } - name: ves_loglevel value: { get_input: ves_loglevel } + ports: + - containerPort: { get_input: container_port } relationships: - type: cloudify.kubernetes.relationships.managed_by_master target: kubernetes_master diff --git a/tools/cloudify/ves-collector/blueprint.yaml b/tools/cloudify/ves-collector/blueprint.yaml new file mode 100644 index 0000000..7c4a051 --- /dev/null +++ b/tools/cloudify/ves-collector/blueprint.yaml @@ -0,0 +1,183 @@ +tosca_definitions_version: cloudify_dsl_1_3 +# +# Copyright 2018 AT&T Intellectual Property, Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# What this is: Cloudify blueprint for running the OPNFV VES Collector under +# kubernetes. + +imports: + - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml + - https://raw.githubusercontent.com/cloudify-incubator/cloudify-kubernetes-plugin/1.2.1/plugin.yaml + +inputs: + + ves_host: + default: 127.0.0.1 + ves_port: + default: 3001 + ves_path: + default: + ves_topic: + default: + ves_https: + default: false + ves_user: + default: + ves_pass: + default: + ves_interval: + default: 20 + ves_version: + default: 5.1 + ves_loglevel: + default: info + ves_influxdb_host: + default: 127.0.0.1 + ves_influxdb_port: + default: 8086 + ves_grafana_host: + default: 127.0.0.1 + ves_grafana_port: + default: 3000 + ves_grafana_auth: + default: admin:admin + spec_port: + default: 3001 + container_port: + default: 3001 + + kubernetes_configuration_file_content: + default: kube.config + + kubernetes_master_ip: + type: string + default: { get_secret: kubernetes_master_ip } + + kubernetes_master_port: + type: string + default: { get_secret: kubernetes_master_port } + + kubernetes_certificate_authority_data: + default: { get_secret: kubernetes_certificate_authority_data } + + kubernetes-admin_client_certificate_data: + default: { get_secret: kubernetes-admin_client_certificate_data } + + kubernetes-admin_client_key_data: + default: { get_secret: kubernetes-admin_client_key_data } + + kubernetes_master_configuration: + default: + apiVersion: v1 + kind: Config + preferences: {} + current-context: kubernetes-admin@kubernetes + clusters: + - name: kubernetes + cluster: + certificate-authority-data: { get_input: kubernetes_certificate_authority_data } + server: { concat: [ 'https://', { get_input: kubernetes_master_ip}, ':', { get_input: kubernetes_master_port } ] } + contexts: + - name: kubernetes-admin@kubernetes + context: + cluster: kubernetes + user: kubernetes-admin + users: + - name: kubernetes-admin + user: + client-certificate-data: { get_input: kubernetes-admin_client_certificate_data } + client-key-data: { get_input: kubernetes-admin_client_key_data } + + kubernetes_configuration_file_content: + description: > + File content of kubernetes master YAML configuration + default: { get_input: kubernetes_master_configuration } + +node_templates: + kubernetes_master: + type: cloudify.kubernetes.nodes.Master + properties: + configuration: + file_content: { get_input: kubernetes_configuration_file_content } + + ves_collector_service: + type: cloudify.kubernetes.resources.Service + properties: + definition: + apiVersion: v1 + metadata: + name: ves-collector-service + spec: + ports: + - port: { get_input: spec_port } + selector: + app: ves-collector + relationships: + - type: cloudify.kubernetes.relationships.managed_by_master + target: kubernetes_master + - type: cloudify.relationships.depends_on + target: ves_collector_pod + + ves_collector_pod: + type: cloudify.kubernetes.resources.Pod + properties: + definition: + apiVersion: v1 + metadata: + name: ves-collector-pod + labels: + app: ves-collector + spec: + nodeSelector: + role: worker + containers: + - name: ves-collector + image: blsaws/ves-collector:latest + env: + - name: ves_host + value: { get_input: ves_host } + - name: ves_port + value: { get_input: ves_port } + - name: ves_path + value: { get_input: ves_path } + - name: ves_topic + value: { get_input: ves_topic } + - name: ves_https + value: { get_input: ves_https } + - name: ves_user + value: { get_input: ves_user } + - name: ves_pass + value: { get_input: ves_pass } + - name: ves_interval + value: { get_input: ves_interval } + - name: ves_version + value: { get_input: ves_version } + - name: ves_loglevel + value: { get_input: ves_loglevel } + - name: ves_influxdb_host + value: { get_input: ves_influxdb_host } + - name: ves_influxdb_port + value: { get_input: ves_influxdb_port } + - name: ves_grafana_host + value: { get_input: ves_grafana_host } + - name: ves_grafana_port + value: { get_input: ves_grafana_port } + - name: ves_grafana_auth + value: { get_input: ves_grafana_auth } + ports: + - containerPort: { get_input: container_port } + relationships: + - type: cloudify.kubernetes.relationships.managed_by_master + target: kubernetes_master diff --git a/tools/cloudify/ves-grafana/blueprint.yaml b/tools/cloudify/ves-grafana/blueprint.yaml new file mode 100644 index 0000000..00963b3 --- /dev/null +++ b/tools/cloudify/ves-grafana/blueprint.yaml @@ -0,0 +1,123 @@ +tosca_definitions_version: cloudify_dsl_1_3 +# +# Copyright 2018 AT&T Intellectual Property, Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# What this is: Cloudify blueprint for running a grafana service for OPNFV VES +# under kubernetes. + +imports: + - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml + - https://raw.githubusercontent.com/cloudify-incubator/cloudify-kubernetes-plugin/1.2.1/plugin.yaml + +inputs: + + spec_port: + default: 3000 + + container_port: + default: 3000 + + kubernetes_configuration_file_content: + default: kube.config + + kubernetes_master_ip: + type: string + default: { get_secret: kubernetes_master_ip } + + kubernetes_master_port: + type: string + default: { get_secret: kubernetes_master_port } + + kubernetes_certificate_authority_data: + default: { get_secret: kubernetes_certificate_authority_data } + + kubernetes-admin_client_certificate_data: + default: { get_secret: kubernetes-admin_client_certificate_data } + + kubernetes-admin_client_key_data: + default: { get_secret: kubernetes-admin_client_key_data } + + kubernetes_master_configuration: + default: + apiVersion: v1 + kind: Config + preferences: {} + current-context: kubernetes-admin@kubernetes + clusters: + - name: kubernetes + cluster: + certificate-authority-data: { get_input: kubernetes_certificate_authority_data } + server: { concat: [ 'https://', { get_input: kubernetes_master_ip}, ':', { get_input: kubernetes_master_port } ] } + contexts: + - name: kubernetes-admin@kubernetes + context: + cluster: kubernetes + user: kubernetes-admin + users: + - name: kubernetes-admin + user: + client-certificate-data: { get_input: kubernetes-admin_client_certificate_data } + client-key-data: { get_input: kubernetes-admin_client_key_data } + + kubernetes_configuration_file_content: + description: > + File content of kubernetes master YAML configuration + default: { get_input: kubernetes_master_configuration } + +node_templates: + kubernetes_master: + type: cloudify.kubernetes.nodes.Master + properties: + configuration: + file_content: { get_input: kubernetes_configuration_file_content } + + ves_grafana_service: + type: cloudify.kubernetes.resources.Service + properties: + definition: + apiVersion: v1 + metadata: + name: ves-grafana-service + spec: + type: NodePort + ports: + - port: { get_input: spec_port } + selector: + app: ves-grafana + relationships: + - type: cloudify.kubernetes.relationships.managed_by_master + target: kubernetes_master + - type: cloudify.relationships.depends_on + target: ves_grafana_pod + + ves_grafana_pod: + type: cloudify.kubernetes.resources.Pod + properties: + definition: + apiVersion: v1 + metadata: + name: ves-grafana-pod + labels: + app: ves-grafana + spec: + containers: + - name: ves-grafana + image: grafana/grafana + env: + ports: + - containerPort: { get_input: container_port } + relationships: + - type: cloudify.kubernetes.relationships.managed_by_master + target: kubernetes_master diff --git a/tools/cloudify/ves-influxdb/blueprint.yaml b/tools/cloudify/ves-influxdb/blueprint.yaml new file mode 100644 index 0000000..d0a400b --- /dev/null +++ b/tools/cloudify/ves-influxdb/blueprint.yaml @@ -0,0 +1,122 @@ +tosca_definitions_version: cloudify_dsl_1_3 +# +# Copyright 2018 AT&T Intellectual Property, Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# What this is: Cloudify blueprint for running a influxdb service for OPNFV VES +# under kubernetes. + +imports: + - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml + - https://raw.githubusercontent.com/cloudify-incubator/cloudify-kubernetes-plugin/1.2.1/plugin.yaml + +inputs: + + spec_port: + default: 8086 + + container_port: + default: 8086 + + kubernetes_configuration_file_content: + default: kube.config + + kubernetes_master_ip: + type: string + default: { get_secret: kubernetes_master_ip } + + kubernetes_master_port: + type: string + default: { get_secret: kubernetes_master_port } + + kubernetes_certificate_authority_data: + default: { get_secret: kubernetes_certificate_authority_data } + + kubernetes-admin_client_certificate_data: + default: { get_secret: kubernetes-admin_client_certificate_data } + + kubernetes-admin_client_key_data: + default: { get_secret: kubernetes-admin_client_key_data } + + kubernetes_master_configuration: + default: + apiVersion: v1 + kind: Config + preferences: {} + current-context: kubernetes-admin@kubernetes + clusters: + - name: kubernetes + cluster: + certificate-authority-data: { get_input: kubernetes_certificate_authority_data } + server: { concat: [ 'https://', { get_input: kubernetes_master_ip}, ':', { get_input: kubernetes_master_port } ] } + contexts: + - name: kubernetes-admin@kubernetes + context: + cluster: kubernetes + user: kubernetes-admin + users: + - name: kubernetes-admin + user: + client-certificate-data: { get_input: kubernetes-admin_client_certificate_data } + client-key-data: { get_input: kubernetes-admin_client_key_data } + + kubernetes_configuration_file_content: + description: > + File content of kubernetes master YAML configuration + default: { get_input: kubernetes_master_configuration } + +node_templates: + kubernetes_master: + type: cloudify.kubernetes.nodes.Master + properties: + configuration: + file_content: { get_input: kubernetes_configuration_file_content } + + ves_influxdb_service: + type: cloudify.kubernetes.resources.Service + properties: + definition: + apiVersion: v1 + metadata: + name: ves-influxdb-service + spec: + ports: + - port: { get_input: spec_port } + selector: + app: ves-influxdb + relationships: + - type: cloudify.kubernetes.relationships.managed_by_master + target: kubernetes_master + - type: cloudify.relationships.depends_on + target: ves_influxdb_pod + + ves_influxdb_pod: + type: cloudify.kubernetes.resources.Pod + properties: + definition: + apiVersion: v1 + metadata: + name: ves-influxdb-pod + labels: + app: ves-influxdb + spec: + containers: + - name: ves-influxdb + image: influxdb + env: + ports: + - containerPort: { get_input: container_port } + relationships: + - type: cloudify.kubernetes.relationships.managed_by_master + target: kubernetes_master diff --git a/tools/cloudify/ves-kafka/blueprint.yaml b/tools/cloudify/ves-kafka/blueprint.yaml new file mode 100644 index 0000000..45f4378 --- /dev/null +++ b/tools/cloudify/ves-kafka/blueprint.yaml @@ -0,0 +1,142 @@ +tosca_definitions_version: cloudify_dsl_1_3 +# +# Copyright 2018 AT&T Intellectual Property, Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# What this is: Cloudify blueprint for running a Kafka service for OPNFV VES +# under kubernetes. + +imports: + - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml + - https://raw.githubusercontent.com/cloudify-incubator/cloudify-kubernetes-plugin/1.2.1/plugin.yaml + +inputs: + + zookeeper_hostname: + default: localhost + zookeeper_host: + default: 127.0.0.1 + zookeeper_port: + default: 2181 + kafka_hostname: + default: localhost + kafka_port: + default: 9092 + spec_port: + default: 9092 + container_port: + default: 9092 + + kubernetes_configuration_file_content: + default: kube.config + + kubernetes_master_ip: + type: string + default: { get_secret: kubernetes_master_ip } + + kubernetes_master_port: + type: string + default: { get_secret: kubernetes_master_port } + + kubernetes_certificate_authority_data: + default: { get_secret: kubernetes_certificate_authority_data } + + kubernetes-admin_client_certificate_data: + default: { get_secret: kubernetes-admin_client_certificate_data } + + kubernetes-admin_client_key_data: + default: { get_secret: kubernetes-admin_client_key_data } + + kubernetes_master_configuration: + default: + apiVersion: v1 + kind: Config + preferences: {} + current-context: kubernetes-admin@kubernetes + clusters: + - name: kubernetes + cluster: + certificate-authority-data: { get_input: kubernetes_certificate_authority_data } + server: { concat: [ 'https://', { get_input: kubernetes_master_ip}, ':', { get_input: kubernetes_master_port } ] } + contexts: + - name: kubernetes-admin@kubernetes + context: + cluster: kubernetes + user: kubernetes-admin + users: + - name: kubernetes-admin + user: + client-certificate-data: { get_input: kubernetes-admin_client_certificate_data } + client-key-data: { get_input: kubernetes-admin_client_key_data } + + kubernetes_configuration_file_content: + description: > + File content of kubernetes master YAML configuration + default: { get_input: kubernetes_master_configuration } + +node_templates: + kubernetes_master: + type: cloudify.kubernetes.nodes.Master + properties: + configuration: + file_content: { get_input: kubernetes_configuration_file_content } + + ves_kafka_service: + type: cloudify.kubernetes.resources.Service + properties: + definition: + apiVersion: v1 + metadata: + name: ves-kafka-service + spec: + ports: + - port: { get_input: spec_port } + targetPort: { get_input: spec_port } + selector: + app: ves-kafka + relationships: + - type: cloudify.kubernetes.relationships.managed_by_master + target: kubernetes_master + - type: cloudify.relationships.depends_on + target: ves_kafka_pod + + ves_kafka_pod: + type: cloudify.kubernetes.resources.Pod + properties: + definition: + apiVersion: v1 + metadata: + name: ves-kafka-pod + labels: + app: ves-kafka + spec: + containers: + - name: ves-kafka + image: blsaws/ves-kafka:latest + env: + - name: zookeeper_hostname + value: { get_input: zookeeper_hostname } + - name: zookeeper_host + value: { get_input: zookeeper_host } + - name: zookeeper_port + value: { get_input: zookeeper_port } + - name: kafka_hostname + value: { get_input: kafka_hostname } + - name: kafka_port + value: { get_input: kafka_port } + ports: + - containerPort: { get_input: container_port } + relationships: + - type: cloudify.kubernetes.relationships.managed_by_master + target: kubernetes_master diff --git a/tools/cloudify/ves-zookeeper/blueprint.yaml b/tools/cloudify/ves-zookeeper/blueprint.yaml new file mode 100644 index 0000000..8e22ed3 --- /dev/null +++ b/tools/cloudify/ves-zookeeper/blueprint.yaml @@ -0,0 +1,122 @@ +tosca_definitions_version: cloudify_dsl_1_3 +# +# Copyright 2018 AT&T Intellectual Property, Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# What this is: Cloudify blueprint for running a zookeeper service for OPNFV VES +# under kubernetes. + +imports: + - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml + - https://raw.githubusercontent.com/cloudify-incubator/cloudify-kubernetes-plugin/1.2.1/plugin.yaml + +inputs: + + spec_port: + default: 2181 + + container_port: + default: 2181 + + kubernetes_configuration_file_content: + default: kube.config + + kubernetes_master_ip: + type: string + default: { get_secret: kubernetes_master_ip } + + kubernetes_master_port: + type: string + default: { get_secret: kubernetes_master_port } + + kubernetes_certificate_authority_data: + default: { get_secret: kubernetes_certificate_authority_data } + + kubernetes-admin_client_certificate_data: + default: { get_secret: kubernetes-admin_client_certificate_data } + + kubernetes-admin_client_key_data: + default: { get_secret: kubernetes-admin_client_key_data } + + kubernetes_master_configuration: + default: + apiVersion: v1 + kind: Config + preferences: {} + current-context: kubernetes-admin@kubernetes + clusters: + - name: kubernetes + cluster: + certificate-authority-data: { get_input: kubernetes_certificate_authority_data } + server: { concat: [ 'https://', { get_input: kubernetes_master_ip}, ':', { get_input: kubernetes_master_port } ] } + contexts: + - name: kubernetes-admin@kubernetes + context: + cluster: kubernetes + user: kubernetes-admin + users: + - name: kubernetes-admin + user: + client-certificate-data: { get_input: kubernetes-admin_client_certificate_data } + client-key-data: { get_input: kubernetes-admin_client_key_data } + + kubernetes_configuration_file_content: + description: > + File content of kubernetes master YAML configuration + default: { get_input: kubernetes_master_configuration } + +node_templates: + kubernetes_master: + type: cloudify.kubernetes.nodes.Master + properties: + configuration: + file_content: { get_input: kubernetes_configuration_file_content } + + ves_zookeeper_service: + type: cloudify.kubernetes.resources.Service + properties: + definition: + apiVersion: v1 + metadata: + name: ves-zookeeper-service + spec: + ports: + - port: { get_input: spec_port } + selector: + app: ves-zookeeper + relationships: + - type: cloudify.kubernetes.relationships.managed_by_master + target: kubernetes_master + - type: cloudify.relationships.depends_on + target: ves_zookeeper_pod + + ves_zookeeper_pod: + type: cloudify.kubernetes.resources.Pod + properties: + definition: + apiVersion: v1 + metadata: + name: ves-zookeeper-pod + labels: + app: ves-zookeeper + spec: + containers: + - name: ves-zookeeper + image: zookeeper + env: + ports: + - containerPort: { get_input: container_port } + relationships: + - type: cloudify.kubernetes.relationships.managed_by_master + target: kubernetes_master diff --git a/tools/demo_deploy.sh b/tools/demo_deploy.sh index 305de9c..1105c2a 100644 --- a/tools/demo_deploy.sh +++ b/tools/demo_deploy.sh @@ -35,9 +35,17 @@ #. - env variables set prior to running this script, as per ves-setup.sh #. ves_kafka_hostname: hostname of the node where the kafka server runs #. - optional env varibles set prior to running this script, as per ves-setup.sh -#. ves_influxdb_host: ip:port of the influxdb service +#. ves_host: ip of the VES collector service +#. ves_zookeeper_host: ip of the zookeeper service +#. ves_zookeeper_port: port of the zookeeper service +#. ves_kafka_host: ip of the kafka service +#. ves_kafka_port: port of the kafka service +#. ves_port: port of the VES collector service +#. ves_influxdb_host: ip of the influxdb service +#. ves_influxdb_port: port of the influxdb service #. ves_influxdb_auth: authentication for the influxdb service -#. ves_grafana_host: ip:port of the grafana service +#. ves_grafana_host: ip of the grafana service +#. ves_grafana_port: port of the grafana service #. ves_grafana_auth: authentication for the grafana service #. ves_loglevel: loglevel for VES Agent and Collector (ERROR|DEBUG) #. @@ -49,81 +57,104 @@ #. Usage: on the admin server #. $ git clone https://gerrit.opnfv.org/gerrit/ves ~/ves #. $ cd ~/ves/tools -#. $ bash demo_deploy.sh [cloudify] -#. : SSH key enabling password-less SSH to nodes +#. $ bash demo_deploy.sh [cloudify] #. : username on node with password-less SSH authorized -#. : master node where core components will be installed -#. : list of worker nodes where collectd will be installed +#. : hostname of k8s master node #. cloudify: flag indicating to deploy VES core services via Cloudify -key=$1 -user=$2 -master=$3 -workers="$4" -cloudify=$5 +trap 'fail' ERR -eval `ssh-agent` -ssh-add $key +function fail() { + log $1 + exit 1 +} -ves_host=$master -ves_mode=node -ves_user=hello -ves_pass=world -ves_kafka_host=$master -ves_kafka_hostname=$ves_kafka_hostname -ves_influxdb_host=$ves_influxdb_host -ves_influxdb_auth=$ves_influxdb_auth -ves_grafana_host=$ves_grafana_host -ves_grafana_auth=$ves_grafana_auth -ves_loglevel=$ves_loglevel -env | grep ves -source ~/ves/tools/ves-setup.sh env +function log() { + f=$(caller 0 | awk '{print $2}') + l=$(caller 0 | awk '{print $1}') + echo; echo "$f:$l ($(date)) $1" +} -echo; echo "$0 $(date): Setting up master node" -ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ - $user@$master mkdir /home/$user/ves -scp -r -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ - ~/ves/tools $user@$master:/home/$user/ves -ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ - $user@$master <~/ves/tools/ves_env.sh + for var in $vars; do echo "export $var" | tee -a ~/ves/tools/ves_env.sh; done -if [[ "$master" == "$workers" ]]; then - nodes=$master -else - nodes="$master $workers" -fi + log "Setting up master node" + run_master "mkdir /home/$user/ves" + scp -r -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ + ~/ves/tools $user@$master:/home/$user/ves + run "bash ves/tools/ves-setup.sh collector $cloudify" + run "bash ves/tools/ves-setup.sh kafka $cloudify" + run "bash ves/tools/ves-setup.sh agent $cloudify" -for node in $nodes; do - echo; echo "$0 $(date): Setting up collectd at $node" - if [[ "$node" != "$master" ]]; then - ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ - $user@$node mkdir /home/$user/ves - scp -r -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ - ~/ves/tools $user@$node:/home/$user/ves + if [[ "$k8s_master" == "$k8s_workers" ]]; then + nodes=$k8s_master + else + nodes="$k8s_master $k8s_workers" fi - ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ - $user@$node < ves-collectd-$node.log 2>&1 & -ves_kafka_host=$master -export ves_kafka_host -ves_kafka_port=$ves_kafka_port -export ves_kafka_port -ves_kafka_hostname=$ves_kafka_hostname -export ves_kafka_hostname -ves_mode=node -export ves_mode -bash /home/$user/ves/tools/ves-setup.sh collectd + + for node in $nodes; do + log "Setting up collectd at $node" + if [[ "$node" != "$k8s_master" ]]; then + ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ + $user@$node mkdir /home/$user/ves + scp -r -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ + ~/ves/tools $user@$node:/home/$user/ves + fi + run "bash ves/tools/ves-setup.sh collectd" EOF -done + done -echo; echo "$0 $(date): VES Grafana dashboards are available at http://$ves_grafana_host (login as admin/admin)" + source ~/ves/tools/ves_env.sh + log "VES Grafana dashboards are available at http://$ves_grafana_host:$ves_grafana_port (login as admin/admin)" +} +deploy_start=$((`date +%s`/60)) +user=$1 +master=$2 +cloudify=$3 +source ~/k8s_env_$master.sh +log "k8s environment as input" +env | grep k8s +eval `ssh-agent` +ssh-add $k8s_key +deploy diff --git a/tools/grafana/Dashboard.json b/tools/grafana/Dashboard.json deleted file mode 100644 index b88646c..0000000 --- a/tools/grafana/Dashboard.json +++ /dev/null @@ -1,996 +0,0 @@ -{ -"dashboard": { - "description": "This Dashboard provides a general overview of a host, with templating to select the hostname.", - "editable": true, - "gnetId": null, - "graphTooltip": 0, - "hideControls": false, - "id": null, - "links": [], - "refresh": "10s", - "rows": [ - { - "collapse": false, - "height": 401, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "VESEvents", - "fill": 1, - "grid": { - "leftLogBase": 1, - "leftMax": null, - "leftMin": null, - "rightLogBase": 1, - "rightMax": null, - "rightMin": null - }, - "id": 3, - "interval": "30s", - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "sort": "current", - "sortDesc": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "", - "dsType": "influxdb", - "groupBy": [ - { - "params": [ - "system" - ], - "type": "tag" - } - ], - "measurement": "load", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT mean(\"cpusystem\") FROM \"cpu\" WHERE $timeFilter GROUP BY time(1m) fill(null)", - "refId": "B", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "load-shortterm" - ], - "type": "field" - }, - { - "params": [ - "5" - ], - "type": "moving_average" - } - ] - ], - "tags": [ - { - "key": "system", - "operator": "=~", - "value": "/^$host$/" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "host load", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "x-axis": true, - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "y-axis": true, - "y_formats": [ - "short", - "short" - ], - "yaxes": [ - { - "format": "short", - "label": "Percent", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "VESEvents", - "fill": 1, - "grid": { - "leftLogBase": 1, - "leftMax": null, - "leftMin": null, - "rightLogBase": 1, - "rightMax": null, - "rightMin": null - }, - "id": 6, - "interval": "30s", - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "sort": "current", - "sortDesc": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "", - "dsType": "influxdb", - "groupBy": [ - { - "params": [ - "system" - ], - "type": "tag" - }, - { - "params": [ - "cpu" - ], - "type": "tag" - } - ], - "measurement": "cpuUsage", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT mean(\"cpusystem\") FROM \"cpu\" WHERE $timeFilter GROUP BY time(1m) fill(null)", - "refId": "B", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "cpuUsageUser" - ], - "type": "field" - }, - { - "params": [ - "5" - ], - "type": "moving_average" - } - ] - ], - "tags": [ - { - "key": "system", - "operator": "=~", - "value": "/^$host$/" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "host CPU Usage User", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "x-axis": true, - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "y-axis": true, - "y_formats": [ - "short", - "short" - ], - "yaxes": [ - { - "format": "short", - "label": "Percent", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - } - ], - "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": false, - "title": "Dashboard Row", - "titleSize": "h6" - }, - { - "collapse": false, - "height": 442, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "VESEvents", - "fill": 1, - "grid": { - "leftLogBase": 1, - "leftMax": null, - "leftMin": null, - "rightLogBase": 1, - "rightMax": null, - "rightMin": null - }, - "id": 2, - "interval": "30s", - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "sort": "current", - "sortDesc": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "", - "dsType": "influxdb", - "groupBy": [ - { - "params": [ - "system" - ], - "type": "tag" - }, - { - "params": [ - "vnic" - ], - "type": "tag" - } - ], - "measurement": "vNicPerformance", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT derivative(mean(\"rxoctetsacc\"), 10s) FROM \"vnic\" WHERE \"system\" = 'computehost' AND $timeFilter GROUP BY time(1m) fill(null)", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "receivedTotalPacketsAccumulated" - ], - "type": "field" - }, - { - "params": [ - "5" - ], - "type": "moving_average" - } - ] - ], - "tags": [ - { - "key": "system", - "operator": "=~", - "value": "/^$host$/" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Received Octets", - "tooltip": { - "shared": true, - "sort": 2, - "value_type": "individual" - }, - "type": "graph", - "x-axis": true, - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "y-axis": true, - "y_formats": [ - "short", - "short" - ], - "yaxes": [ - { - "format": "short", - "label": "Octets/Packets", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "VESEvents", - "fill": 1, - "grid": { - "leftLogBase": 1, - "leftMax": null, - "leftMin": null, - "rightLogBase": 1, - "rightMax": null, - "rightMin": null - }, - "id": 4, - "interval": "30s", - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "sort": "current", - "sortDesc": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "", - "dsType": "influxdb", - "groupBy": [ - { - "params": [ - "system" - ], - "type": "tag" - }, - { - "params": [ - "vnic" - ], - "type": "tag" - } - ], - "measurement": "vNicPerformance", - "orderByTime": "ASC", - "policy": "default", - "refId": "B", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "receivedOctetsAccumulated" - ], - "type": "field" - }, - { - "params": [ - "5" - ], - "type": "moving_average" - } - ] - ], - "tags": [ - { - "key": "system", - "operator": "=~", - "value": "/^$host$/" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Transmitted Octets", - "tooltip": { - "shared": true, - "sort": 2, - "value_type": "individual" - }, - "type": "graph", - "x-axis": true, - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "y-axis": true, - "y_formats": [ - "short", - "short" - ], - "yaxes": [ - { - "format": "short", - "label": "Octets/Packets", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - } - ], - "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": false, - "title": "Dashboard Row", - "titleSize": "h6" - }, - { - "collapse": false, - "height": 362, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "VESEvents", - "fill": 1, - "id": 7, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "sort": "current", - "sortDesc": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "", - "dsType": "influxdb", - "groupBy": [ - { - "params": [ - "system" - ], - "type": "tag" - }, - { - "params": [ - "disk" - ], - "type": "tag" - } - ], - "measurement": "diskUsage", - "orderByTime": "ASC", - "policy": "autogen", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "diskOpsWriteLast" - ], - "type": "field" - }, - { - "params": [ - "5" - ], - "type": "moving_average" - } - ] - ], - "tags": [ - { - "key": "system", - "operator": "=~", - "value": "/^$host$/" - }, - { - "condition": "AND", - "key": "disk", - "operator": "=", - "value": "sda" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Disk Usage SDA", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 10, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "VESEvents", - "fill": 1, - "id": 8, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "sort": "current", - "sortDesc": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "", - "dsType": "influxdb", - "groupBy": [ - { - "params": [ - "system" - ], - "type": "tag" - }, - { - "params": [ - "disk" - ], - "type": "tag" - } - ], - "measurement": "diskUsage", - "orderByTime": "ASC", - "policy": "autogen", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "diskOpsWriteLast" - ], - "type": "field" - }, - { - "params": [ - "5" - ], - "type": "moving_average" - } - ] - ], - "tags": [ - { - "key": "system", - "operator": "=~", - "value": "/^$host$/" - }, - { - "condition": "AND", - "key": "disk", - "operator": "=", - "value": "sdb" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Disk Usage SDB", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 10, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - } - ], - "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": false, - "title": "Dashboard Row", - "titleSize": "h6" - }, - { - "collapse": false, - "height": 250, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "VESEvents", - "fill": 1, - "id": 5, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "sort": "current", - "sortDesc": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "span": 12, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "", - "dsType": "influxdb", - "groupBy": [ - { - "params": [ - "system" - ], - "type": "tag" - } - ], - "measurement": "memoryUsage", - "orderByTime": "ASC", - "policy": "autogen", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "memoryUsed" - ], - "type": "field" - } - ] - ], - "tags": [ - { - "key": "system", - "operator": "=~", - "value": "/^$host$/" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Memory", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 10, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - } - ], - "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": false, - "title": "Dashboard Row", - "titleSize": "h6" - } - ], - "schemaVersion": 14, - "style": "dark", - "tags": [], - "templating": { - "list": [ - { - "allValue": null, - "current": {}, - "datasource": "VESEvents", - "hide": 0, - "includeAll": true, - "label": "host", - "multi": true, - "name": "host", - "options": [], - "query": "SHOW TAG VALUES WITH KEY=system", - "refresh": 1, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false - } - ] - }, - "time": { - "from": "now-30m", - "to": "now" - }, - "timepicker": { - "now": true, - "refresh_intervals": [ - "10s", - "20s", - "30s", - "1m" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "timezone": "browser", - "title": "VES Demo", - "version": 4 -} -} diff --git a/tools/kubernetes/ves-barometer/daemonset.yaml b/tools/kubernetes/ves-barometer/daemonset.yaml new file mode 100644 index 0000000..d0d6d19 --- /dev/null +++ b/tools/kubernetes/ves-barometer/daemonset.yaml @@ -0,0 +1,62 @@ +# +# Copyright 2017 AT&T Intellectual Property, Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# What this is: Kuberbetes chart for the OPNFV Barometer collectd agent +# running as a daemonset (one each kluster node) under kubernetes. +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: ves-barometer + namespace: default + labels: + k8s-app: ves-barometer +spec: + selector: + matchLabels: + name: ves-barometer + template: + metadata: + labels: + name: ves-barometer + spec: + tolerations: + - key: node-role.kubernetes.io/master + effect: NoSchedule + containers: + - name: ves-barometer + image: blsaws/ves-barometer:latest + env: + - name: ves_mode + value: + - name: ves_kafka_hostname + value: + - name: ves_kafka_port + value: "" + volumeMounts: + - name: varrun + mountPath: /var/run + - name: tmp + mountPath: /tmp + readOnly: true + securityContext: + privileged: true + terminationGracePeriodSeconds: 30 + volumes: + - name: varrun + hostPath: + path: /var/run + - name: tmp + hostPath: + path: /tmp diff --git a/tools/ves-setup.sh b/tools/ves-setup.sh index 0a279f0..1a3dbbe 100644 --- a/tools/ves-setup.sh +++ b/tools/ves-setup.sh @@ -35,7 +35,7 @@ #. - shell environment variables setup as below (for non-default setting) #. ves_mode: install mode (node|guest) for VES collectd plugin (default: node) #. ves_host: VES collector IP or hostname (default: 127.0.0.1) -#. ves_port: VES collector port (default: 30000) +#. ves_port: VES collector port (default: 3001) #. ves_path: REST path optionalRoutingPath element (default: empty) #. ves_topic: REST path topicName element (default: empty) #. ves_https: use HTTPS instead of HTTP (default: false) @@ -97,11 +97,13 @@ function common_prereqs() { } function setup_env() { + log "updating VES environment variables" cat <~/ves/tools/ves_env.sh #!/bin/bash ves_mode="${ves_mode:=node}" ves_host="${ves_host:=127.0.0.1}" -ves_port="${ves_port:=30000}" +ves_hostname="${ves_hostname:=ves-collector-service.default.svc.cluster.local}" +ves_port="${ves_port:=3001}" ves_path="${ves_path:=}" ves_topic="${ves_topic:=}" ves_https="${ves_https:=false}" @@ -109,17 +111,25 @@ ves_user="${ves_user:=}" ves_pass="${ves_pass:=}" ves_interval="${ves_interval:=20}" ves_version="${ves_version:=5.1}" +ves_zookeeper_hostname="${ves_zookeeper_hostname:=ves-zookeeper-service.default.svc.cluster.local}" +ves_zookeeper_host="${ves_zookeeper_host:=127.0.0.1}" +ves_zookeeper_port="${ves_zookeeper_port:=2181}" ves_kafka_host="${ves_kafka_host:=127.0.0.1}" -ves_kafka_hostname="${ves_kafka_hostname:=localhost}" +ves_kafka_hostname="${ves_kafka_hostname:=ves-kafka-service.default.svc.cluster.local}" ves_kafka_port="${ves_kafka_port:=9092}" -ves_influxdb_host="${ves_influxdb_host:=localhost:8086}" +ves_influxdb_host="${ves_influxdb_host:=127.0.0.1}" +ves_influxdb_hostname="${ves_influxdb_hostname:=ves-influxdb-service.default.svc.cluster.local}" +ves_influxdb_port="${ves_influxdb_port:=8086}" ves_influxdb_auth="${ves_influxdb_auth:=}" -ves_grafana_host="${ves_grafana_host:=localhost:3000}" +ves_grafana_host="${ves_grafana_host:=127.0.0.1}" +ves_grafana_hostname="${ves_grafana_hostname:=ves-grafana-service.default.svc.cluster.local}" +ves_grafana_port="${ves_grafana_port:=3000}" ves_grafana_auth="${ves_grafana_auth:=admin:admin}" -ves_loglevel="${ves_loglevel:=}" +ves_loglevel="${ves_loglevel:=DEBUG}" ves_cloudtype="${ves_cloudtype:=kubernetes}" export ves_mode export ves_host +export ves_hostname export ves_port export ves_path export ves_topic @@ -127,177 +137,105 @@ export ves_https export ves_user export ves_pass export ves_interval +export ves_version +export ves_zookeeper_host +export ves_zookeeper_hostname +export ves_zookeeper_port export ves_kafka_host export ves_kafka_hostname export ves_kafka_port export ves_influxdb_host +export ves_influxdb_hostname +export ves_influxdb_port export ves_influxdb_auth export ves_grafana_host +export ves_grafana_hostname +export ves_grafana_port export ves_grafana_auth export ves_loglevel export ves_cloudtype EOF source ~/ves/tools/ves_env.sh - echo ~/ves/tools/ves_env.sh + env | grep ves_ } -function setup_collectd() { - log "setup collectd" - - common_prereqs - source ~/ves/tools/ves_env.sh - log "VES environment as set by ves_env.sh" - env | grep ves +function update_env() { + log "update VES environment with $1=$2" + eval ${1}=${2} + export $1 + sed -i -- "s/.*$1=.*/$1=$2/" ~/ves/tools/ves_env.sh + env | grep ves_ +} - log "setup VES collectd config for VES $ves_mode mode" - mkdir ~/collectd - if [[ "$ves_mode" == "node" ]]; then -# # TODO: fix for journalctl -xe report "... is marked executable" -# sudo chmod 744 /etc/systemd/system/collectd.service - - cat <~/collectd/collectd.conf -# for VES plugin -LoadPlugin logfile - - LogLevel debug - File STDOUT - Timestamp true - PrintSeverity false - - -LoadPlugin csv - - DataDir "/work-dir/collectd/install/var/lib/csv" - StoreRates false - - -LoadPlugin target_set -LoadPlugin match_regex - - - - Plugin "^memory$" - - - PluginInstance "host" - - - - -LoadPlugin cpu - - ReportByCpu true - ReportByState true - ValuesPercentage true - - -LoadPlugin interface -LoadPlugin memory -LoadPlugin load -LoadPlugin disk -# TODO: how to set this option only to apply to VMs (not nodes) -LoadPlugin uuid - -LoadPlugin write_kafka - - Property "metadata.broker.list" "$ves_kafka_host:$ves_kafka_port" - - Format JSON - - -EOF +function setup_kafka() { + log "setup kafka server" + log "deploy zookeeper and kafka" + if [[ "$1" == "cloudify" ]]; then + cp -r ~/ves/tools/cloudify/ves-zookeeper ~/models/tools/cloudify/blueprints/. + source ~/models/tools/cloudify/k8s-cloudify.sh start ves-zookeeper ves-zookeeper + source ~/models/tools/cloudify/k8s-cloudify.sh clusterIp ves-zookeeper + update_env ves_zookeeper_host $clusterIp - if [[ -d /etc/nova ]]; then - cat <>~/collectd/collectd.conf -LoadPlugin virt - - Connection "qemu:///system" - RefreshInterval 60 - HostnameFormat uuid - PluginInstanceFormat name - ExtraStats "cpu_util" - -EOF - fi + cp -r ~/ves/tools/cloudify/ves-kafka ~/models/tools/cloudify/blueprints/. + inputs="{ \ + \"zookeeper_hostname\": \"$ves_zookeeper_hostname\", + \"zookeeper_host\": \"$ves_zookeeper_host\", + \"zookeeper_port\": \"$ves_zookeeper_port\", + \"kafka_port\": \"$ves_kafka_port\", + \"kafka_hostname\": \"$ves_kafka_hostname\"}" + + source ~/models/tools/cloudify/k8s-cloudify.sh start ves-kafka ves-kafka "$inputs" + source ~/models/tools/cloudify/k8s-cloudify.sh clusterIp ves-kafka + update_env ves_kafka_host $clusterIp else - cat <~/collectd/collectd.conf -# for VES plugin -LoadPlugin logfile - - LogLevel debug - File STDOUT - Timestamp true - PrintSeverity false - - -LoadPlugin cpu - - ReportByCpu true - ReportByState true - ValuesPercentage true - - -LoadPlugin csv - - DataDir "/tmp" - - -LoadPlugin interface -LoadPlugin memory -LoadPlugin load -LoadPlugin disk -LoadPlugin uuid - -LoadPlugin write_kafka - - Property "metadata.broker.list" "$ves_kafka_host:$ves_kafka_port" - - Format JSON - - - -LoadPlugin target_set -LoadPlugin match_regex - - - - Plugin "^memory$" - - - PluginInstance "guest" - - - + ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ + $k8s_user@$k8s_master </$ves_mode/" \ + /home/$k8s_user/ves/tools/kubernetes/ves-barometer/daemonset.yaml +sed -i -- "s//$ves_kafka_hostname/" \ + /home/$k8s_user/ves/tools/kubernetes/ves-barometer/daemonset.yaml +sed -i -- "s//$ves_kafka_port/" \ + /home/$k8s_user/ves/tools/kubernetes/ves-barometer/daemonset.yaml +kubectl create \ + -f /home/$k8s_user/ves/tools/kubernetes/ves-barometer/daemonset.yaml +EOF + +# sudo docker run -tid --net=host --name ves-barometer \ +# -v ~/collectd:/opt/collectd/etc/collectd.conf.d \ +# -v /var/run:/var/run -v /tmp:/tmp --privileged \ +# opnfv/barometer:latest /run_collectd.sh } function setup_agent() { log "setup VES agent" - source ~/k8s_env.sh - source ~/ves/tools/ves_env.sh - log "VES environment as set by ves_env.sh" - env | grep ves log "deploy the VES agent container" if [[ "$1" == "cloudify" ]]; then cp -r ~/ves/tools/cloudify/ves-agent ~/models/tools/cloudify/blueprints/. - # Cloudify is deployed on the k8s master node - manager_ip=$k8s_master - inputs="{ \ \"ves_mode\": \"$ves_mode\", \"ves_host\": \"$ves_host\", @@ -309,29 +247,32 @@ function setup_agent() { \"ves_pass\": \"$ves_pass\", \"ves_interval\": \"$ves_interval\", \"ves_version\": \"$ves_version\", - \"ves_kafka_port\": \"$ves_kafka_port\", - \"ves_kafka_host\": \"$ves_kafka_host\", \"ves_kafka_hostname\": \"$ves_kafka_hostname\", + \"ves_kafka_host\": \"$ves_kafka_host\", + \"ves_kafka_port\": \"$ves_kafka_port\", \"ves_loglevel\": \"$ves_loglevel\"}" bash ~/models/tools/cloudify/k8s-cloudify.sh start ves-agent ves-agent "$inputs" else - sudo docker run -it -d \ - -e ves_mode=$ves_mode \ - -e ves_host=$ves_host \ - -e ves_port=$ves_port \ - -e ves_path=$ves_path \ - -e ves_topic=$ves_topic \ - -e ves_https=$ves_https \ - -e ves_user=$ves_user \ - -e ves_pass=$ves_pass \ - -e ves_interval=$ves_interval \ - -e ves_version=$ves_version \ - -e ves_kafka_port=$ves_kafka_port \ - -e ves_kafka_host=$ves_kafka_host \ - -e ves_kafka_hostname=$ves_kafka_hostname \ - -e ves_loglevel=$ves_loglevel \ - --name ves-agent blsaws/ves-agent:latest + ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ + $k8s_user@$k8s_master <~/ves/tools/grafana/datasource.json -{ "name":"VESEvents", - "type":"influxdb", - "access":"direct", - "url":"http://$ves_host:8086", - "password":"root", - "user":"root", - "database":"veseventsdb", - "basicAuth":false, - "basicAuthUser":"", - "basicAuthPassword":"", - "withCredentials":false, - "isDefault":false, - "jsonData":null -} + log "checking for grafana at http://$ves_grafana_host:$ves_grafana_port" + if ! curl http://$ves_grafana_host:$ves_grafana_port ; then + log "install Grafana container on k8s master" + update_env ves_grafana_host $k8s_master + update_env ves_grafana_hostname $k8s_master_hostname + ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ + $k8s_user@$k8s_master \ + sudo docker run -d --name ves-grafana -p 3000:3000 grafana/grafana + ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ + $k8s_user@$k8s_master <<'EOF' +status=$(sudo docker inspect ves-grafana | jq -r '.[0].State.Status') +while [[ "x$status" != "xrunning" ]]; do + echo; echo "Grafana container state is ($status)" + sleep 10 +status=$(sudo docker inspect ves-grafana | jq -r '.[0].State.Status') +done +echo; echo "Grafana container state is $status" EOF - - # Use /home/$USER/ instead of ~ with @ - curl -H "Accept: application/json" -H "Content-type: application/json" \ - -X POST -d @/home/$USER/ves/tools/grafana/datasource.json \ - http://$ves_grafana_auth@$ves_grafana_host/api/datasources - - log "add VES dashboard to Grafana at http://$ves_grafana_auth@$ves_grafana_host" - curl -H "Accept: application/json" -H "Content-type: application/json" \ - -X POST \ - -d @/home/$USER/ves/tools/grafana/Dashboard.json\ - http://$ves_grafana_auth@$ves_grafana_host/api/dashboards/db + fi log "setup collector container" - # TODO: migrate to deployment via Helm - sudo docker run -it -d -p 30000:30000 \ - -e ves_host=$ves_host \ - -e ves_port=$ves_port \ - -e ves_path=$ves_path \ - -e ves_topic=$ves_topic \ - -e ves_https=$ves_https \ - -e ves_user=$ves_user \ - -e ves_pass=$ves_pass \ - -e ves_interval=$ves_interval \ - -e ves_version=$ves_version \ - -e ves_influxdb_host=$ves_influxdb_host \ - -e ves_loglevel=$ves_loglevel \ - --name ves-collector blsaws/ves-collector:latest + if [[ "$1" == "cloudify" ]]; then + cp -r ~/ves/tools/cloudify/ves-collector ~/models/tools/cloudify/blueprints/. + inputs="{ \ + \"ves_host\": \"$ves_host\", + \"ves_port\": \"$ves_port\", + \"ves_path\": \"$ves_path\", + \"ves_topic\": \"$ves_topic\", + \"ves_https\": \"$ves_https\", + \"ves_user\": \"$ves_user\", + \"ves_pass\": \"$ves_pass\", + \"ves_interval\": \"$ves_interval\", + \"ves_version\": \"$ves_version\", + \"ves_influxdb_host\": \"$ves_influxdb_host\", + \"ves_influxdb_port\": \"$ves_influxdb_port\", + \"ves_grafana_host\": \"$ves_grafana_host\", + \"ves_grafana_port\": \"$ves_grafana_port\", + \"ves_grafana_auth\": \"$ves_grafana_auth\", + \"ves_loglevel\": \"$ves_loglevel\"}" + + source ~/models/tools/cloudify/k8s-cloudify.sh start \ + ves-collector ves-collector "$inputs" + source ~/models/tools/cloudify/k8s-cloudify.sh clusterIp ves-collector + update_env ves_host $clusterIp + log "updated VES env"; env | grep ves + else + ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ + $k8s_user@$k8s_master <= now() - 5m" | jq -r '.results[0].series') + result=$(curl -G "http://$ves_influxdb_host:$ves_influxdb_port/query?pretty=true" --data-urlencode "db=veseventsdb" --data-urlencode "q=SELECT moving_average(\"$3\", 5) FROM \"$2\" WHERE (\"system\" =~ /^($uuid)$/) AND time >= now() - 5m" | jq -r '.results[0].series') if [[ "$result" != "null" ]]; then echo "$host load data found in influxdb" else @@ -527,8 +476,14 @@ if [[ $(grep -c $HOSTNAME /etc/hosts) -eq 0 ]]; then sudo tee -a /etc/hosts fi +source ~/k8s_env.sh +if [[ -f ~/ves/tools/ves_env.sh ]]; then + source ~/ves/tools/ves_env.sh +fi log "VES environment as input" -env | grep ves +env | grep ves_ + +trap 'fail' ERR case "$1" in "env") @@ -541,23 +496,13 @@ case "$1" in setup_agent $2 ;; "collector") - setup_collector + setup_collector $2 ;; "kafka") - log "setup kafka server" - source ~/k8s_env.sh - source ~/ves/tools/ves_env.sh - log "VES environment as set by ves_env.sh" - env | grep ves - sudo docker run -it -d -p 2181:2181 --name ves-zookeeper zookeeper - sudo docker run -it -d -p 9092:9092 --name ves-kafka \ - -e zookeeper_host=$k8s_master_host \ - -e zookeeper=$k8s_master \ - -e kafka_hostname=$ves_kafka_hostname \ - blsaws/ves-kafka:latest + setup_kafka $2 ;; "verify") - verify_veseventsdb "$1" "load" "load-shortterm" + verify_veseventsdb "$1" load load-shortterm ;; "clean") clean $2 "$3" $4 @@ -565,3 +510,4 @@ case "$1" in *) grep '#. ' $0 esac +trap '' ERR -- cgit 1.2.3-korg