all.sh 8.22 KB
Newer Older
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
#!/bin/bash
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
#
# 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.


########################################################################################################################
# Read deployment settings
########################################################################################################################

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

# ----- TeraFlowSDN ------------------------------------------------------------

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, set the URL of the Docker registry where the images will be uploaded to.
# By default, assume internal MicroK8s registry is used.
export TFS_REGISTRY_IMAGES=${TFS_REGISTRY_IMAGES:-"http://localhost:32000/tfs/"}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, set the list of components, separated by spaces, you want to build images for, and deploy.
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# By default, only basic components are deployed
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
export TFS_COMPONENTS=${TFS_COMPONENTS:-"context device automation monitoring pathcomp service slice compute webui load_generator"}
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

# If not already set, set the tag you want to use for your images.
export TFS_IMAGE_TAG=${TFS_IMAGE_TAG:-"dev"}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, set the name of the Kubernetes namespace to deploy TFS to.
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}

# If not already set, set additional manifest files to be applied after the deployment
export TFS_EXTRA_MANIFESTS=${TFS_EXTRA_MANIFESTS:-""}

# If not already set, set the new Grafana admin password
export TFS_GRAFANA_PASSWORD=${TFS_GRAFANA_PASSWORD:-"admin123+"}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, disable skip-build flag to rebuild the Docker images.
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If TFS_SKIP_BUILD is "YES", the containers are not rebuilt-retagged-repushed and existing ones are used.
export TFS_SKIP_BUILD=${TFS_SKIP_BUILD:-""}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

# ----- CockroachDB ------------------------------------------------------------

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, set the namespace where CockroackDB will be deployed.
export CRDB_NAMESPACE=${CRDB_NAMESPACE:-"crdb"}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, set the external port CockroackDB Postgre SQL interface will be exposed to.
export CRDB_EXT_PORT_SQL=${CRDB_EXT_PORT_SQL:-"26257"}

# If not already set, set the external port CockroackDB HTTP Mgmt GUI interface will be exposed to.
export CRDB_EXT_PORT_HTTP=${CRDB_EXT_PORT_HTTP:-"8081"}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, set the database username to be used by Context.
export CRDB_USERNAME=${CRDB_USERNAME:-"tfs"}

# If not already set, set the database user's password to be used by Context.
export CRDB_PASSWORD=${CRDB_PASSWORD:-"tfs123"}

# If not already set, set the database name to be used by Context.
export CRDB_DATABASE=${CRDB_DATABASE:-"tfs"}

# If not already set, set CockroachDB installation mode. Accepted values are: 'single' and 'cluster'.
# "YES", the database pointed by variable CRDB_NAMESPACE will be dropped while
# checking/deploying CockroachDB.
# - If CRDB_DEPLOY_MODE is "single", CockroachDB is deployed in single node mode. It is convenient for
#   development and testing purposes and should fit in a VM. IT SHOULD NOT BE USED IN PRODUCTION ENVIRONMENTS.
# - If CRDB_DEPLOY_MODE is "cluster", CockroachDB is deployed in cluster mode, and an entire CockroachDB cluster
#   with 3 replicas and version v22.2 (set by default) will be deployed. It is convenient for production and
#   provides scalability features. If you are deploying for production, also read the following link providing
#   details on deploying CockroachDB for production environments:
#   Ref: https://www.cockroachlabs.com/docs/stable/recommended-production-settings.html
export CRDB_DEPLOY_MODE=${CRDB_DEPLOY_MODE:-"single"}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, disable flag for dropping database, if it exists.
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# WARNING: ACTIVATING THIS FLAG IMPLIES LOOSING THE DATABASE INFORMATION!
# If CRDB_DROP_DATABASE_IF_EXISTS is "YES", the database pointed by variable CRDB_NAMESPACE will be dropped while
# checking/deploying CockroachDB.
export CRDB_DROP_DATABASE_IF_EXISTS=${CRDB_DROP_DATABASE_IF_EXISTS:-""}

# If not already set, disable flag for re-deploying CockroachDB from scratch.
# WARNING: ACTIVATING THIS FLAG IMPLIES LOOSING THE DATABASE INFORMATION!
# WARNING: THE REDEPLOY MIGHT TAKE FEW MINUTES TO COMPLETE GRACEFULLY IN CLUSTER MODE
# If CRDB_REDEPLOY is "YES", the database will be dropped while checking/deploying CockroachDB.
export CRDB_REDEPLOY=${CRDB_REDEPLOY:-""}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

