Commit 5e5dc289 authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Merge branch 'OCF3-improve-help-scripts-under-services' into 'main'

Resolve "Improve Help scripts under services"

See merge request !6
parents 9756234d 2f6e9c3c
Loading
Loading
Loading
Loading
Loading
+52 −12
Original line number Diff line number Diff line
@@ -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 0](#capif-release-0)

@@ -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 <options>
       -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 <options>
       -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://<Mongo Express Host IP>:8082/ (if accessed from another host)
http://<Mongo CAPIF Express Host IP>:8082/ (if accessed from another host)
```

## Mongo Register's DB Dashboard
```
http://localhost:8083/ (if accessed from localhost) 

or

http://<Mongo Register Express Host IP>:8083/ (if accessed from another host)
```

# FAQ Documentation

Frequently asked questions can be found here: [FAQ Directory]
+60 −23
Original line number Diff line number Diff line
#!/bin/bash

# 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
help() {
  echo "Usage: $1 <options>"
  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
}

# exit $status
if [[ $# -lt 1 ]]
then
  echo "You must specify an option before run script."
  help
fi

#!/bin/bash
FILES=()
echo "${FILES[@]}"

# 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]"
# 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
fi
      ;;
    :)
      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"
  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."
+18 −7
Original line number Diff line number Diff line
#!/bin/bash

help() {
  echo "Usage: $1 <options>"
  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

services/show_logs.sh

0 → 100755
+81 −0
Original line number Diff line number Diff line
#!/bin/bash

help() {
  echo "Usage: $0 <options>"
  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}
Loading