From 580817c79ecc3751164f6564d7e980a433db976c Mon Sep 17 00:00:00 2001 From: gifrerenom Date: Wed, 1 Mar 2023 13:35:27 +0000 Subject: [PATCH] Deploy scripts: - Added definition of external ports - Added definition of NATS namespace - Improved Grafana configuration - Improved deployment of dependencies - Updated my_deploy.sh script --- deploy/all.sh | 21 +++++++++++++++++++ deploy/crdb.sh | 57 ++++++++++++++++++++++++++++++-------------------- deploy/nats.sh | 36 ++++++++++++++++++------------- deploy/qdb.sh | 40 ++++++++++++++++++++++------------- deploy/tfs.sh | 31 ++++++++++++++++++++++++--- my_deploy.sh | 21 +++++++++++++++++++ 6 files changed, 151 insertions(+), 55 deletions(-) diff --git a/deploy/all.sh b/deploy/all.sh index 6f5592cb4..6f8331b76 100755 --- a/deploy/all.sh +++ b/deploy/all.sh @@ -51,6 +51,12 @@ export TFS_SKIP_BUILD=${TFS_SKIP_BUILD:-""} # If not already set, set the namespace where CockroackDB will be deployed. export CRDB_NAMESPACE=${CRDB_NAMESPACE:-"crdb"} +# 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"} + # If not already set, set the database username to be used by Context. export CRDB_USERNAME=${CRDB_USERNAME:-"tfs"} @@ -90,6 +96,12 @@ export CRDB_REDEPLOY=${CRDB_REDEPLOY:-""} # If not already set, set the namespace where NATS will be deployed. export NATS_NAMESPACE=${NATS_NAMESPACE:-"nats"} +# 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"} + # 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. @@ -101,6 +113,15 @@ export NATS_REDEPLOY=${NATS_REDEPLOY:-""} # If not already set, set the namespace where QuestDB will be deployed. export QDB_NAMESPACE=${QDB_NAMESPACE:-"qdb"} +# 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"} + # If not already set, set the database username to be used for QuestDB. export QDB_USERNAME=${QDB_USERNAME:-"admin"} diff --git a/deploy/crdb.sh b/deploy/crdb.sh index 4e8cfe2c3..216339117 100755 --- a/deploy/crdb.sh +++ b/deploy/crdb.sh @@ -21,6 +21,12 @@ # If not already set, set the namespace where CockroackDB will be deployed. export CRDB_NAMESPACE=${CRDB_NAMESPACE:-"crdb"} +# 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"} + # If not already set, set the database username to be used by Context. export CRDB_USERNAME=${CRDB_USERNAME:-"tfs"} @@ -109,24 +115,23 @@ function crdb_deploy_single() { echo echo "CockroachDB Port Mapping" - echo ">>> Expose CockroachDB SQL port (26257->26257)" - CRDB_SQL_PORT=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="sql")].port}') - PATCH='{"data": {"'${CRDB_SQL_PORT}'": "'${CRDB_NAMESPACE}'/cockroachdb-public:'${CRDB_SQL_PORT}'"}}' + echo ">>> Expose CockroachDB SQL port (26257->${CRDB_EXT_PORT_SQL})" + CRDB_PORT_SQL=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="sql")].port}') + PATCH='{"data": {"'${CRDB_EXT_PORT_SQL}'": "'${CRDB_NAMESPACE}'/cockroachdb-public:'${CRDB_PORT_SQL}'"}}' kubectl patch configmap nginx-ingress-tcp-microk8s-conf --namespace ingress --patch "${PATCH}" - PORT_MAP='{"containerPort": '${CRDB_SQL_PORT}', "hostPort": '${CRDB_SQL_PORT}'}' + PORT_MAP='{"containerPort": '${CRDB_EXT_PORT_SQL}', "hostPort": '${CRDB_EXT_PORT_SQL}'}' CONTAINER='{"name": "nginx-ingress-microk8s", "ports": ['${PORT_MAP}']}' PATCH='{"spec": {"template": {"spec": {"containers": ['${CONTAINER}']}}}}' kubectl patch daemonset nginx-ingress-microk8s-controller --namespace ingress --patch "${PATCH}" echo - echo ">>> Expose CockroachDB HTTP Mgmt GUI port (8080->8081)" - CRDB_GUI_PORT_EXT="8081" - CRDB_GUI_PORT=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="http")].port}') - PATCH='{"data": {"'${CRDB_GUI_PORT_EXT}'": "'${CRDB_NAMESPACE}'/cockroachdb-public:'${CRDB_GUI_PORT}'"}}' + echo ">>> Expose CockroachDB HTTP Mgmt GUI port (8080->${CRDB_EXT_PORT_HTTP})" + CRDB_PORT_HTTP=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="http")].port}') + PATCH='{"data": {"'${CRDB_EXT_PORT_HTTP}'": "'${CRDB_NAMESPACE}'/cockroachdb-public:'${CRDB_PORT_HTTP}'"}}' kubectl patch configmap nginx-ingress-tcp-microk8s-conf --namespace ingress --patch "${PATCH}" - PORT_MAP='{"containerPort": '${CRDB_GUI_PORT_EXT}', "hostPort": '${CRDB_GUI_PORT_EXT}'}' + PORT_MAP='{"containerPort": '${CRDB_EXT_PORT_HTTP}', "hostPort": '${CRDB_EXT_PORT_HTTP}'}' CONTAINER='{"name": "nginx-ingress-microk8s", "ports": ['${PORT_MAP}']}' PATCH='{"spec": {"template": {"spec": {"containers": ['${CONTAINER}']}}}}' kubectl patch daemonset nginx-ingress-microk8s-controller --namespace ingress --patch "${PATCH}" @@ -153,7 +158,8 @@ function crdb_undeploy_single() { function crdb_drop_database_single() { echo "Drop database if exists" - CRDB_CLIENT_URL="postgresql://${CRDB_USERNAME}:${CRDB_PASSWORD}@cockroachdb-0:${CRDB_SQL_PORT}/defaultdb?sslmode=require" + CRDB_PORT_SQL=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="sql")].port}') + CRDB_CLIENT_URL="postgresql://${CRDB_USERNAME}:${CRDB_PASSWORD}@cockroachdb-0:${CRDB_PORT_SQL}/defaultdb?sslmode=require" kubectl exec -it --namespace ${CRDB_NAMESPACE} cockroachdb-0 -- \ ./cockroach sql --certs-dir=/cockroach/cockroach-certs --url=${CRDB_CLIENT_URL} \ --execute "DROP DATABASE IF EXISTS ${CRDB_DATABASE};" @@ -263,24 +269,23 @@ function crdb_deploy_cluster() { echo echo "CockroachDB Port Mapping" - echo ">>> Expose CockroachDB SQL port (26257)" - CRDB_SQL_PORT=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="sql")].port}') - PATCH='{"data": {"'${CRDB_SQL_PORT}'": "'${CRDB_NAMESPACE}'/cockroachdb-public:'${CRDB_SQL_PORT}'"}}' + echo ">>> Expose CockroachDB SQL port (26257->${CRDB_EXT_PORT_SQL})" + CRDB_PORT_SQL=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="sql")].port}') + PATCH='{"data": {"'${CRDB_EXT_PORT_SQL}'": "'${CRDB_NAMESPACE}'/cockroachdb-public:'${CRDB_PORT_SQL}'"}}' kubectl patch configmap nginx-ingress-tcp-microk8s-conf --namespace ingress --patch "${PATCH}" - PORT_MAP='{"containerPort": '${CRDB_SQL_PORT}', "hostPort": '${CRDB_SQL_PORT}'}' + PORT_MAP='{"containerPort": '${CRDB_EXT_PORT_SQL}', "hostPort": '${CRDB_EXT_PORT_SQL}'}' CONTAINER='{"name": "nginx-ingress-microk8s", "ports": ['${PORT_MAP}']}' PATCH='{"spec": {"template": {"spec": {"containers": ['${CONTAINER}']}}}}' kubectl patch daemonset nginx-ingress-microk8s-controller --namespace ingress --patch "${PATCH}" echo - echo ">>> Expose CockroachDB HTTP Mgmt GUI port (8080->8081)" - CRDB_GUI_PORT_EXT="8081" - CRDB_GUI_PORT=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="http")].port}') - PATCH='{"data": {"'${CRDB_GUI_PORT_EXT}'": "'${CRDB_NAMESPACE}'/cockroachdb-public:'${CRDB_GUI_PORT}'"}}' + echo ">>> Expose CockroachDB HTTP Mgmt GUI port (8080->${CRDB_EXT_PORT_HTTP})" + CRDB_PORT_HTTP=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="http")].port}') + PATCH='{"data": {"'${CRDB_EXT_PORT_HTTP}'": "'${CRDB_NAMESPACE}'/cockroachdb-public:'${CRDB_PORT_HTTP}'"}}' kubectl patch configmap nginx-ingress-tcp-microk8s-conf --namespace ingress --patch "${PATCH}" - PORT_MAP='{"containerPort": '${CRDB_GUI_PORT_EXT}', "hostPort": '${CRDB_GUI_PORT_EXT}'}' + PORT_MAP='{"containerPort": '${CRDB_EXT_PORT_HTTP}', "hostPort": '${CRDB_EXT_PORT_HTTP}'}' CONTAINER='{"name": "nginx-ingress-microk8s", "ports": ['${PORT_MAP}']}' PATCH='{"spec": {"template": {"spec": {"containers": ['${CONTAINER}']}}}}' kubectl patch daemonset nginx-ingress-microk8s-controller --namespace ingress --patch "${PATCH}" @@ -342,17 +347,23 @@ function crdb_drop_database_cluster() { if [ "$CRDB_DEPLOY_MODE" == "single" ]; then if [ "$CRDB_REDEPLOY" == "YES" ]; then crdb_undeploy_single - elif [ "$CRDB_DROP_DATABASE_IF_EXISTS" == "YES" ]; then - crdb_drop_database_single fi + crdb_deploy_single + + if [ "$CRDB_DROP_DATABASE_IF_EXISTS" == "YES" ]; then + crdb_drop_database_single + fi elif [ "$CRDB_DEPLOY_MODE" == "cluster" ]; then if [ "$CRDB_REDEPLOY" == "YES" ]; then crdb_undeploy_cluster - elif [ "$CRDB_DROP_DATABASE_IF_EXISTS" == "YES" ]; then - crdb_drop_database_cluster fi + crdb_deploy_cluster + + if [ "$CRDB_DROP_DATABASE_IF_EXISTS" == "YES" ]; then + crdb_drop_database_cluster + fi else echo "Unsupported value: CRDB_DEPLOY_MODE=$CRDB_DEPLOY_MODE" fi diff --git a/deploy/nats.sh b/deploy/nats.sh index 9edbc7765..aa082b54b 100755 --- a/deploy/nats.sh +++ b/deploy/nats.sh @@ -21,6 +21,12 @@ # If not already set, set the namespace where NATS will be deployed. export NATS_NAMESPACE=${NATS_NAMESPACE:-"nats"} +# 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"} + # 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. @@ -43,14 +49,14 @@ function nats_deploy_single() { echo "Install NATS (single-node)" echo ">>> Checking if NATS is deployed..." - if kubectl get --namespace ${NATS_NAMESPACE} statefulset/nats &> /dev/null; then + if kubectl get --namespace ${NATS_NAMESPACE} statefulset/${NATS_NAMESPACE} &> /dev/null; then echo ">>> NATS is present; skipping step." else echo ">>> Deploy NATS" - helm3 install nats nats/nats --namespace ${NATS_NAMESPACE} --set nats.image.tag=2.9-alpine + helm3 install ${NATS_NAMESPACE} nats/nats --namespace ${NATS_NAMESPACE} --set nats.image.tag=2.9-alpine echo ">>> Waiting NATS statefulset to be created..." - while ! kubectl get --namespace ${NATS_NAMESPACE} statefulset/nats &> /dev/null; do + while ! kubectl get --namespace ${NATS_NAMESPACE} statefulset/${NATS_NAMESPACE} &> /dev/null; do printf "%c" "." sleep 1 done @@ -64,32 +70,32 @@ function nats_deploy_single() { #kubectl wait --namespace ${NATS_NAMESPACE} --for=jsonpath='{.status.readyReplicas}'=3 --timeout=300s \ # statefulset/nats echo ">>> NATS statefulset created. Waiting NATS pods to be created..." - while ! kubectl get --namespace ${NATS_NAMESPACE} pod/nats-0 &> /dev/null; do + while ! kubectl get --namespace ${NATS_NAMESPACE} pod/${NATS_NAMESPACE}-0 &> /dev/null; do printf "%c" "." sleep 1 done - kubectl wait --namespace ${NATS_NAMESPACE} --for=condition=Ready --timeout=300s pod/nats-0 + kubectl wait --namespace ${NATS_NAMESPACE} --for=condition=Ready --timeout=300s pod/${NATS_NAMESPACE}-0 fi echo echo "NATS Port Mapping" - echo ">>> Expose NATS Client port (4222)" - NATS_CLIENT_PORT=$(kubectl --namespace ${NATS_NAMESPACE} get service nats -o 'jsonpath={.spec.ports[?(@.name=="client")].port}') - PATCH='{"data": {"'${NATS_CLIENT_PORT}'": "'${NATS_NAMESPACE}'/nats:'${NATS_CLIENT_PORT}'"}}' + echo ">>> Expose NATS Client port (4222->${NATS_EXT_PORT_CLIENT})" + NATS_PORT_CLIENT=$(kubectl --namespace ${NATS_NAMESPACE} get service ${NATS_NAMESPACE} -o 'jsonpath={.spec.ports[?(@.name=="client")].port}') + PATCH='{"data": {"'${NATS_EXT_PORT_CLIENT}'": "'${NATS_NAMESPACE}'/'${NATS_NAMESPACE}':'${NATS_PORT_CLIENT}'"}}' kubectl patch configmap nginx-ingress-tcp-microk8s-conf --namespace ingress --patch "${PATCH}" - PORT_MAP='{"containerPort": '${NATS_CLIENT_PORT}', "hostPort": '${NATS_CLIENT_PORT}'}' + PORT_MAP='{"containerPort": '${NATS_EXT_PORT_CLIENT}', "hostPort": '${NATS_EXT_PORT_CLIENT}'}' CONTAINER='{"name": "nginx-ingress-microk8s", "ports": ['${PORT_MAP}']}' PATCH='{"spec": {"template": {"spec": {"containers": ['${CONTAINER}']}}}}' kubectl patch daemonset nginx-ingress-microk8s-controller --namespace ingress --patch "${PATCH}" echo - echo ">>> Expose NATS HTTP Mgmt GUI port (8222)" - NATS_GUI_PORT=$(kubectl --namespace ${NATS_NAMESPACE} get service nats -o 'jsonpath={.spec.ports[?(@.name=="monitor")].port}') - PATCH='{"data": {"'${NATS_GUI_PORT}'": "'${NATS_NAMESPACE}'/nats:'${NATS_GUI_PORT}'"}}' + echo ">>> Expose NATS HTTP Mgmt GUI port (8222->${NATS_EXT_PORT_HTTP})" + NATS_PORT_HTTP=$(kubectl --namespace ${NATS_NAMESPACE} get service ${NATS_NAMESPACE} -o 'jsonpath={.spec.ports[?(@.name=="monitor")].port}') + PATCH='{"data": {"'${NATS_EXT_PORT_HTTP}'": "'${NATS_NAMESPACE}'/'${NATS_NAMESPACE}':'${NATS_PORT_HTTP}'"}}' kubectl patch configmap nginx-ingress-tcp-microk8s-conf --namespace ingress --patch "${PATCH}" - PORT_MAP='{"containerPort": '${NATS_GUI_PORT}', "hostPort": '${NATS_GUI_PORT}'}' + PORT_MAP='{"containerPort": '${NATS_EXT_PORT_HTTP}', "hostPort": '${NATS_EXT_PORT_HTTP}'}' CONTAINER='{"name": "nginx-ingress-microk8s", "ports": ['${PORT_MAP}']}' PATCH='{"spec": {"template": {"spec": {"containers": ['${CONTAINER}']}}}}' kubectl patch daemonset nginx-ingress-microk8s-controller --namespace ingress --patch "${PATCH}" @@ -99,9 +105,9 @@ function nats_deploy_single() { function nats_undeploy_single() { echo "NATS" echo ">>> Checking if NATS is deployed..." - if kubectl get --namespace ${NATS_NAMESPACE} statefulset/nats &> /dev/null; then + if kubectl get --namespace ${NATS_NAMESPACE} statefulset/${NATS_NAMESPACE} &> /dev/null; then echo ">>> Undeploy NATS" - helm3 uninstall --namespace ${NATS_NAMESPACE} nats + helm3 uninstall --namespace ${NATS_NAMESPACE} ${NATS_NAMESPACE} else echo ">>> NATS is not present; skipping step." fi diff --git a/deploy/qdb.sh b/deploy/qdb.sh index d94c000bf..cba8a5c00 100755 --- a/deploy/qdb.sh +++ b/deploy/qdb.sh @@ -21,6 +21,15 @@ # If not already set, set the namespace where QuestDB will be deployed. export QDB_NAMESPACE=${QDB_NAMESPACE:-"qdb"} +# 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"} + # If not already set, set the database username to be used for QuestDB. export QDB_USERNAME=${QDB_USERNAME:-"admin"} @@ -96,34 +105,34 @@ function qdb_deploy() { echo echo "QuestDB Port Mapping" - echo ">>> Expose QuestDB SQL port (8812->8812)" - QDB_SQL_PORT=$(kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o 'jsonpath={.spec.ports[?(@.name=="sql")].port}') - PATCH='{"data": {"'${QDB_SQL_PORT}'": "'${QDB_NAMESPACE}'/questdb-public:'${QDB_SQL_PORT}'"}}' + echo ">>> Expose QuestDB SQL port (8812->${QDB_EXT_PORT_SQL})" + QDB_PORT_SQL=$(kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o 'jsonpath={.spec.ports[?(@.name=="sql")].port}') + PATCH='{"data": {"'${QDB_EXT_PORT_SQL}'": "'${QDB_NAMESPACE}'/questdb-public:'${QDB_PORT_SQL}'"}}' kubectl patch configmap nginx-ingress-tcp-microk8s-conf --namespace ingress --patch "${PATCH}" - PORT_MAP='{"containerPort": '${QDB_SQL_PORT}', "hostPort": '${QDB_SQL_PORT}'}' + PORT_MAP='{"containerPort": '${QDB_EXT_PORT_SQL}', "hostPort": '${QDB_EXT_PORT_SQL}'}' CONTAINER='{"name": "nginx-ingress-microk8s", "ports": ['${PORT_MAP}']}' PATCH='{"spec": {"template": {"spec": {"containers": ['${CONTAINER}']}}}}' kubectl patch daemonset nginx-ingress-microk8s-controller --namespace ingress --patch "${PATCH}" echo - echo ">>> Expose QuestDB Influx Line Protocol port (9009->9009)" - QDB_ILP_PORT=$(kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o 'jsonpath={.spec.ports[?(@.name=="ilp")].port}') - PATCH='{"data": {"'${QDB_ILP_PORT}'": "'${QDB_NAMESPACE}'/questdb-public:'${QDB_ILP_PORT}'"}}' + echo ">>> Expose QuestDB Influx Line Protocol port (9009->${QDB_EXT_PORT_ILP})" + QDB_PORT_ILP=$(kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o 'jsonpath={.spec.ports[?(@.name=="ilp")].port}') + PATCH='{"data": {"'${QDB_EXT_PORT_ILP}'": "'${QDB_NAMESPACE}'/questdb-public:'${QDB_PORT_ILP}'"}}' kubectl patch configmap nginx-ingress-tcp-microk8s-conf --namespace ingress --patch "${PATCH}" - PORT_MAP='{"containerPort": '${QDB_ILP_PORT}', "hostPort": '${QDB_ILP_PORT}'}' + PORT_MAP='{"containerPort": '${QDB_EXT_PORT_ILP}', "hostPort": '${QDB_EXT_PORT_ILP}'}' CONTAINER='{"name": "nginx-ingress-microk8s", "ports": ['${PORT_MAP}']}' PATCH='{"spec": {"template": {"spec": {"containers": ['${CONTAINER}']}}}}' kubectl patch daemonset nginx-ingress-microk8s-controller --namespace ingress --patch "${PATCH}" echo - echo ">>> Expose QuestDB HTTP Mgmt GUI port (9000->9000)" - QDB_GUI_PORT=$(kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o 'jsonpath={.spec.ports[?(@.name=="http")].port}') - PATCH='{"data": {"'${QDB_GUI_PORT}'": "'${QDB_NAMESPACE}'/questdb-public:'${QDB_GUI_PORT}'"}}' + echo ">>> Expose QuestDB HTTP Mgmt GUI port (9000->${QDB_EXT_PORT_HTTP})" + QDB_PORT_HTTP=$(kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o 'jsonpath={.spec.ports[?(@.name=="http")].port}') + PATCH='{"data": {"'${QDB_EXT_PORT_HTTP}'": "'${QDB_NAMESPACE}'/questdb-public:'${QDB_PORT_HTTP}'"}}' kubectl patch configmap nginx-ingress-tcp-microk8s-conf --namespace ingress --patch "${PATCH}" - PORT_MAP='{"containerPort": '${QDB_GUI_PORT}', "hostPort": '${QDB_GUI_PORT}'}' + PORT_MAP='{"containerPort": '${QDB_EXT_PORT_HTTP}', "hostPort": '${QDB_EXT_PORT_HTTP}'}' CONTAINER='{"name": "nginx-ingress-microk8s", "ports": ['${PORT_MAP}']}' PATCH='{"spec": {"template": {"spec": {"containers": ['${CONTAINER}']}}}}' kubectl patch daemonset nginx-ingress-microk8s-controller --namespace ingress --patch "${PATCH}" @@ -161,7 +170,10 @@ function qdb_drop_tables() { if [ "$QDB_REDEPLOY" == "YES" ]; then qdb_undeploy -elif [ "$QDB_DROP_TABLES_IF_EXIST" == "YES" ]; then - qdb_drop_tables fi + qdb_deploy + +if [ "$QDB_DROP_TABLES_IF_EXIST" == "YES" ]; then + qdb_drop_tables +fi diff --git a/deploy/tfs.sh b/deploy/tfs.sh index 16cf5c13b..4c6dc95d2 100755 --- a/deploy/tfs.sh +++ b/deploy/tfs.sh @@ -51,6 +51,12 @@ export TFS_SKIP_BUILD=${TFS_SKIP_BUILD:-""} # If not already set, set the namespace where CockroackDB will be deployed. export CRDB_NAMESPACE=${CRDB_NAMESPACE:-"crdb"} +# 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"} + # If not already set, set the database username to be used by Context. export CRDB_USERNAME=${CRDB_USERNAME:-"tfs"} @@ -66,12 +72,27 @@ export CRDB_DATABASE=${CRDB_DATABASE:-"tfs"} # If not already set, set the namespace where NATS will be deployed. export NATS_NAMESPACE=${NATS_NAMESPACE:-"nats"} +# 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"} + # ----- QuestDB ---------------------------------------------------------------- # If not already set, set the namespace where QuestDB will be deployed. export QDB_NAMESPACE=${QDB_NAMESPACE:-"qdb"} +# 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"} + # If not already set, set the database username to be used for QuestDB. export QDB_USERNAME=${QDB_USERNAME:-"admin"} @@ -116,7 +137,7 @@ kubectl create secret generic crdb-data --namespace ${TFS_K8S_NAMESPACE} --type= printf "\n" echo "Create secret with NATS data" -NATS_CLIENT_PORT=$(kubectl --namespace ${NATS_NAMESPACE} get service nats -o 'jsonpath={.spec.ports[?(@.name=="client")].port}') +NATS_CLIENT_PORT=$(kubectl --namespace ${NATS_NAMESPACE} get service ${NATS_NAMESPACE} -o 'jsonpath={.spec.ports[?(@.name=="client")].port}') kubectl create secret generic nats-data --namespace ${TFS_K8S_NAMESPACE} --type='Opaque' \ --from-literal=NATS_NAMESPACE=${NATS_NAMESPACE} \ --from-literal=NATS_CLIENT_PORT=${NATS_CLIENT_PORT} @@ -303,12 +324,16 @@ for COMPONENT in $TFS_COMPONENTS; do printf "\n" done -if [[ "$TFS_COMPONENTS" == *"webui"* ]] && [[ "$TFS_COMPONENTS" == *"monitoring"* ]]; then +if [[ "$TFS_COMPONENTS" == *"webui"* ]]; then echo "Configuring WebUI DataStores and Dashboards..." sleep 5 + INGRESS_CTRL_NAME=$(echo "${TFS_K8S_NAMESPACE}" | sed "s/tfs/nginx-ingress-microk8s-controller/g") + EXT_HTTP_PORT=$(kubectl get daemonsets.apps --namespace ingress ${INGRESS_CTRL_NAME} \ + -o 'jsonpath={.spec.template.spec.containers[?(@.name=="nginx-ingress-microk8s")].ports[?(@.name=="http")].hostPort}') + # Exposed through the ingress controller "tfs-ingress" - GRAFANA_URL="127.0.0.1:80/grafana" + GRAFANA_URL="127.0.0.1:${EXT_HTTP_PORT}/grafana" # Default Grafana credentials GRAFANA_USERNAME="admin" diff --git a/my_deploy.sh b/my_deploy.sh index 518b90f28..22a7ae815 100755 --- a/my_deploy.sh +++ b/my_deploy.sh @@ -43,6 +43,12 @@ export TFS_SKIP_BUILD="" # Set the namespace where CockroackDB will be deployed. export CRDB_NAMESPACE="crdb" +# Set the external port CockroackDB Postgre SQL interface will be exposed to. +export CRDB_EXT_PORT_SQL="26257" + +# Set the external port CockroackDB HTTP Mgmt GUI interface will be exposed to. +export CRDB_EXT_PORT_HTTP="8081" + # Set the database username to be used by Context. export CRDB_USERNAME="tfs" @@ -68,6 +74,12 @@ export CRDB_REDEPLOY="" # Set the namespace where NATS will be deployed. export NATS_NAMESPACE="nats" +# Set the external port NATS Client interface will be exposed to. +export NATS_EXT_PORT_CLIENT="4222" + +# Set the external port NATS HTTP Mgmt GUI interface will be exposed to. +export NATS_EXT_PORT_HTTP="8222" + # Disable flag for re-deploying NATS from scratch. export NATS_REDEPLOY="" @@ -77,6 +89,15 @@ export NATS_REDEPLOY="" # Set the namespace where QuestDB will be deployed. export QDB_NAMESPACE="qdb" +# Set the external port QuestDB Postgre SQL interface will be exposed to. +export QDB_EXT_PORT_SQL="8812" + +# Set the external port QuestDB Influx Line Protocol interface will be exposed to. +export QDB_EXT_PORT_ILP="9009" + +# Set the external port QuestDB HTTP Mgmt GUI interface will be exposed to. +export QDB_EXT_PORT_HTTP="9000" + # Set the database username to be used for QuestDB. export QDB_USERNAME="admin" -- GitLab