performance-analyzer
performance-analyzer copied to clipboard
Allow performance-analyzer webservice-listener and rpc ports to be changed in docker build
Problem
When running multiple instances in docker, while using the host networking interface for performance reasons, performance analyzers trying to bind to the same port causes containers to die.
Solution?
Allow these aforementioned ports to be changed via environment variables. plugins.pa_webservice_listener_port: 9651 plugins.pa_rpc_port: 9601
Or better yet, make configuration with environment variables more expressive and easier to manage:
version: "3.9"
services:
opensearch-node:
image: opensearchproject/opensearch:1..3.0
environment:
# OPENSEARCH_<opensearch.yml settings>
OPENSEARCH_CLUSTER_NAME: opensearch-cluster
OPENSEARCH_DISCOVERY_TYPE: single-node
OPENSEARCH_HTTP_PORT: 9201
OPENSEARCH_TRANSPORT_PORT: 9301
# OPENSEARCH_PLUGINS_<plugin-name>_<plugin-setting>
OPENSEARCH_PLUGINS_PA_WEBSERVICE_LISTENER_PORT: 9651
OPENSEARCH_PLUGINS_PA_RPC_PORT: 9601
OPENSEARCH_PLUGINS_SECURITY_KEYSTORE_PATH: /usr/share/opensearch/keystore.jks
OPENSEARCH_PLUGINS_SECURITY_KEYSTORE_PASSWORD: p@ssword!
...
I think this naming scheme would make it so much easier to configure containers using environment variables. Because as it is, if I'm not mistaken you're just splitting environment variables by a "=" and only capturing key=value pairs for opensearch options. As seen here:
# Parse Docker env vars to customize OpenSearch
#
# e.g. Setting the env var cluster.name=testcluster
# will cause OpenSearch to be invoked with -Ecluster.name=testcluster
opensearch_opts=()
while IFS='=' read -r envvar_key envvar_value
do
# OpenSearch settings need to have at least two dot separated lowercase
# words, e.g. `cluster.name`, except for `processors` which we handle
# specially
if [[ "$envvar_key" =~ ^[a-z0-9_]+\.[a-z0-9_]+ || "$envvar_key" == "processors" ]]; then
if [[ ! -z $envvar_value ]]; then
opensearch_opt="-E${envvar_key}=${envvar_value}"
opensearch_opts+=("${opensearch_opt}")
fi
fi
done < <(env)
I've tried
Mounting the performance-analyzer.properties files manually to force the behaviour. For some reason it didn't work, and documentation being lacking I cannot find a work around.
@DogukanL would you be able to open a PR for this if passing an environment variable worked for you?
Hi,
someone mixed it up, please double check!
PORT
it actually is:
- 960x -> for the Performance analyzer webservice-listener
- 965x -> for the RCA
# WebService exposed by App's port
webservice-listener-port = 9600
#...
# Port for RPC Communication
rpc-port = 9650
BIND to Interface
in addition please make the BIND host also available as config + environment variable:
# WebService bind host; default only to local interface
webservice-bind-host = 0.0.0.0
the RCA bind option is missing in the performance-analyzer.properties please implement this.
Please note that both, BIND and PORT is required for a docker based (host mode) and/or native multnode installation on a single host !