diff --git a/README.md b/README.md index 27dc1bdc8fe55f13d31bb386232b10c1a16805ef..8707d45f0a166f4ee7da2aff2f6ef25ad2e20039 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: @@ -70,31 +77,54 @@ 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 ``` -or also the next script: -``` -./stop.sh +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 + -m : clean monitoring service + -a : clean all services + -h : show this help +`````` 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 + -m : Show monitoring 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. 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 ``` -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 @@ -142,14 +172,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://:8083/ (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 af3c31365c4823fb603bce1ec99395ef1569bfb5..7b3c91e031803c15e0443b7e3da2c6a38d391633 100755 --- a/services/clean_capif_docker_services.sh +++ b/services/clean_capif_docker_services.sh @@ -1,31 +1,68 @@ - -# 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: $1 " + 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 +} + +if [[ $# -lt 1 ]] +then + echo "You must specify an option before run script." + help fi -# Recorrer los archivos Docker Compose y ejecutar docker-compose down +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[@]}" + 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 @@ -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 11a89c8aa219e25b4ca64e85d6af8632f0707e24..8214516f7616da74eae34b8079cd2f3d479b87c8 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 "Opción no válida: -$OPTARG" >&2 - exit 1 + echo "Not valid option: -$OPTARG" >&2 + help ;; :) - echo "La opción -$OPTARG requiere un argumento." >&2 - exit 1 + echo "The -$OPTARG option requires an argument." >&2 + help ;; esac done 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 0000000000000000000000000000000000000000..b53641dd216e3cb43d9cd4ca0eaca85567ca60e4 --- /dev/null +++ b/services/show_logs.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +help() { + echo "Usage: $0 " + 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" + 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} + diff --git a/services/stop.sh b/services/stop.sh deleted file mode 100755 index a45576d520e8d788ea5dc333b4beeeec6fe90f10..0000000000000000000000000000000000000000 --- 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