summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/cloudify/ves-agent/blueprint.yaml169
-rw-r--r--tools/demo_deploy.sh70
-rw-r--r--tools/ves-setup.sh79
3 files changed, 240 insertions, 78 deletions
diff --git a/tools/cloudify/ves-agent/blueprint.yaml b/tools/cloudify/ves-agent/blueprint.yaml
new file mode 100644
index 0000000..f7ef0a9
--- /dev/null
+++ b/tools/cloudify/ves-agent/blueprint.yaml
@@ -0,0 +1,169 @@
+tosca_definitions_version: cloudify_dsl_1_3
+#
+# 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: Cloudify blueprint for running the OPNFV VES Agent 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: 30000
+ 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_kafka_host:
+ default: 127.0.0.1
+ ves_kafka_hostname:
+ default: localhost
+ ves_kafka_port:
+ default: 9092
+ ves_mode:
+ default: node
+ ves_loglevel:
+ default: info
+
+ 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_agent_service:
+ type: cloudify.kubernetes.resources.Service
+ properties:
+ definition:
+ apiVersion: v1
+ metadata:
+ name: ves-agent-service
+ spec:
+ selector:
+ app: ves-agent
+ relationships:
+ - type: cloudify.kubernetes.relationships.managed_by_master
+ target: kubernetes_master
+ - type: cloudify.relationships.depends_on
+ target: ves_agent_pod
+
+ ves_agent_pod:
+ type: cloudify.kubernetes.resources.Pod
+ properties:
+ definition:
+ apiVersion: v1
+ metadata:
+ name: ves-agent-pod
+ labels:
+ app: ves-agent
+ spec:
+ containers:
+ - name: ves-agent
+ image: blsaws/ves-agent: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_kafka_host
+ value: { get_input: ves_kafka_host }
+ - name: ves_kafka_hostname
+ value: { get_input: ves_kafka_hostname }
+ - name: ves_kafka_port
+ value: { get_input: ves_kafka_port }
+ - name: ves_mode
+ value: { get_input: ves_mode }
+ - name: ves_loglevel
+ value: { get_input: ves_loglevel }
+ relationships:
+ - type: cloudify.kubernetes.relationships.managed_by_master
+ target: kubernetes_master
diff --git a/tools/demo_deploy.sh b/tools/demo_deploy.sh
index f939a83..305de9c 100644
--- a/tools/demo_deploy.sh
+++ b/tools/demo_deploy.sh
@@ -65,6 +65,20 @@ cloudify=$5
eval `ssh-agent`
ssh-add $key
+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
+
echo; echo "$0 $(date): Setting up master node"
ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
$user@$master mkdir /home/$user/ves
@@ -72,36 +86,16 @@ 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 <<EOF
- ves_host=$master
- export ves_host
- ves_mode=node
- export ves_mode
- ves_user=hello
- export ves_user
- ves_pass=world
- export ves_pass
- ves_kafka_host=$master
- export ves_kafka_host
- ves_kafka_hostname=$ves_kafka_hostname
- export ves_kafka_hostname
- ves_influxdb_host=$ves_influxdb_host
- export ves_influxdb_host
- ves_influxdb_auth=$ves_influxdb_auth
- export ves_influxdb_auth
- ves_grafana_host=$ves_grafana_host
- export ves_grafana_host
- ves_grafana_auth=$ves_grafana_auth
- export ves_grafana_auth
- ves_loglevel=$ves_loglevel
- export ves_loglevel
- env | grep ves
- bash /home/$user/ves/tools/ves-setup.sh collector
- bash /home/$user/ves/tools/ves-setup.sh kafka
- bash /home/$user/ves/tools/ves-setup.sh agent $cloudify
+bash ves/tools/ves-setup.sh collector
+bash ves/tools/ves-setup.sh kafka
EOF
-scp -r -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
- $user@$master:/home/$user/ves/tools/ves_env.sh ~/ves/tools/.
+if [[ "$cloudify" == "cloudify" ]]; then
+ bash ves/tools/ves-setup.sh agent $cloudify
+else
+ ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
+ $user@$master bash ves/tools/ves-setup.sh agent
+fi
if [[ "$master" == "$workers" ]]; then
nodes=$master
@@ -119,17 +113,17 @@ for node in $nodes; do
fi
ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
$user@$node <<EOF > 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
+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
EOF
done
-echo; echo "$0 $(date): VES Grafana dashboards are available at http://$ves_grafana_host:3000 (login as admin/admin)"
+echo; echo "$0 $(date): VES Grafana dashboards are available at http://$ves_grafana_host (login as admin/admin)"
diff --git a/tools/ves-setup.sh b/tools/ves-setup.sh
index 00d7db8..0a279f0 100644
--- a/tools/ves-setup.sh
+++ b/tools/ves-setup.sh
@@ -54,16 +54,18 @@
#.
#. Usage:
#. git clone https://gerrit.opnfv.org/gerrit/ves ~/ves
-#. bash ~/ves/tools/ves-setup.sh <collector|kafka|collectd|agent> [cloudify]
+#. bash ~/ves/tools/ves-setup.sh <env|collector|kafka|collectd|agent> [cloudify]
+#. env: setup VES environment script ~/ves/tools/ves_env.sh
#. collector: setup VES collector (test collector)
#. kafka: setup kafka server for VES events from collect agent(s)
#. collectd: setup collectd with libvirt plugin, as a kafka publisher
#. agent: setup VES agent in host or guest mode, as a kafka consumer
#. cloudify: (optional) use cloudify to deploy the component, as setup by
#. tools/cloudify/k8s-cloudify.sh in the OPNFV Models repo.
-#. bash ~/ves/ves-setup.sh <master> <workers>
+#. bash ~/ves/ves-setup.sh clean <master> <workers> [cloudify]
#. master: VES master node IP
#. workers: quoted, space-separated list of worker node IPs
+#. cloudify: (optional) clean up cloudify-based deployments
#.
#. See demo_deploy.sh in this repo for a recommended sequence of the above.
#.
@@ -95,7 +97,7 @@ function common_prereqs() {
}
function setup_env() {
- cat <<'EOF' >~/ves/tools/ves_env.sh
+ cat <<EOF >~/ves/tools/ves_env.sh
#!/bin/bash
ves_mode="${ves_mode:=node}"
ves_host="${ves_host:=127.0.0.1}"
@@ -145,6 +147,8 @@ function setup_collectd() {
common_prereqs
source ~/ves/tools/ves_env.sh
+ log "VES environment as set by ves_env.sh"
+ env | grep ves
log "setup VES collectd config for VES $ves_mode mode"
mkdir ~/collectd
@@ -285,26 +289,14 @@ 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
- cd ~/ves/tools/cloudify
+ cp -r ~/ves/tools/cloudify/ves-agent ~/models/tools/cloudify/blueprints/.
# Cloudify is deployed on the k8s master node
manager_ip=$k8s_master
- log "copy kube config from k8s master for insertion into blueprint"
- scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
- $k8s_user@$manager_ip:/home/$k8s_user/.kube/config ves-agent/kube.config
-
- log "package the blueprint"
- # CLI: cfy blueprints package -o /tmp/$bp $bp
- tar ckf /tmp/blueprint.tar ves-agent
-
- log "upload the blueprint"
- # CLI: cfy blueprints upload -t default_tenant -b $bp /tmp/$bp.tar.gz
- curl -s -X PUT -u admin:admin --header 'Tenant: default_tenant' \
- --header "Content-Type: application/octet-stream" -o /tmp/json \
- http://$manager_ip/api/v3.1/blueprints/ves-agent?application_file_name=blueprint.yaml \
- -T /tmp/blueprint.tar
inputs="{ \
\"ves_mode\": \"$ves_mode\",
@@ -322,22 +314,7 @@ function setup_agent() {
\"ves_kafka_hostname\": \"$ves_kafka_hostname\",
\"ves_loglevel\": \"$ves_loglevel\"}"
- log "create a deployment for the blueprint"
- # CLI: cfy deployments create -t default_tenant -b $bp $bp
- curl -s -X PUT -u admin:admin --header 'Tenant: default_tenant' \
- --header "Content-Type: application/json" -o /tmp/json \
- -d "{\"blueprint_id\": \"ves-agent\", \"inputs\": $inputs}" \
- http://$manager_ip/api/v3.1/deployments/ves-agent
- sleep 10
-
- # CLI: cfy workflows list -d $bp
-
- log "install the deployment pod and service"
- # CLI: cfy executions start install -d $bp
- curl -s -X POST -u admin:admin --header 'Tenant: default_tenant' \
- --header "Content-Type: application/json" -o /tmp/json \
- -d "{\"deployment_id\":\"ves-agent\", \"workflow_id\":\"install\"}" \
- http://$manager_ip/api/v3.1/executions
+ bash ~/models/tools/cloudify/k8s-cloudify.sh start ves-agent ves-agent "$inputs"
else
sudo docker run -it -d \
-e ves_mode=$ves_mode \
@@ -368,7 +345,9 @@ function setup_agent() {
function setup_collector() {
log "setup collector"
- $2 $3 $4
+ source ~/ves/tools/ves_env.sh
+ log "VES environment as set by ves_env.sh"
+ env | grep ves
log "install prerequistes"
if [[ "$dist" == "ubuntu" ]]; then
@@ -377,8 +356,6 @@ function setup_collector() {
sudo yum install -y jq
fi
- setup_env
-
if ! curl http://$ves_influxdb_host/ping ; then
# TODO: migrate to deployment via Helm
log "setup influxdb container"
@@ -483,7 +460,12 @@ function clean() {
log "clean installation"
master=$1
workers="$2"
+ cloudify=$3
+
source ~/k8s_env.sh
+ source ~/ves/tools/ves_env.sh
+ log "VES environment as set by ves_env.sh"
+ env | grep ves
if [[ "$master" == "$workers" ]]; then
nodes=$master
@@ -491,6 +473,10 @@ function clean() {
nodes="$master $workers"
fi
+ if [[ "$cloudify" == "cloudify" ]]; then
+ bash ~/models/tools/cloudify/k8s-cloudify.sh stop ves-agent ves-agent
+ fi
+
for node in $nodes; do
log "remove config for VES at node $node"
ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
@@ -509,7 +495,7 @@ EOF
log "Remove VES containers and collectd config at master node"
ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
$k8s_user@$master <<'EOF'
-cs="ves-agent ves-collector ves-grafana ves-influxdb ves-barometer"
+cs="ves-agent ves-collector ves-grafana ves-influxdb ves-barometer ves-kafka ves-zookeeper"
for c in $cs; do
sudo docker stop $c
sudo docker rm -v $c
@@ -519,6 +505,10 @@ EOF
function verify_veseventsdb() {
source ~/k8s_env.sh
+ source ~/ves/tools/ves_env.sh
+ log "VES environment as set by ves_env.sh"
+ env | grep ves
+
for host in $1; do
uuid=$(ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $k8s_user@$host sudo cat /sys/class/dmi/id/product_uuid)
echo "$host=$uuid"
@@ -537,7 +527,13 @@ if [[ $(grep -c $HOSTNAME /etc/hosts) -eq 0 ]]; then
sudo tee -a /etc/hosts
fi
+log "VES environment as input"
+env | grep ves
+
case "$1" in
+ "env")
+ setup_env
+ ;;
"collectd")
setup_collectd
;;
@@ -550,7 +546,10 @@ case "$1" in
"kafka")
log "setup kafka server"
source ~/k8s_env.sh
- sudo docker run -it -d -p 2181:2181 --name zookeeper zookeeper
+ 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 \
@@ -561,7 +560,7 @@ case "$1" in
verify_veseventsdb "$1" "load" "load-shortterm"
;;
"clean")
- clean $2 "$3"
+ clean $2 "$3" $4
;;
*)
grep '#. ' $0