From e2cfedcde7a0a249921384e03bc9b91ccd7a25dd Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Tue, 6 Feb 2024 09:27:54 +0100 Subject: [PATCH 1/6] Fixing clean script and remove some not english logs --- README.md | 18 +++++- services/clean_capif_docker_services.sh | 79 ++++++++++++++++++------- services/run.sh | 4 +- 3 files changed, 75 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 27dc1bd..1e81b78 100644 --- a/README.md +++ b/README.md @@ -70,11 +70,23 @@ If you want to check if all CAPIF services are running properly in local machine ``` This shell script will return 0 if all services are running properly. -When we need to stop CAPIF services, we can use next bash script: +When we need to stop all CAPIF services, we can use next bash script: ``` -./clean_capif_docker_services.sh +./clean_capif_docker_services.sh -a ``` +NOTE: You can use different flags if you only want to stop some of them, please check help using +``` +./clean_capif_docker_services.sh -h + +Usage: clean_capif_docker_services.sh + -c : clean capif services + -v : clean vault service + -r : clean register service + -a : clean all services + -h : show this help +`````` + or also the next script: ``` ./stop.sh @@ -88,7 +100,7 @@ It is now possible to deploy a monitoring stack for CAPIF with Grafana, Promethe To deploy CAPIF together with the monitoring stack, it is only necessary to execute the following. ``` -./run.sh --m true +./run.sh -m true ``` After they have been built, the different panels can be consulted in Grafana at the url diff --git a/services/clean_capif_docker_services.sh b/services/clean_capif_docker_services.sh index af3c313..ba783d5 100755 --- a/services/clean_capif_docker_services.sh +++ b/services/clean_capif_docker_services.sh @@ -1,28 +1,65 @@ - -# docker-compose -f "docker-compose-capif.yml" down --rmi all --remove-orphans -# docker network rm capif-network - -# status=$? -# if [ $status -eq 0 ]; then -# echo "*** All Capif services are cleaned ***" -# else -# echo "*** Some Capif services failed on clean ***" -# fi - -# exit $status - #!/bin/bash -# Verificar el parámetro proporcionado -if [[ $# -eq 0 || "$1" == "capif" ]]; then - FILES=("docker-compose-capif.yml") -elif [[ "$1" == "all" ]]; then - FILES=("docker-compose-capif.yml" "docker-compose-vault.yml" "docker-compose-register.yml" "../monitoring/docker-compose.yml" "docker-compose-backoffice.yml") -else - echo "Parámetro inválido. Uso: ./script.sh [capif|all]" +help() { + echo "Usage: clean_capif_docker_services.sh " + echo " -c : clean capif services" + echo " -v : clean vault service" + echo " -r : clean register service" + echo " -a : clean all services" + echo " -h : show this help" exit 1 +} + +if [[ $# -lt 1 ]] +then + echo "You must specify an option before run script." + help fi +FILES=() +echo "${FILES[@]}" + +# Read params +while getopts "cvrahm" opt; do + case $opt in + c) + echo "Remove Capif services" + FILES+=("docker-compose-capif.yml") + ;; + v) + echo "Remove vault service" + FILES+=("docker-compose-vault.yml") + ;; + r) + echo "Remove register service" + FILES+=("docker-compose-register.yml") + ;; + m) + echo "Remove monitoring service" + FILES+=("../monitoring/docker-compose.yml") + ;; + a) + echo "Remove all services" + FILES=("docker-compose-capif.yml" "docker-compose-vault.yml" "docker-compose-register.yml" "../monitoring/docker-compose.yml") + ;; + h) + help + ;; + \?) + echo "Not valid option: -$OPTARG" >&2 + help + exit 1 + ;; + :) + echo "The -$OPTARG option requires an argument." >&2 + help + exit 1 + ;; + esac +done +echo "after check" +echo "${FILES[@]}" + # Recorrer los archivos Docker Compose y ejecutar docker-compose down for FILE in "${FILES[@]}"; do echo "Ejecutando 'docker-compose down' para el archivo $FILE" @@ -37,4 +74,4 @@ done docker network rm capif-network -echo "Operación completada." +echo "Clean complete." diff --git a/services/run.sh b/services/run.sh index 11a89c8..fbdf1af 100755 --- a/services/run.sh +++ b/services/run.sh @@ -29,11 +29,11 @@ while getopts ":h:m:" opt; do MONITORING_STATE="$OPTARG" ;; \?) - echo "Opción no válida: -$OPTARG" >&2 + echo "Not valid option: -$OPTARG" >&2 exit 1 ;; :) - echo "La opción -$OPTARG requiere un argumento." >&2 + echo "The -$OPTARG option requires an argument." >&2 exit 1 ;; esac -- GitLab From 3a59eba889bc8ac628f6dab3a8e06e30741b27a0 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Tue, 6 Feb 2024 10:04:26 +0100 Subject: [PATCH 2/6] Fixed script and added new one for logs --- README.md | 16 +++- services/clean_capif_docker_services.sh | 5 +- .../{runCapifTests.sh => run_capif_tests.sh} | 0 services/show_logs.sh | 79 +++++++++++++++++++ 4 files changed, 95 insertions(+), 5 deletions(-) rename services/{runCapifTests.sh => run_capif_tests.sh} (100%) create mode 100755 services/show_logs.sh diff --git a/README.md b/README.md index 1e81b78..77fc7ee 100644 --- a/README.md +++ b/README.md @@ -87,13 +87,25 @@ Usage: clean_capif_docker_services.sh -h : show this help `````` -or also the next script: +or also the next script (-m true if monitoring is deployed): ``` -./stop.sh +./stop.sh -m true ``` This shell script will remove and clean all CAPIF services started previously with run.sh +On the other hand you can check logs using show_logs.sh script, please check options: +``` +./show_logs.sh +You must specify an option before run script. +Usage: ./show_logs.sh + -c : Show capif services + -v : Show vault service + -r : Show register service + -a : Show all services + -h : Show this help +``` + ### Run All CAPIF Services locally with Docker images and deploy monitoring stack It is now possible to deploy a monitoring stack for CAPIF with Grafana, Prometheus, FluentBit, Loki, Cadvisor, Tempo and Opentelemetry. diff --git a/services/clean_capif_docker_services.sh b/services/clean_capif_docker_services.sh index ba783d5..101060a 100755 --- a/services/clean_capif_docker_services.sh +++ b/services/clean_capif_docker_services.sh @@ -1,7 +1,7 @@ #!/bin/bash help() { - echo "Usage: clean_capif_docker_services.sh " + echo "Usage: $1 " echo " -c : clean capif services" echo " -v : clean vault service" echo " -r : clean register service" @@ -60,9 +60,8 @@ done echo "after check" echo "${FILES[@]}" -# Recorrer los archivos Docker Compose y ejecutar docker-compose down for FILE in "${FILES[@]}"; do - echo "Ejecutando 'docker-compose down' para el archivo $FILE" + echo "Executing 'docker-compose down' for file $FILE" docker-compose -f "$FILE" down --rmi all status=$? if [ $status -eq 0 ]; then diff --git a/services/runCapifTests.sh b/services/run_capif_tests.sh similarity index 100% rename from services/runCapifTests.sh rename to services/run_capif_tests.sh diff --git a/services/show_logs.sh b/services/show_logs.sh new file mode 100755 index 0000000..c5f9c23 --- /dev/null +++ b/services/show_logs.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +help() { + echo "Usage: $0 " + echo " -c : Show capif services" + echo " -v : Show vault service" + echo " -r : Show register service" + echo " -a : Show all services" + echo " -h : Show this help" + exit 1 +} + +if [[ $# -lt 1 ]] +then + echo "You must specify an option before run script." + help +fi + +FILES=() +echo "${FILES[@]}" +FOLLOW="" + +# Read params +while getopts "cvrahmf" opt; do + case $opt in + c) + echo "Show Capif services" + FILES+=("-f docker-compose-capif.yml") + ;; + v) + echo "Show vault service" + FILES+=("-f docker-compose-vault.yml") + ;; + r) + echo "Show register service" + FILES+=("-f docker-compose-register.yml") + ;; + m) + echo "Show monitoring service" + FILES+=("-f ../monitoring/docker-compose.yml") + ;; + a) + echo "Show all services" + FILES=("-f docker-compose-capif.yml" -f "docker-compose-vault.yml" -f "docker-compose-register.yml" -f "../monitoring/docker-compose.yml") + ;; + f) + echo "Setup follow logs" + FOLLOW="-f" + ;; + h) + help + ;; + ?) + echo "Not valid option: -$OPTARG" >&2 + help + exit 1 + ;; + :) + echo "The -$OPTARG option requires an argument." >&2 + help + exit 1 + ;; + \*) + echo "Not valid parameter $opt" + help + exit 1 + ;; + esac +done + +if [[ $1 =~ ^- ]] +then + echo "${FILES[@]}" +else + help +fi + +docker compose ${FILES[@]} logs ${FOLLOW} + -- GitLab From e5fb07385670713268ea8dcf311c61dbb27e6cbd Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Tue, 6 Feb 2024 10:07:38 +0100 Subject: [PATCH 3/6] Remove stop script --- README.md | 5 --- services/stop.sh | 98 ------------------------------------------------ 2 files changed, 103 deletions(-) delete mode 100755 services/stop.sh diff --git a/README.md b/README.md index 77fc7ee..09ffc53 100644 --- a/README.md +++ b/README.md @@ -87,11 +87,6 @@ Usage: clean_capif_docker_services.sh -h : show this help `````` -or also the next script (-m true if monitoring is deployed): -``` -./stop.sh -m true -``` - This shell script will remove and clean all CAPIF services started previously with run.sh On the other hand you can check logs using show_logs.sh script, please check options: diff --git a/services/stop.sh b/services/stop.sh deleted file mode 100755 index a45576d..0000000 --- a/services/stop.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash - -HOSTNAME=capifcore -MONITORING_STATE=false -DEPLOY=all -DEPLOY_BACKOFFICE=${DEPLOY_BACKOFFICE:-false} - -# Get docker compose version -docker_version=$(docker compose version --short | cut -d',' -f1) -IFS='.' read -ra version_components <<< "$docker_version" - -if [ "${version_components[0]}" -ge 2 ] && [ "${version_components[1]}" -ge 10 ]; then - echo "Docker compose version it greater than 2.10" -else - echo "Docker compose version is not valid. Should be greater than 2.10" - exit 1 -fi - -# Read params -while getopts ":h:m:" opt; do - case $opt in - h) - HOSTNAME="$OPTARG" - ;; - m) - MONITORING_STATE="$OPTARG" - ;; - \?) - echo "Opción no válida: -$OPTARG" >&2 - exit 1 - ;; - :) - echo "La opción -$OPTARG requiere un argumento." >&2 - exit 1 - ;; - esac -done - -if [ "$MONITORING_STATE" = true ] ; then - docker compose -f "../monitoring/docker-compose.yml" down - status=$? - if [ $status -eq 0 ]; then - echo "*** Monitoring Stack Stopped ***" - else - echo "*** Monitoring Stack failed to stopt ***" - exit $status - fi -fi - -docker compose -f "docker-compose-vault.yml" down - -status=$? -if [ $status -eq 0 ]; then - echo "*** Vault Service Stopped ***" -else - echo "*** Vault failed to stop ***" - exit $status -fi - - - -CAPIF_HOSTNAME=$HOSTNAME MONITORING=$MONITORING_STATE docker compose -f "docker-compose-capif.yml" down - -status=$? -if [ $status -eq 0 ]; then - echo "*** All Capif services are stopped ***" -else - echo "*** Some Capif services failed to stop ***" - exit $status -fi - - -CAPIF_PRIV_KEY_BASE_64=$(echo "$(cat nginx/certs/server.key)") -CAPIF_PRIV_KEY=$CAPIF_PRIV_KEY_BASE_64 docker compose -f "docker-compose-register.yml" down - -status=$? -if [ $status -eq 0 ]; then - echo "*** Register Service are stopped ***" -else - echo "*** Register Service failed to stop ***" -fi - - -if [ $DEPLOY_BACKOFFICE = "false" ]; then - exit $status -fi - - -docker compose -f "docker-compose-backoffice.yml" down - -status=$? -if [ $status -eq 0 ]; then - echo "*** Backoffice Service are stopped ***" -else - echo "*** Backoffice Service failed to stop ***" -fi - -exit $status -- GitLab From 0868e1ca9842fc78b2f4f0148dbce81be9c0f5e8 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Tue, 6 Feb 2024 11:18:53 +0100 Subject: [PATCH 4/6] Fixes required after stavros review --- README.md | 31 ++++++++++++++++++++----- services/clean_capif_docker_services.sh | 9 +++---- services/run.sh | 21 +++++++++++++---- services/show_logs.sh | 1 + 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 09ffc53..778def8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,8 @@ - [Using Curl](#using-curl) - [Using PostMan](#using-postman) - [Important urls:](#important-urls) - - [Mongo DB Dashboard](#mongo-db-dashboard) + - [Mongo CAPIF's DB Dashboard](#mongo-capifs-db-dashboard) + - [Mongo Register's DB Dashboard](#mongo-registers-db-dashboard) - [FAQ Documentation](#faq-documentation) - [CAPIF Release 1.0](#capif-release-10) @@ -61,7 +62,13 @@ This will build and run all services using docker images, including mongodb and Nginx deployed by default use **capifcore** hostname, but can add a parameter when run.sh is executed setting a different hostname, for example, ``` -./run.sh openshift.evolved-5g.eu +./run.sh -c openshift.evolved-5g.eu +``` + +Also you can run monitoring just using option -m true, for example: +``` +./run.sh -m true +./run.sh -m true -c openshift.evolved-5g.eu ``` If you want to check if all CAPIF services are running properly in local machine after execute run.sh, we can use: @@ -98,8 +105,10 @@ Usage: ./show_logs.sh -v : Show vault service -r : Show register service -a : Show all services + -f : Follow log output -h : Show this help ``` +You can also use option -f in order to live follow log output ### Run All CAPIF Services locally with Docker images and deploy monitoring stack It is now possible to deploy a monitoring stack for CAPIF with Grafana, Prometheus, FluentBit, Loki, Cadvisor, Tempo and Opentelemetry. @@ -113,7 +122,7 @@ To deploy CAPIF together with the monitoring stack, it is only necessary to exec After they have been built, the different panels can be consulted in Grafana at the url ``` -http:<0.0.0.0>:3000 +http://localhost:3000 ``` By default, the monitoring option is set to false. Once up, all data sources and dashboards are automatically provisioned @@ -161,14 +170,24 @@ Also you have here the [POSTMAN Collection](docs/testing_with_postman/CAPIF.post # Important urls: -## Mongo DB Dashboard +## Mongo CAPIF's DB Dashboard ``` -http://0.0.0.0:8082/ (if accessed from localhost) +http://localhost:8082/ (if accessed from localhost) or -http://:8082/ (if accessed from another host) +http://:8082/ (if accessed from another host) +``` + +## Mongo Register's DB Dashboard ``` +http://localhost:8083/ (if accessed from localhost) + +or + +http://:8082/ (if accessed from another host) +``` + # FAQ Documentation Frequently asked questions can be found here: [FAQ Directory] diff --git a/services/clean_capif_docker_services.sh b/services/clean_capif_docker_services.sh index 101060a..7b3c91e 100755 --- a/services/clean_capif_docker_services.sh +++ b/services/clean_capif_docker_services.sh @@ -2,10 +2,11 @@ help() { echo "Usage: $1 " - echo " -c : clean capif services" - echo " -v : clean vault service" - echo " -r : clean register service" - echo " -a : clean all services" + echo " -c : Clean capif services" + echo " -v : Clean vault service" + echo " -r : Clean register service" + echo " -m : Clean monitoring service" + echo " -a : Clean all services" echo " -h : show this help" exit 1 } diff --git a/services/run.sh b/services/run.sh index fbdf1af..8214516 100755 --- a/services/run.sh +++ b/services/run.sh @@ -1,5 +1,13 @@ #!/bin/bash +help() { + echo "Usage: $1 " + echo " -c : Setup different hostname for capif" + echo " -m : Clean monitoring service" + echo " -h : show this help" + exit 1 +} + HOSTNAME=capifcore MONITORING_STATE=false DEPLOY=all @@ -20,21 +28,24 @@ else fi # Read params -while getopts ":h:m:" opt; do +while getopts ":c:m:h" opt; do case $opt in - h) + c) HOSTNAME="$OPTARG" ;; m) MONITORING_STATE="$OPTARG" - ;; + ;; + h) + help + ;; \?) echo "Not valid option: -$OPTARG" >&2 - exit 1 + help ;; :) echo "The -$OPTARG option requires an argument." >&2 - exit 1 + help ;; esac done diff --git a/services/show_logs.sh b/services/show_logs.sh index c5f9c23..e0e3d3f 100755 --- a/services/show_logs.sh +++ b/services/show_logs.sh @@ -6,6 +6,7 @@ help() { echo " -v : Show vault service" echo " -r : Show register service" echo " -a : Show all services" + echo " -f : Follow log output" echo " -h : Show this help" exit 1 } -- GitLab From a9c27fa622dda7f48272984d142756e989b26643 Mon Sep 17 00:00:00 2001 From: Stavros Charismiadis Date: Tue, 6 Feb 2024 12:31:16 +0200 Subject: [PATCH 5/6] Last minor fixes --- services/show_logs.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/services/show_logs.sh b/services/show_logs.sh index e0e3d3f..b53641d 100755 --- a/services/show_logs.sh +++ b/services/show_logs.sh @@ -5,6 +5,7 @@ help() { echo " -c : Show capif services" echo " -v : Show vault service" echo " -r : Show register service" + echo " -m : Show monitoring service" echo " -a : Show all services" echo " -f : Follow log output" echo " -h : Show this help" -- GitLab From b29c0d02b2598d506dc05fc4d8e3eeec51eeb484 Mon Sep 17 00:00:00 2001 From: Stavros Charismiadis Date: Tue, 6 Feb 2024 12:32:47 +0200 Subject: [PATCH 6/6] README minor fix --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 778def8..8707d45 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ Usage: clean_capif_docker_services.sh -c : clean capif services -v : clean vault service -r : clean register service + -m : clean monitoring service -a : clean all services -h : show this help `````` @@ -104,6 +105,7 @@ Usage: ./show_logs.sh -c : Show capif services -v : Show vault service -r : Show register service + -m : Show monitoring service -a : Show all services -f : Follow log output -h : Show this help @@ -185,7 +187,7 @@ http://localhost:8083/ (if accessed from localhost) or -http://:8082/ (if accessed from another host) +http://:8083/ (if accessed from another host) ``` # FAQ Documentation -- GitLab