-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standalone Monasca for demo purposes with Docker Compose #16
Open
pgillich
wants to merge
4
commits into
monasca:master
Choose a base branch
from
pgillich:compose-standalone
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
CONTAINER_NAME_PREFIX=standalone_ | ||
|
||
ZOOKEEPER_TAG=3.3.6 | ||
|
||
KAFKA_TAG=0.9.0.1-2.11 | ||
ZOOKEEPER_CONNECTION_STRING=zookeeper:2181 | ||
KAFKA_DELETE_TOPIC_ENABLE=true | ||
KAFKA_TOPIC_CONFIG=segment.ms=900000 | ||
KAFKA_CREATE_TOPICS=metrics:64:1,alarm-state-transitions:12:1,alarm-notifications:12:1,retry-notifications:3:1,events:12:1,60-seconds-notifications:3:1 | ||
|
||
INFLUXDB_TAG=1.1.3 | ||
INFLUXDB_RETENTION_ENABLED=false | ||
INFLUXDB_ADMIN_ENABLED=true | ||
|
||
INFLUXDB_INIT_TAG=latest | ||
|
||
MYSQL_TAG=5.5.54 | ||
MYSQL_ROOT_PASSWORD=secretmysql | ||
|
||
MYSQL_INIT_TAG=1.1.0 | ||
MYSQL_INIT_DISABLE_REMOTE_ROOT=false | ||
MYSQL_INIT_RANDOM_PASSWORD=false | ||
|
||
KEYSTONE_TAG=latest | ||
KEYSTONE_HOST=keystone | ||
KEYSTONE_PASSWORD=secretadmin | ||
KEYSTONE_DATABASE_BACKEND=mysql | ||
KEYSTONE_MYSQL_HOST=mysql | ||
KEYSTONE_MYSQL_USER=keystone | ||
KEYSTONE_MYSQL_PASSWORD=keystone | ||
KEYSTONE_MYSQL_DATABASE=keystone | ||
|
||
MONASCA_API_TAG=1.6.0 | ||
|
||
MONASCA_SIDECAR_TAG=1.0.0 | ||
SIDECAR_URL=http://monasca-sidecar:4888/v1/ingest | ||
|
||
MONASCA_PERSISTER_TAG=1.4.0 | ||
|
||
MONASCA_GRAFANA_TAG=master-keystone | ||
MONASCA_GRAFANA_BRANCH=master | ||
MONASCA_GRAFANA_REPO=https://github.com/openstack/monasca-grafana-datasource | ||
|
||
MONASCA_GRAFANA_INIT_TAG=latest | ||
|
||
GRAFANA_OFFICIAL_TAG=4.1.2 | ||
GF_SERVER_ROOT_URL=http://localhost | ||
GF_AUTH_ANONYMOUS_ENABLED=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# Standalone Monasca | ||
|
||
|
||
This repository contains a Docker Compose configuration for running | ||
a standalone Monasca and its required components in containers. Stability and repeatability is important, so | ||
The goal is component versions should declared if possible, instead of `latest`. | ||
Typical use case is demo. | ||
|
||
## Tags | ||
|
||
Tags can be set in .env file. | ||
|
||
## Usage | ||
|
||
### First-time run | ||
|
||
At the first time, initializer containers must be run, too. | ||
Example command for running all initializer containers with all services: | ||
|
||
`docker-compose --file docker-compose.yml --file compose-init.yml up` | ||
|
||
This command builds and run initializer containers and all of components. | ||
Initializer containers will exit automatically. See more details in [docker-compose up][1]. | ||
|
||
For debugging purposes, pulling, building and running can be executed separated. | ||
Below script creates separated GNOME Terminal tab for each pulling and building of services: | ||
|
||
`./build-all_gnome-terminal.sh` | ||
|
||
Press any key if all of images already pulled, in order to start building. | ||
Below messages may not be error: | ||
* `ERROR: manifest for <service image> not found` | ||
* `<service> uses an image, skipping` | ||
|
||
Initializer containers must be run only once. Example for running initializer containers, including its dependencies: | ||
|
||
`docker-compose --file docker-compose.yml --file compose-init.yml up mysql-init influxdb-init` | ||
|
||
After exit of initializer containers, stop all containers, for example: | ||
|
||
`docker-compose stop` | ||
|
||
Below script creates separated GNOME Terminal tab for each service up: | ||
|
||
`./up-all_gnome-terminal.sh` | ||
|
||
|
||
### Stop | ||
|
||
Default services can be stopped by below command: | ||
|
||
`docker-compose stop` | ||
|
||
Example command for stopping optional services (for example: initializer containers): | ||
|
||
`docker-compose --file docker-compose.yml --file compose-init.yml stop` | ||
|
||
See more details in [docker-compose stop][2]. | ||
|
||
### Start | ||
|
||
In case of all containers stopped, the simplest command for starting all default services is: | ||
|
||
`docker-compose up` | ||
|
||
Starting only one or a few containers can be by below command: | ||
|
||
`docker-compose start <service>...` | ||
|
||
See more details in [docker-compose start][3]. | ||
|
||
For debugging purposes, below script creates separated GNOME Terminal tab for each service up: | ||
|
||
`./up-all_gnome-terminal.sh` | ||
|
||
This script uses `up` command, so all of containers must be stopped before executing the script. | ||
|
||
|
||
### Down | ||
|
||
Below command stops and removes containers and images: | ||
|
||
`docker-compose --file docker-compose.yml --file compose-init.yml down -v` | ||
|
||
## Configuration | ||
|
||
More compose files can be specified to `docker-compose`, which combines them into a single configuration. | ||
Using alternate compose files is a good idea for keeping related service configuration of different use cases in sync. | ||
See more details in [Overview of docker-compose CLI][4]. | ||
|
||
Another preferred way for using different configuration is editing `.env` file or setting environment variables. | ||
See more details in [https://docs.docker.com/compose/env-file/][5] | ||
|
||
### Official Grafana | ||
|
||
Official Grafana service name is `grafana-official`. It has limitations to Monasca Keystone authentications, moreover, | ||
Monasca datasource plugin must be installed manually by below command: | ||
``` | ||
docker-compose exec grafana-official /bin/bash | ||
grafana-cli plugins install monasca-datasource | ||
exit | ||
``` | ||
Influx database can be accessed directly by using InfluxDB datasource. | ||
See default values for Grafana datasource options: | ||
|
||
| Option | Value | | ||
|----------|-----------------------| | ||
| Url | http://localhost:8086 | | ||
| Access | direct | | ||
| Database | mon | | ||
| User | mon_persister | | ||
| Password | password | | ||
|
||
Values are declared in [`monasca-persister-python`](../monasca-persister-python/README.md) | ||
|
||
## TODO | ||
|
||
[1]: https://docs.docker.com/compose/reference/up/ | ||
[2]: https://docs.docker.com/compose/reference/stop/ | ||
[3]: https://docs.docker.com/compose/reference/start/ | ||
[4]: https://docs.docker.com/compose/reference/overview/ | ||
[5]: https://docs.docker.com/compose/env-file/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
cd "$(dirname "$0")" | ||
source gnome-terminal_helper.sh | ||
|
||
docker-compose ${FILE_LIST} config --quiet || exit 1 | ||
|
||
FILE_LIST="--file docker-compose.yml --file compose-init.yml" | ||
SERVICE_LIST="$(docker-compose ${FILE_LIST} config --services)" | ||
|
||
echo -e "Services:\n${SERVICE_LIST}" | ||
|
||
echo | ||
do_compose "pull" "${FILE_LIST}" "$(docker-compose ${FILE_LIST} config --services)" | ||
|
||
echo "Press any key when all of images are already pulled..." | ||
read -n1 | ||
|
||
echo | ||
do_compose "build" "${FILE_LIST}" "$(docker-compose ${FILE_LIST} config --services)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version: '3' | ||
|
||
services: | ||
|
||
influxdb-init: | ||
image: monasca/influxdb-init:${INFLUXDB_INIT_TAG} | ||
build: | ||
context: ../influxdb-init | ||
container_name: ${CONTAINER_NAME_PREFIX}influxdb-init | ||
depends_on: | ||
- influxdb | ||
|
||
mysql-init: | ||
image: monasca/mysql-init:${MYSQL_INIT_TAG} | ||
build: | ||
context: ../mysql-init | ||
container_name: ${CONTAINER_NAME_PREFIX}mysql-init | ||
environment: | ||
MYSQL_INIT_DISABLE_REMOTE_ROOT: ${MYSQL_INIT_DISABLE_REMOTE_ROOT} | ||
MYSQL_INIT_RANDOM_PASSWORD: ${MYSQL_INIT_RANDOM_PASSWORD} | ||
depends_on: | ||
- mysql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: '3' | ||
|
||
services: | ||
|
||
monasca: | ||
environment: | ||
SIDECAR_URL: ${SIDECAR_URL} | ||
depends_on: | ||
- monasca-sidecar | ||
|
||
monasca-sidecar: | ||
image: timothyb89/monasca-sidecar:${MONASCA_SIDECAR_TAG} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
version: '3' | ||
|
||
services: | ||
|
||
influxdb: | ||
image: influxdb:${INFLUXDB_TAG} | ||
container_name: ${CONTAINER_NAME_PREFIX}influxdb | ||
environment: | ||
INFLUXDB_RETENTION_ENABLED: ${INFLUXDB_RETENTION_ENABLED} | ||
INFLUXDB_ADMIN_ENABLED: ${INFLUXDB_ADMIN_ENABLED} | ||
ports: | ||
- "8083:8083" | ||
- "8086:8086" | ||
|
||
zookeeper: | ||
image: zookeeper:${ZOOKEEPER_TAG} | ||
container_name: ${CONTAINER_NAME_PREFIX}zookeeper | ||
|
||
kafka: | ||
image: monasca/kafka:${KAFKA_TAG} | ||
build: | ||
context: ../kafka | ||
container_name: ${CONTAINER_NAME_PREFIX}kafka | ||
environment: | ||
ZOOKEEPER_CONNECTION_STRING: ${ZOOKEEPER_CONNECTION_STRING} | ||
KAFKA_DELETE_TOPIC_ENABLE: ${KAFKA_DELETE_TOPIC_ENABLE} | ||
KAFKA_TOPIC_CONFIG: ${KAFKA_TOPIC_CONFIG} | ||
KAFKA_CREATE_TOPICS: ${KAFKA_CREATE_TOPICS} | ||
depends_on: | ||
- zookeeper | ||
|
||
mysql: | ||
image: mysql:${MYSQL_TAG} | ||
container_name: ${CONTAINER_NAME_PREFIX}mysql | ||
environment: | ||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} | ||
|
||
keystone: | ||
image: monasca/keystone:${KEYSTONE_TAG} | ||
build: | ||
context: ../keystone | ||
container_name: ${CONTAINER_NAME_PREFIX}keystone | ||
environment: | ||
KEYSTONE_HOST: ${KEYSTONE_HOST} | ||
KEYSTONE_PASSWORD: ${KEYSTONE_PASSWORD} | ||
KEYSTONE_DATABASE_BACKEND: ${KEYSTONE_DATABASE_BACKEND} | ||
KEYSTONE_MYSQL_HOST: ${KEYSTONE_MYSQL_HOST} | ||
KEYSTONE_MYSQL_USER: ${KEYSTONE_MYSQL_USER} | ||
KEYSTONE_MYSQL_PASSWORD: ${KEYSTONE_MYSQL_PASSWORD} | ||
KEYSTONE_MYSQL_DATABASE: ${KEYSTONE_MYSQL_DATABASE} | ||
volumes: | ||
- ../keystone/preload.yml:/preload.yml | ||
depends_on: | ||
- mysql | ||
ports: | ||
- "5000:5000" | ||
- "35357:35357" | ||
|
||
monasca: | ||
image: monasca/api:${MONASCA_API_TAG} | ||
build: | ||
context: ../monasca-api-python | ||
container_name: ${CONTAINER_NAME_PREFIX}monasca-api | ||
depends_on: | ||
- influxdb | ||
- keystone | ||
- mysql | ||
- zookeeper | ||
- kafka | ||
ports: | ||
- "8070:8070" | ||
|
||
monasca-persister: | ||
image: monasca/persister:${MONASCA_PERSISTER_TAG} | ||
build: | ||
context: ../monasca-persister-python | ||
container_name: ${CONTAINER_NAME_PREFIX}monasca-persister | ||
depends_on: | ||
- monasca | ||
- influxdb | ||
- zookeeper | ||
- kafka | ||
|
||
grafana-official: | ||
image: grafana/grafana:${GRAFANA_OFFICIAL_TAG} | ||
container_name: ${CONTAINER_NAME_PREFIX}grafana-official | ||
environment: | ||
GF_SERVER_ROOT_URL: ${GF_SERVER_ROOT_URL} | ||
GF_AUTH_ANONYMOUS_ENABLED: ${GF_AUTH_ANONYMOUS_ENABLED} | ||
ports: | ||
- "3000:3000" | ||
depends_on: | ||
- keystone | ||
- monasca |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#@IgnoreInspection BashAddShebang | ||
function do_compose { | ||
COMPOSE_COMMAND=$1 | ||
FILE_LIST=$2 | ||
SERVICE_LIST=$3 | ||
|
||
TERM_CMD="gnome-terminal --geometry=132x43" | ||
for i in ${SERVICE_LIST}; do | ||
TERM_CMD="${TERM_CMD} --tab --command 'bash -c \"printf \\\"\033]0;${i}\007\\\"; docker-compose ${FILE_LIST} ${COMPOSE_COMMAND} ${i}; read -n1;\"'" | ||
done; | ||
|
||
echo "docker-compose ${COMPOSE_COMMAND}" | ||
eval "${TERM_CMD}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
cd "$(dirname "$0")" | ||
source gnome-terminal_helper.sh | ||
|
||
docker-compose ${FILE_LIST} config --quiet || exit 1 | ||
|
||
FILE_LIST="--file docker-compose.yml" | ||
SERVICE_LIST="$(docker-compose ${FILE_LIST} config --services)" | ||
|
||
echo -e "Services:\n${SERVICE_LIST}" | ||
|
||
echo | ||
do_compose "up" "${FILE_LIST}" "$(docker-compose ${FILE_LIST} config --services)" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to use monasca/grafana here? It installs keystone auth and the monasca datasource plugin automatically (and can be configured with grafana-init)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too strong reason, see my long answer.