diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2023-03-16 16:31:11 +0000 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2023-03-31 10:01:43 +0100 |
commit | 5980fb4d758c2ee55fad90661d039920dcc0ebe6 (patch) | |
tree | e208f346bd7b25a62c8beaa4bad3e114562f6f81 /compose | |
parent | e4ff7e58336dfb4fa6699e0a37dbbb298a129ada (diff) |
Improvements to scripts and test configuration
- reduced csit image for k8s test from 1gb to 230mb
- fixed some small hindrances with start-compose.sh
- added README for how to use and configure compose script
- cleaning of Chart.lock as it fails helm install if outdated even
after running helm dependencies update
Issue-ID: POLICY-4125
Change-Id: If1711523bb836c212f27a032a46cc18d68766478
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'compose')
-rw-r--r-- | compose/README.md | 100 | ||||
-rwxr-xr-x | compose/start-compose.sh | 25 | ||||
-rwxr-xr-x | compose/stop-compose.sh | 12 |
3 files changed, 123 insertions, 14 deletions
diff --git a/compose/README.md b/compose/README.md new file mode 100644 index 00000000..ada34e1c --- /dev/null +++ b/compose/README.md @@ -0,0 +1,100 @@ +# Policy Framework Docker Compose + +The PF docker compose starts a small instance of docker containers for PF components. + +## Features + +- Starts all components, including Prometheus/Grafana dashboard and GUI (ACM and Apex) +- Can start specific components +- Expose fixed ports so all the REST endpoints can be called with localhost:component_port + +## Tech + +Things to be installed beforehand: + +- Linux VM if using Windows +- Docker +- Docker compose +- Any editor + +## Installation + +Assuming the docker repository has been cloned and workdir is ../docker/compose + +- Install all PF components (excluding GUI) +```sh +./start-compose.sh +``` + +- Install all PF components + GUI + +```sh +./start-compose.sh --gui +``` + +- Install an specific PF component +(accepted options: api pap apex-pdp distribution drools-pdp drools-apps xacml-pdp +policy-clamp-runtime-acm) + + +```sh +./start-compose.sh component + +# that will start apex-pdp and its dependencies (pap, api, db, simulator) +./start-compose.sh apex-pdp +``` + +- Install an specific PF component with Grafana dashboard +(accepted options: api pap apex-pdp distribution drools-pdp drools-apps xacml-pdp +policy-clamp-runtime-acm) + + +```sh +./start-compose.sh component --grafana + +# that will start apex-pdp and its dependencies (pap, api, db, simulator) + grafana and prometheus server +./start-compose.sh apex-pdp --grafana +``` + +## Docker image localization + +The docker images are always downloaded from nexus repository, but if needed to build a local +image, edit the ``export-ports.sh`` script and change the variable ``CONTAINER_LOCATION`` +to be empty. + + +## Docker image versions + +The start-compose script is always looking for the latest SNAPSHOT version available (will +look locally first, then download from nexus if not available). +Note: if latest Policy-API docker image is 2.8-SNAPSHOT-latest, but on nexus it was released +2 days ago and in local environment it's 3 months old - it will use the 3 months old image, +so it's recommended to keep an eye on it. + +If needed, the version can be edited on docker-compose.yml and docker-compose.gui.yml + +i.e: need to change db-migrator version +from docker-compose.yml: +``image: ${CONTAINER_LOCATION}onap/policy-db-migrator:${POLICY_DOCKER_VERSION}`` + +replace the ${POLICY_DOCKER_VERSION} for the specific version needed + + +## Logs + +To collect the docker-compose logs, simply run the following: + +```sh +./start-compose.sh logs +``` +Note: these are logs for installation only, not actual application usage + +It will generate a ``docker-compose.log`` file with the result. + +## Uninstall + +Simply run the ``stop-compose.sh`` script. + +```sh +./stop-compose.sh +``` diff --git a/compose/start-compose.sh b/compose/start-compose.sh index a77b4834..49006f11 100755 --- a/compose/start-compose.sh +++ b/compose/start-compose.sh @@ -57,9 +57,11 @@ do esac done +cd ${COMPOSE_FOLDER} + echo "Configuring docker compose..." -source "${COMPOSE_FOLDER}"/export-ports.sh > /dev/null 2>&1 -source "${COMPOSE_FOLDER}"/get-versions.sh > /dev/null 2>&1 +source export-ports.sh > /dev/null 2>&1 +source get-versions.sh > /dev/null 2>&1 # in case of csit running for PAP (groups should be for pap) but starts apex-pdp for dependencies. if [ -z "$PROJECT" ]; then @@ -67,29 +69,32 @@ if [ -z "$PROJECT" ]; then fi if [ -n "$component" ]; then - if [ "$grafana" = true ]; then + if [ "$component" == "logs" ]; then + echo "Collecting logs..." + docker-compose logs > docker-compose.log + elif [ "$grafana" = true ]; then echo "Starting ${component} application with Grafana" - docker-compose -f "${COMPOSE_FOLDER}"/docker-compose.yml up -d "${component}" grafana + docker-compose up -d "${component}" grafana echo "Prometheus server: http://localhost:${PROMETHEUS_PORT}" echo "Grafana server: http://localhost:${GRAFANA_PORT}" elif [ "$gui" = true ]; then echo "Starting application with gui..." - docker-compose -f "${COMPOSE_FOLDER}"/docker-compose.yml \ - -f "${COMPOSE_FOLDER}"/docker-compose.gui.yml up -d "${component}" policy-gui + docker-compose -f docker-compose.yml -f docker-compose.gui.yml up -d "${component}" policy-gui echo "Clamp GUI: https://localhost:2445/clamp" else echo "Starting ${component} application" - docker-compose -f "${COMPOSE_FOLDER}"/docker-compose.yml up -d "${component}" + docker-compose up -d "${component}" fi else export PROJECT=api # api has groups.json complete with all 3 pdps if [ "$gui" = true ]; then echo "Starting application with gui..." - docker-compose -f "${COMPOSE_FOLDER}"/docker-compose.yml \ - -f "${COMPOSE_FOLDER}"/docker-compose.gui.yml up -d + docker-compose -f docker-compose.yml -f docker-compose.gui.yml up -d echo "Clamp GUI: https://localhost:2445/clamp" else echo "Starting all components..." - docker-compose -f "${COMPOSE_FOLDER}"/docker-compose.yml up -d + docker-compose up -d fi fi + +cd ${WORKSPACE} diff --git a/compose/stop-compose.sh b/compose/stop-compose.sh index a8185215..0a7d9af4 100755 --- a/compose/stop-compose.sh +++ b/compose/stop-compose.sh @@ -25,12 +25,16 @@ if [ -z "${WORKSPACE}" ]; then fi COMPOSE_FOLDER="${WORKSPACE}"/compose -source "${COMPOSE_FOLDER}"/export-ports.sh > /dev/null 2>&1 -source "${COMPOSE_FOLDER}"/get-versions.sh > /dev/null 2>&1 +cd ${COMPOSE_FOLDER} + +source export-ports.sh > /dev/null 2>&1 +source get-versions.sh > /dev/null 2>&1 echo "Collecting logs from docker compose containers..." -docker-compose -f "${COMPOSE_FOLDER}"/docker-compose.yml logs > docker_compose.log +docker-compose logs > docker_compose.log cat docker_compose.log echo "Tearing down containers..." -docker-compose -f "${COMPOSE_FOLDER}"/docker-compose.yml down -v --remove-orphans +docker-compose down -v --remove-orphans + +cd ${WORKSPACE} |