From 5edbbeca419f5f79397b9da029988a499e67682b Mon Sep 17 00:00:00 2001 From: Tim Schoof <tim.schoof@desy.de> Date: Fri, 6 Mar 2020 18:15:34 +0100 Subject: [PATCH] Create logs database on influxdb startup The network mode is changed to bridge because the influxdb image entrypoint script uses hardcoded ports for the influxdb instance it starts before executing the setup scripts --- .../scripts/influxdb/create_db_logs.sh.tpl | 3 +++ .../scripts/monitoring.nmd.tpl | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 deploy/asapo_orchestration_docker/scripts/influxdb/create_db_logs.sh.tpl diff --git a/deploy/asapo_orchestration_docker/scripts/influxdb/create_db_logs.sh.tpl b/deploy/asapo_orchestration_docker/scripts/influxdb/create_db_logs.sh.tpl new file mode 100644 index 000000000..52a7b788d --- /dev/null +++ b/deploy/asapo_orchestration_docker/scripts/influxdb/create_db_logs.sh.tpl @@ -0,0 +1,3 @@ +set -x + +influx -execute "CREATE DATABASE logs" diff --git a/deploy/asapo_orchestration_docker/scripts/monitoring.nmd.tpl b/deploy/asapo_orchestration_docker/scripts/monitoring.nmd.tpl index e0282a8db..33dd52f41 100644 --- a/deploy/asapo_orchestration_docker/scripts/monitoring.nmd.tpl +++ b/deploy/asapo_orchestration_docker/scripts/monitoring.nmd.tpl @@ -30,15 +30,17 @@ job "monitoring" { driver = "docker" user = "${asapo_user}" config { - network_mode = "host" + network_mode = "bridge" security_opt = ["no-new-privileges"] userns_mode = "host" image = "influxdb:${influxdb_version}" - volumes = ["/${service_dir}/influxdb:/var/lib/influxdb"] + volumes = [ + "/${service_dir}/influxdb:/var/lib/influxdb", + "local/influxdb:/docker-entrypoint-initdb.d"] + command = "influxd" } env { - PRE_CREATE_DB="asapo_receivers;asapo_brokers" INFLUXDB_BIND_ADDRESS="127.0.0.1:$${NOMAD_PORT_influxdb_rpc}" INFLUXDB_HTTP_BIND_ADDRESS=":$${NOMAD_PORT_influxdb}" } @@ -70,6 +72,10 @@ job "monitoring" { } } + template { + source = "${scripts_dir}/influxdb/create_db_logs.sh.tpl" + destination = "local/influxdb/create_db_logs.sh" + } } #influxdb -- GitLab