[Why]
"logging-es" and "master-fluentd" may be on different services and may
be performed over the network.
In this scenario, the logging-es information needs to be obtained from
the configuretion file.
Signed-off-by: Wu Zhende <wuzhende666(a)163.com>
---
container/master-fluentd/docker-fluentd.conf | 4 ++--
container/master-fluentd/start | 14 +++++++++++++-
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/container/master-fluentd/docker-fluentd.conf b/container/master-fluentd/docker-fluentd.conf
index 4660988..a57d4cd 100644
--- a/container/master-fluentd/docker-fluentd.conf
+++ b/container/master-fluentd/docker-fluentd.conf
@@ -40,8 +40,8 @@
<store>
@type elasticsearch
- host 172.17.0.1
- port 9202
+ host "#{ENV['LOGGING_ES_HOST']}"
+ port "#{ENV['LOGGING_ES_PORT']}"
suppress_type_name true
flush_interval 1s
index_name ${tag}
diff --git a/container/master-fluentd/start b/container/master-fluentd/start
index b3e3dbb..a05881c 100755
--- a/container/master-fluentd/start
+++ b/container/master-fluentd/start
@@ -3,9 +3,20 @@
# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
# frozen_string_literal: true
+require 'set'
require_relative '../defconfig.rb'
-docker_rm "master-fluentd"
+names = Set.new %w[
+ LOGGING_ES_HOST
+ LOGGING_ES_PORT
+]
+
+defaults = relevant_defaults(names)
+defaults['LOGGING_ES_HOST'] ||= '172.17.0.1'
+defaults['LOGGING_ES_PORT'] ||= '9202'
+env = docker_env(defaults)
+
+docker_rm 'master-fluentd'
cmd = %w[
docker run
@@ -13,6 +24,7 @@ cmd = %w[
--name master-fluentd
-v /etc/localtime:/etc/localtime:ro
-d
+] + env + %w[
-u 1090:1090
-p 24224:24224/tcp
-p 24224:24224/udp
--
2.23.0