我们当然在AWS上运行了EKS和工作程序节点。我们正在使用gcr.io/google_containers/elasticsearch:v6.3.0。但是,现在我们想添加策展人以拍摄ES索引的快照并将其存储在S3存储桶中。为此,ES需要一个repository-s3插件。
因此,我们决定扩展此映像,并使用安装的插件创建自己的映像。 Dockerfile是:
FROM gcr.io/google_containers/elasticsearch:v6.3.0
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch repository-s3
这将返回:
Step 2/2 : RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch repository-s3
---> Running in 8d96a792a7e3
Exception in thread "main" java.lang.IllegalArgumentException: Could not resolve placeholder 'MINIMUM_MASTER_NODES'
at org.elasticsearch.common.settings.PropertyPlaceholder.parseStringValue(PropertyPlaceholder.java:116)
at org.elasticsearch.common.settings.PropertyPlaceholder.replacePlaceholders(PropertyPlaceholder.java:69)
at org.elasticsearch.common.settings.Settings$Builder.replacePropertyPlaceholders(Settings.java:1263)
at org.elasticsearch.common.settings.Settings$Builder.replacePropertyPlaceholders(Settings.java:1213)
at org.elasticsearch.node.InternalSettingsPreparer.initializeSettings(InternalSettingsPreparer.java:128)
at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:107)
at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:95)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:79)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
at org.elasticsearch.cli.Command.main(Command.java:90)
at org.elasticsearch.plugins.PluginCli.main(PluginCli.java:48)
The command '/bin/sh -c /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch repository-s3' returned a non-zero code: 1
当我尝试在正在运行的es实例上安装插件时,也会发生同样的事情。
然后我可以向elasticsearch用户进行sudo并再次运行该命令,但仍然出现相同的问题:
似乎环境缺少以下变量,因为当我使用ARG将它们添加到Dockerfile中时,它似乎完成了映像(当然这些值是硬编码的,只是为了证明这一点):
MINIMUM_MASTER_NODES
HTTP_PORT
NODE_DATA
NODE_MASTER
NODE_NAME
TRANSPORT_PORT
不确定整个故事中我缺少什么。
答案 0 :(得分:0)
插件安装程序希望可以从配置中设置或读取这些变量。这些是您的Elasticsearch配置中的参数。 elasticsearch.yml
,jvm.options
和log4j2.properties
文件所在的目录是哪个目录?您可以尝试:
ES_PATH_CONF=/path/to/my/config /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch repository-s3
在运行脚本之前设置环境变量:
export MINIMUM_MASTER_NODES=<value>
export HTTP_PORT=<value>
export NODE_DATA=<value>
export NODE_MASTER=<value>
export NODE_NAME=<value>
export TRANSPORT_PORT=<value>
/usr/share/elasticsearch/bin/elasticsearch-plugin install --batch repository-s3
在构建映像时,使用Dockerfile中的ENV
关键字添加这些参数。 Dockerfile:
FROM gcr.io/google_containers/elasticsearch:v6.3.0
ENV MINIMUM_MASTER_NODES=<value>
ENV HTTP_PORT=<value>
ENV NODE_DATA=<value>
ENV NODE_MASTER=<value>
ENV NODE_NAME=<value>
ENV TRANSPORT_PORT=<value>
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch repository-s3
答案 1 :(得分:0)
Configuring the Dockerfile as below does the trick. It is important to have ARG rather than ENV as ARG is only used at build time. At run time it is elasticsearch provides the environment variables so we don't have to worry about that.
FROM gcr.io/google_containers/elasticsearch:v6.3.0
ARG MINIMUM_MASTER_NODES=${MINIMUM_MASTER_NODES}
ARG HTTP_PORT=${HTTP_PORT}
ARG NODE_DATA=${NODE_DATA}
ARG NODE_MASTER=${NODE_MASTER}
ARG NODE_NAME=${NODE_NAME}
ARG TRANSPORT_PORT=${TRANSPORT_PORT}
RUN su elasticsearch -c "/usr/share/elasticsearch/bin/elasticsearch-plugin install --batch repository-s3"