# ----- NATS -------------------------------------------------------------------

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, set the namespace where NATS will be deployed.
export NATS_NAMESPACE=${NATS_NAMESPACE:-"nats"}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, set the external port NATS Client interface will be exposed to.
export NATS_EXT_PORT_CLIENT=${NATS_EXT_PORT_CLIENT:-"4222"}

# If not already set, set the external port NATS HTTP Mgmt GUI interface will be exposed to.
export NATS_EXT_PORT_HTTP=${NATS_EXT_PORT_HTTP:-"8222"}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, disable flag for re-deploying NATS from scratch.
# WARNING: ACTIVATING THIS FLAG IMPLIES LOOSING THE MESSAGE BROKER INFORMATION!
# If NATS_REDEPLOY is "YES", the message broker will be dropped while checking/deploying NATS.
export NATS_REDEPLOY=${NATS_REDEPLOY:-""}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

# ----- QuestDB ----------------------------------------------------------------

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, set the namespace where QuestDB will be deployed.
export QDB_NAMESPACE=${QDB_NAMESPACE:-"qdb"}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, set the external port QuestDB Postgre SQL interface will be exposed to.
export QDB_EXT_PORT_SQL=${QDB_EXT_PORT_SQL:-"8812"}

# If not already set, set the external port QuestDB Influx Line Protocol interface will be exposed to.
export QDB_EXT_PORT_ILP=${QDB_EXT_PORT_ILP:-"9009"}

# If not already set, set the external port QuestDB HTTP Mgmt GUI interface will be exposed to.
export QDB_EXT_PORT_HTTP=${QDB_EXT_PORT_HTTP:-"9000"}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, set the database username to be used for QuestDB.
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
export QDB_USERNAME=${QDB_USERNAME:-"admin"}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, set the database user's password to be used for QuestDB.
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
export QDB_PASSWORD=${QDB_PASSWORD:-"quest"}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, set the table name to be used by Monitoring for KPIs.
export QDB_TABLE_MONITORING_KPIS=${QDB_TABLE_MONITORING_KPIS:-"tfs_monitoring_kpis"}
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, set the table name to be used by Slice for plotting groups.
export QDB_TABLE_SLICE_GROUPS=${QDB_TABLE_SLICE_GROUPS:-"tfs_slice_groups"}

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If not already set, disable flag for dropping tables if they exist.
# WARNING: ACTIVATING THIS FLAG IMPLIES LOOSING THE TABLE INFORMATION!
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# If QDB_DROP_TABLES_IF_EXIST is "YES", the tables pointed by variables
# QDB_TABLE_MONITORING_KPIS and QDB_TABLE_SLICE_GROUPS will be dropped while 
# checking/deploying QuestDB.
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
export QDB_DROP_TABLES_IF_EXIST=${QDB_DROP_TABLES_IF_EXIST:-""}
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

# If not already set, disable flag for re-deploying QuestDB from scratch.
# WARNING: ACTIVATING THIS FLAG IMPLIES LOOSING THE DATABASE INFORMATION!
# If QDB_REDEPLOY is "YES", the database will be dropped while checking/deploying QuestDB.
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
export QDB_REDEPLOY=${QDB_REDEPLOY:-""}
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# ----- K8s Observability ------------------------------------------------------

# If not already set, set the external port Prometheus Mgmt HTTP GUI interface will be exposed to.
export PROM_EXT_PORT_HTTP=${PROM_EXT_PORT_HTTP:-"9090"}

# If not already set, set the external port Grafana HTTP Dashboards will be exposed to.
export GRAF_EXT_PORT_HTTP=${GRAF_EXT_PORT_HTTP:-"3000"}


Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
########################################################################################################################
# Automated steps start here
########################################################################################################################

# Deploy CockroachDB
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
./deploy/crdb.sh
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

# Deploy NATS
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
./deploy/nats.sh
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# Deploy QuestDB
./deploy/qdb.sh

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# Expose Dashboard
./deploy/expose_dashboard.sh

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
# Deploy TeraFlowSDN
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
./deploy/tfs.sh
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

# Show deploy summary
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
./deploy/show.sh
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

echo "Done!"