From e4c698f4ece22b2fe2b212801b6d5597c91535e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ferenc=20T=C3=B3th?= Date: Mon, 14 Oct 2019 20:57:11 +0200 Subject: [PATCH 1/1] Simplify ElasticSearch to make it more robust MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - No more master/data nodes, only all-purpose ES nodes - ES upgrade from 7.3.0 to 7.4.0 - Upgrade to `java-latest-openjdk-headless`, which is java 13 - Move supervisord.conf to ES image from configmap Signed-off-by: Ferenc Tóth Change-Id: I5dbfe6ca3c3e21439a3e11302b622969b3e86870 --- SPECS/elasticsearch.spec | 4 +- docker-build/elasticsearch/Dockerfile | 8 ++-- .../elasticsearch/elasticsearch-logrotate.sh | 10 +--- .../elasticsearch/elasticsearch-setindex.sh | 2 +- docker-build/elasticsearch/supervisord.conf | 55 ++++++++++++++++++++++ 5 files changed, 64 insertions(+), 15 deletions(-) create mode 100644 docker-build/elasticsearch/supervisord.conf diff --git a/SPECS/elasticsearch.spec b/SPECS/elasticsearch.spec index bd5f275..08c8022 100644 --- a/SPECS/elasticsearch.spec +++ b/SPECS/elasticsearch.spec @@ -14,8 +14,8 @@ %define COMPONENT elasticsearch %define RPM_NAME caas-%{COMPONENT} -%define RPM_MAJOR_VERSION 7.3.0 -%define RPM_MINOR_VERSION 2 +%define RPM_MAJOR_VERSION 7.4.0 +%define RPM_MINOR_VERSION 0 %define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION} %define centos_build 191001 diff --git a/docker-build/elasticsearch/Dockerfile b/docker-build/elasticsearch/Dockerfile index ab6d209..bf4ad19 100644 --- a/docker-build/elasticsearch/Dockerfile +++ b/docker-build/elasticsearch/Dockerfile @@ -18,12 +18,11 @@ CMD ["/bin/bash"] MAINTAINER Levente Kale ARG VERSION -ENV ES_VERSION=$VERSION ENV PATH /usr/share/elasticsearch/bin:$PATH -ENV JAVA_HOME /usr/lib/jvm/jre-1.8.0-openjdk +ENV JAVA_HOME /usr/lib/jvm/jre-13-openjdk ENV DOWNLOAD_URL "https://artifacts.elastic.co/downloads/elasticsearch" -ENV ES_TARBAL "${DOWNLOAD_URL}/elasticsearch-oss-${ES_VERSION}-linux-x86_64.tar.gz" +ENV ES_TARBAL "${DOWNLOAD_URL}/elasticsearch-oss-${VERSION}-linux-x86_64.tar.gz" WORKDIR /usr/share/elasticsearch @@ -31,7 +30,7 @@ RUN groupadd -g 202 elasticsearch \ && adduser -u 202 -g 202 -d /usr/share/elasticsearch elasticsearch \ && yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \ && yum install -y --setopt=skip_missing_names_on_install=False \ - java-1.8.0-openjdk-headless \ + java-latest-openjdk-headless \ unzip \ which \ coreutils \ @@ -49,3 +48,4 @@ RUN groupadd -g 202 elasticsearch \ COPY elasticsearch-logrotate.sh /etc/cron.hourly/ COPY elasticsearch-setindex.sh /usr/share/elasticsearch/ COPY log4j2.properties /usr/share/elasticsearch/config/ +COPY supervisord.conf /etc/ diff --git a/docker-build/elasticsearch/elasticsearch-logrotate.sh b/docker-build/elasticsearch/elasticsearch-logrotate.sh index 989aedb..06e36e7 100755 --- a/docker-build/elasticsearch/elasticsearch-logrotate.sh +++ b/docker-build/elasticsearch/elasticsearch-logrotate.sh @@ -15,7 +15,7 @@ FS_LIMIT=80 DOCS_DROP=100000 -ES_URL="http://localhost:$ELASTICSEARCH_LOGGING_SERVICE_PORT" +ES_URL="http://localhost:$ELASTICSEARCH_SERVICE_PORT" log () { echo "LOGROTATE: $*" >/proc/1/fd/1 @@ -23,13 +23,7 @@ log () { log "hourly job started" -IFS='-' read es type num <<< "$HOSTNAME" -if [[ "$type" != "data" ]]; then - log "non-data node -> exiting" - exit 0 -fi - -# sleep to avoid concurrent runs across multiple ES data Pods +# sleep to avoid concurrent runs across multiple ES Pods let "SLEEP=($num * 600)+($RANDOM % 30)" log "sleeping $SLEEP seconds..." sleep $SLEEP diff --git a/docker-build/elasticsearch/elasticsearch-setindex.sh b/docker-build/elasticsearch/elasticsearch-setindex.sh index d931e3b..df3467b 100755 --- a/docker-build/elasticsearch/elasticsearch-setindex.sh +++ b/docker-build/elasticsearch/elasticsearch-setindex.sh @@ -16,7 +16,7 @@ ack="false" while [ "$ack" != "true" ] do - response=$(curl -sS -XPUT "http://localhost:$ELASTICSEARCH_LOGGING_SERVICE_PORT/_template/default_template" -H 'Content-Type: application/json' -d' + response=$(curl -sS -XPUT "http://localhost:$ELASTICSEARCH_SERVICE_PORT/_template/default_template" -H 'Content-Type: application/json' -d' { "index_patterns": ["*"], "settings": { diff --git a/docker-build/elasticsearch/supervisord.conf b/docker-build/elasticsearch/supervisord.conf new file mode 100644 index 0000000..0a87d34 --- /dev/null +++ b/docker-build/elasticsearch/supervisord.conf @@ -0,0 +1,55 @@ +[unix_http_server] +file=/run/supervisord.sock ; (the path to the socket file) +chmod = 0770 +chown = root:root +username = dummy +password = dummy + +[supervisord] +user=root +logfile=/dev/null +logfile_maxbytes=0 +loglevel=info +pidfile=/var/run/supervisor/supervisord.pid +nodaemon=true +minfds=1024 +minprocs=200 + +[supervisorctl] +serverurl=unix:///run/supervisord.sock +username = dummy +password = dummy + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[program:elasticsearch] +command=/usr/share/elasticsearch/bin/elasticsearch +user=202 +startsecs=3 +startretries=1 +stopwaitsecs = 3 +priority = 1 +redirect_stderr=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 + +[program:crond] +command=/usr/sbin/crond -n -s +startsecs=3 +startretries=1 +stopwaitsecs = 3 +priority = 2 +redirect_stderr=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 + +[program:setindex] +command=/usr/share/elasticsearch/elasticsearch-setindex.sh +startsecs=3 +startretries=1 +stopwaitsecs = 3 +priority = 2 +redirect_stderr=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 -- 2.16.6