test
This commit is contained in:
@@ -1,3 +1,20 @@
|
|||||||
ARG BASE_IMAGE=opensearchproject/opensearch:latest
|
ARG BASE_IMAGE=opensearchproject/opensearch:latest
|
||||||
FROM ${BASE_IMAGE}
|
FROM ${BASE_IMAGE}
|
||||||
|
|
||||||
|
# Install dependencies for configuration
|
||||||
|
RUN microdnf update -y && \
|
||||||
|
microdnf install -y gettext bash jq && \
|
||||||
|
microdnf clean all
|
||||||
|
|
||||||
|
# Copy configuration files and scripts
|
||||||
COPY rootfs/ /
|
COPY rootfs/ /
|
||||||
|
|
||||||
|
# Create directories and set permissions
|
||||||
|
RUN mkdir -p /usr/share/opensearch/config/jvm.options.d && \
|
||||||
|
chown -R opensearch:opensearch /usr/share/opensearch && \
|
||||||
|
chmod +x /usr/bin/configure-opensearch
|
||||||
|
|
||||||
|
USER opensearch
|
||||||
|
|
||||||
|
# Use our custom entrypoint script
|
||||||
|
ENTRYPOINT ["/usr/bin/configure-opensearch"]
|
@@ -1,76 +1,46 @@
|
|||||||
{
|
{
|
||||||
"name": "OpenSearch os-master",
|
"name": "OpenSearch Cluster Node",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"slug": "opensearch-master",
|
"slug": "opensearch-node",
|
||||||
"description": "OpenSearch server (es-compatible) for logs and metrics. Configurable JVM heap, node roles, cluster discovery and volumes.",
|
"description": "OpenSearch cluster node with configurable roles",
|
||||||
"arch": ["amd64", "armv7", "aarch64"],
|
"arch": ["amd64", "armv7", "aarch64"],
|
||||||
"startup": "services",
|
"startup": "services",
|
||||||
"boot": "auto",
|
"boot": "auto",
|
||||||
"host_network": true,
|
"host_network": true,
|
||||||
"host_pid": false,
|
"init": false,
|
||||||
"map": [
|
"map": [
|
||||||
[
|
["config", "/usr/share/opensearch/config", "rw"],
|
||||||
"config",
|
["data", "/usr/share/opensearch/data", "rw"],
|
||||||
"./config",
|
["logs", "/usr/share/opensearch/logs", "rw"]
|
||||||
"rw"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"data",
|
|
||||||
"/var/lib/opensearch",
|
|
||||||
"rw"
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
"options": {
|
"options": {
|
||||||
|
"node_role": ["master"],
|
||||||
"cluster_name": "hass-opensearch-cluster",
|
"cluster_name": "hass-opensearch-cluster",
|
||||||
"node_name": "os-master",
|
"node_name": "os-master",
|
||||||
"node_roles": [
|
"heap_size": "2g",
|
||||||
"master"
|
|
||||||
],
|
|
||||||
"discovery_type": "single-node",
|
|
||||||
"discovery_seed_hosts": ["os-master", "os-data-1", "os-data-2"],
|
|
||||||
"initial_master_nodes": ["os-master"],
|
|
||||||
"opensearch_heap": "1.5g",
|
|
||||||
"plugins": [],
|
|
||||||
"bootstrap_memory_lock": false,
|
|
||||||
"http_port": 9200,
|
"http_port": 9200,
|
||||||
"transport_port": 9300,
|
"transport_port": 9300,
|
||||||
"network_host": "0.0.0.0",
|
"discovery_seed_hosts": ["os-master:9300"],
|
||||||
"path_data": "/var/lib/opensearch",
|
"initial_master_nodes": ["os-master"],
|
||||||
"path_logs": "/var/log/opensearch",
|
|
||||||
"security_enabled": true,
|
"security_enabled": true,
|
||||||
"admin_password": "MyOpenSearch25!!"
|
"admin_password": "SecurePass123!",
|
||||||
|
"plugins": []
|
||||||
},
|
},
|
||||||
"schema": {
|
"schema": {
|
||||||
|
"node_role": ["str"],
|
||||||
"cluster_name": "str",
|
"cluster_name": "str",
|
||||||
"node_name": "str",
|
"node_name": "str",
|
||||||
"node_roles": [
|
"heap_size": "str",
|
||||||
"str"
|
|
||||||
],
|
|
||||||
"discovery_type": "str",
|
|
||||||
"discovery_seed_hosts": [
|
|
||||||
"str"
|
|
||||||
],
|
|
||||||
"initial_master_nodes": [
|
|
||||||
"str"
|
|
||||||
],
|
|
||||||
"opensearch_heap": "str",
|
|
||||||
"plugins": [
|
|
||||||
"str"
|
|
||||||
],
|
|
||||||
"bootstrap_memory_lock": "bool",
|
|
||||||
"http_port": "int",
|
"http_port": "int",
|
||||||
"transport_port": "int",
|
"transport_port": "int",
|
||||||
"network_host": "str",
|
"discovery_seed_hosts": ["str"],
|
||||||
"path_data": "str",
|
"initial_master_nodes": ["str"],
|
||||||
"path_logs": "str",
|
|
||||||
"security_enabled": "bool",
|
"security_enabled": "bool",
|
||||||
"admin_password": "password"
|
"admin_password": "password",
|
||||||
|
"plugins": ["str"]
|
||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"9200/tcp": 9200,
|
"9200/tcp": 9200,
|
||||||
"9300/tcp": 9300
|
"9300/tcp": 9300
|
||||||
},
|
|
||||||
"environment": {
|
|
||||||
"OPENSEARCH_INITIAL_ADMIN_PASSWORD": "MyOpenSearch25!!"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,14 +0,0 @@
|
|||||||
#!/command/with-contenv bash
|
|
||||||
set -euo pipefail
|
|
||||||
SRC_DIR=/rootfs-config
|
|
||||||
DST_DIR=/usr/share/opensearch/config
|
|
||||||
if [ -d "$SRC_DIR" ]; then
|
|
||||||
echo "[cont-init] Copying config snippets from $SRC_DIR to $DST_DIR"
|
|
||||||
for f in "$SRC_DIR"/*; do
|
|
||||||
base=$(basename "$f")
|
|
||||||
if [ ! -f "$DST_DIR/$base" ]; then
|
|
||||||
cp "$f" "$DST_DIR/"
|
|
||||||
echo "[cont-init] Copied $base"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
@@ -1,27 +0,0 @@
|
|||||||
#!/command/with-contenv bash
|
|
||||||
set -euo pipefail
|
|
||||||
OPTIONS_FILE=/data/options.json
|
|
||||||
|
|
||||||
# Read options from Supervisor
|
|
||||||
admin_password=$(bashio::config 'admin_password')
|
|
||||||
|
|
||||||
# Export as environment variables for OpenSearch
|
|
||||||
export OPENSEARCH_INITIAL_ADMIN_PASSWORD="${admin_password}"
|
|
||||||
|
|
||||||
if [ ! -f "$OPTIONS_FILE" ]; then
|
|
||||||
echo "[cont-init] No options.json, skipping plugin install"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
if ! jq -e '.plugins // [] | length > 0' "$OPTIONS_FILE" >/dev/null 2>&1; then
|
|
||||||
echo "[cont-init] No plugins configured, skipping"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "[cont-init] Installing plugins from options.json"
|
|
||||||
jq -r '.plugins[]' "$OPTIONS_FILE" | while read -r plugin; do
|
|
||||||
echo "[cont-init] Installing plugin: $plugin"
|
|
||||||
if /usr/share/opensearch/bin/opensearch-plugin install --batch "$plugin"; then
|
|
||||||
echo "[cont-init] Installed $plugin"
|
|
||||||
else
|
|
||||||
echo "[cont-init] Failed to install $plugin (continuing)"
|
|
||||||
fi
|
|
||||||
done
|
|
@@ -0,0 +1,17 @@
|
|||||||
|
cluster.name: ${CLUSTER_NAME}
|
||||||
|
node.name: ${NODE_NAME}
|
||||||
|
node.roles: [${NODE_ROLE}]
|
||||||
|
|
||||||
|
path.data: /usr/share/opensearch/data
|
||||||
|
path.logs: /usr/share/opensearch/logs
|
||||||
|
|
||||||
|
network.host: 0.0.0.0
|
||||||
|
http.port: ${HTTP_PORT}
|
||||||
|
transport.port: ${TRANSPORT_PORT}
|
||||||
|
|
||||||
|
discovery.seed_hosts: [${DISCOVERY_SEEDS}]
|
||||||
|
cluster.initial_master_nodes: [${INITIAL_MASTERS}]
|
||||||
|
|
||||||
|
plugins.security.disabled: ${SECURITY_ENABLED}
|
||||||
|
|
||||||
|
action.auto_create_index: true
|
@@ -1,3 +0,0 @@
|
|||||||
#!/command/execlineb -S0
|
|
||||||
# Prevent restart loops; allow clean exit
|
|
||||||
exit 0
|
|
@@ -1,33 +0,0 @@
|
|||||||
#!/command/with-contenv bash
|
|
||||||
set -euo pipefail
|
|
||||||
OPTIONS_FILE=/data/options.json || true
|
|
||||||
NODE_NAME="os-master"
|
|
||||||
HEAP="1.5g"
|
|
||||||
CLUSTER_NAME="hass-opensearch-cluster"
|
|
||||||
HTTP_PORT=9200
|
|
||||||
TRANSPORT_PORT=9300
|
|
||||||
NODE_ROLES="master"
|
|
||||||
|
|
||||||
# override from options.json if present
|
|
||||||
if [ -f "$OPTIONS_FILE" ]; then
|
|
||||||
NODE_NAME=$(jq -r '.node_name // "os-master"' "$OPTIONS_FILE" 2>/dev/null || echo "os-master")
|
|
||||||
HEAP=$(jq -r '.opensearch_heap // "1.5g"' "$OPTIONS_FILE" 2>/dev/null || echo "1.5g")
|
|
||||||
CLUSTER_NAME=$(jq -r '.cluster_name // "hass-opensearch-cluster"' "$OPTIONS_FILE" 2>/dev/null || echo "hass-opensearch-cluster")
|
|
||||||
HTTP_PORT=$(jq -r '.http_port // 9200' "$OPTIONS_FILE" 2>/dev/null || echo 9200)
|
|
||||||
TRANSPORT_PORT=$(jq -r '.transport_port // 9300' "$OPTIONS_FILE" 2>/dev/null || echo 9300)
|
|
||||||
NODE_ROLES=$(jq -r '.node_roles // ["master"] | join(",")' "$OPTIONS_FILE" 2>/dev/null || echo "master")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Read options from Supervisor
|
|
||||||
admin_password=$(bashio::config 'admin_password')
|
|
||||||
opensearch_heap=$(bashio::config 'opensearch_heap')
|
|
||||||
|
|
||||||
# Export as environment variables for OpenSearch
|
|
||||||
export OPENSEARCH_INITIAL_ADMIN_PASSWORD="${admin_password}"
|
|
||||||
export OPENSEARCH_JAVA_OPTS="-Xms${opensearch_heap} -Xmx${opensearch_heap}"
|
|
||||||
|
|
||||||
echo "[s6-run] Starting OpenSearch node: $NODE_NAME roles:$NODE_ROLES heap:$HEAP http:$HTTP_PORT transport:$TRANSPORT_PORT"
|
|
||||||
|
|
||||||
exec /usr/share/opensearch/bin/opensearch \
|
|
||||||
-E cluster.name=$CLUSTER_NAME \
|
|
||||||
-E node.name=$NODE_NAME
|
|
@@ -1,8 +0,0 @@
|
|||||||
cluster.name: hass-opensearch-cluster
|
|
||||||
node.name: os-master
|
|
||||||
path.data: /var/lib/opensearch
|
|
||||||
path.logs: /var/log/opensearch
|
|
||||||
network.host: 0.0.0.0
|
|
||||||
http.port: 9200
|
|
||||||
transport.port: 9300
|
|
||||||
node.roles: ['master']
|
|
66
opensearch-master/rootfs/usr/bin/configure-opensearch
Normal file
66
opensearch-master/rootfs/usr/bin/configure-opensearch
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Function to read configuration using bashio if available
|
||||||
|
read_config() {
|
||||||
|
if command -v bashio >/dev/null 2>&1; then
|
||||||
|
bashio::config "$1"
|
||||||
|
else
|
||||||
|
# Fallback for testing outside Home Assistant
|
||||||
|
echo "Testing mode - using default values"
|
||||||
|
case "$1" in
|
||||||
|
"node_role") echo "master" ;;
|
||||||
|
"cluster_name") echo "hass-opensearch-cluster" ;;
|
||||||
|
"node_name") echo "os-node-1" ;;
|
||||||
|
"heap_size") echo "1g" ;;
|
||||||
|
"http_port") echo "9200" ;;
|
||||||
|
"transport_port") echo "9300" ;;
|
||||||
|
"discovery_seed_hosts") echo '["os-master:9300", "os-data-1:9300"]' ;;
|
||||||
|
"initial_master_nodes") echo '["os-master"]' ;;
|
||||||
|
"security_enabled") echo "true" ;;
|
||||||
|
"admin_password") echo "SecurePass123!" ;;
|
||||||
|
"plugins") echo "[]" ;;
|
||||||
|
*) echo "" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read configuration values
|
||||||
|
NODE_ROLE=$(read_config 'node_role' | tr -d '[]"' | tr ',' ' ')
|
||||||
|
CLUSTER_NAME=$(read_config 'cluster_name')
|
||||||
|
NODE_NAME=$(read_config 'node_name')
|
||||||
|
HEAP_SIZE=$(read_config 'heap_size')
|
||||||
|
HTTP_PORT=$(read_config 'http_port')
|
||||||
|
TRANSPORT_PORT=$(read_config 'transport_port')
|
||||||
|
DISCOVERY_SEEDS=$(read_config 'discovery_seed_hosts' | tr -d '[]" ' | tr ',' ' ')
|
||||||
|
INITIAL_MASTERS=$(read_config 'initial_master_nodes' | tr -d '[]" ' | tr ',' ' ')
|
||||||
|
SECURITY_ENABLED=$(read_config 'security_enabled')
|
||||||
|
ADMIN_PASSWORD=$(read_config 'admin_password')
|
||||||
|
|
||||||
|
# Export environment variables
|
||||||
|
export OPENSEARCH_INITIAL_ADMIN_PASSWORD="${ADMIN_PASSWORD}"
|
||||||
|
export DISCOVERY_TYPE="multi-node"
|
||||||
|
|
||||||
|
# Set heap size
|
||||||
|
echo "-Xms${HEAP_SIZE}" > /usr/share/opensearch/config/jvm.options.d/heap.options
|
||||||
|
echo "-Xmx${HEAP_SIZE}" >> /usr/share/opensearch/config/jvm.options.d/heap.options
|
||||||
|
|
||||||
|
# Export variables for envsubst
|
||||||
|
export CLUSTER_NAME NODE_NAME NODE_ROLE HTTP_PORT TRANSPORT_PORT
|
||||||
|
export DISCOVERY_SEEDS INITIAL_MASTERS SECURITY_ENABLED
|
||||||
|
|
||||||
|
# Generate opensearch.yml from template
|
||||||
|
envsubst < /etc/opensearch/opensearch.yml.template > /usr/share/opensearch/config/opensearch.yml
|
||||||
|
|
||||||
|
# Install plugins if specified
|
||||||
|
PLUGINS_JSON=$(read_config 'plugins')
|
||||||
|
if [ -n "$PLUGINS_JSON" ] && [ "$PLUGINS_JSON" != "[]" ]; then
|
||||||
|
# Extract plugins from JSON array
|
||||||
|
PLUGINS=$(echo "$PLUGINS_JSON" | tr -d '[]"' | tr ',' '\n' | sed 's/^ *//;s/ *$//')
|
||||||
|
for plugin in $PLUGINS; do
|
||||||
|
echo "Installing plugin: $plugin"
|
||||||
|
/usr/share/opensearch/bin/opensearch-plugin install --batch "$plugin" || true
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start OpenSearch (use exec to replace the current process)
|
||||||
|
exec /usr/share/opensearch/bin/opensearch
|
Reference in New Issue
Block a user