From 468cd6e24f4cd973e43dd0dd8a5707791b3bb49c Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Tue, 11 Apr 2017 11:42:31 +0530 Subject: [PATCH 1/3] Added functional elastic search container with v2.4 on openshift. Currently only 2.4 is functional on openshift due to issues with sysctl. I have created the 5.x container as well but its not currently operational on openshift, but it works if sysctl is configured with vm.max_map_count=262144. So more work will need to be done once kubernetes fixes sysctl issue. --- elasticsearch/centos7/Dockerfile.24 | 18 +++++++ elasticsearch/centos7/Dockerfile.53 | 16 +++++++ elasticsearch/centos7/fix-permissions.sh | 8 ++++ elasticsearch/centos7/install.sh | 48 +++++++++++++++++++ .../centos7/install_older_versions.sh | 37 ++++++++++++++ elasticsearch/centos7/passwd.template | 14 ++++++ elasticsearch/centos7/run.sh | 29 +++++++++++ 7 files changed, 170 insertions(+) create mode 100644 elasticsearch/centos7/Dockerfile.24 create mode 100644 elasticsearch/centos7/Dockerfile.53 create mode 100755 elasticsearch/centos7/fix-permissions.sh create mode 100755 elasticsearch/centos7/install.sh create mode 100755 elasticsearch/centos7/install_older_versions.sh create mode 100644 elasticsearch/centos7/passwd.template create mode 100755 elasticsearch/centos7/run.sh diff --git a/elasticsearch/centos7/Dockerfile.24 b/elasticsearch/centos7/Dockerfile.24 new file mode 100644 index 00000000..f5dadfbf --- /dev/null +++ b/elasticsearch/centos7/Dockerfile.24 @@ -0,0 +1,18 @@ +FROM registry.centos.org/centos/centos:7 + +MAINTAINER Mohammed Zeeshan Ahmed + +# RUN yum -y update && yum clean all + +ENV ELASTIC_MAJOR_VERSION="2.4.0" + +ADD fix-permissions.sh install_older_versions.sh run.sh passwd.template /opt/scripts/ + +RUN . /opt/scripts/install_older_versions.sh + +USER elasticsearch + +EXPOSE 9200 9300 + +ENTRYPOINT ["/opt/scripts/run.sh"] +CMD ["elastic"] diff --git a/elasticsearch/centos7/Dockerfile.53 b/elasticsearch/centos7/Dockerfile.53 new file mode 100644 index 00000000..170db2f5 --- /dev/null +++ b/elasticsearch/centos7/Dockerfile.53 @@ -0,0 +1,16 @@ +FROM registry.centos.org/centos/centos:7 + +MAINTAINER Mohammed Zeeshan Ahmed + +# RUN yum -y update && yum clean all + +ADD fix-permissions.sh install.sh run.sh passwd.template /opt/scripts/ + +RUN . /opt/scripts/install.sh + +USER 1001 + +EXPOSE 9200 9300 + +ENTRYPOINT ["/opt/scripts/run.sh"] +CMD ["elastic"] diff --git a/elasticsearch/centos7/fix-permissions.sh b/elasticsearch/centos7/fix-permissions.sh new file mode 100755 index 00000000..40df1386 --- /dev/null +++ b/elasticsearch/centos7/fix-permissions.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# Fix permissions on the given directory to allow group read/write of +# regular files and execute of directories. +set -eux +find "$1" -exec chown ${2} {} \; +find "$1" -exec chgrp 0 {} \; +find "$1" -exec chmod g+rw {} \; +find "$1" -type d -exec chmod g+x {} + diff --git a/elasticsearch/centos7/install.sh b/elasticsearch/centos7/install.sh new file mode 100755 index 00000000..cb04fd4b --- /dev/null +++ b/elasticsearch/centos7/install.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +set -eux; + +# Initialize Variables + +ELASTIC_SEARCH_GPG_KEY="https://artifacts.elastic.co/GPG-KEY-elasticsearch" +ELASTIC_REPO_FILE_LOCATION="/etc/yum.repos.d/elastic.repo" +ELASTIC_CONFIG="/etc/elasticsearch/elasticsearch.yml" +ELASTIC_CONFIG_BAK="/etc/elasticsearch/elasticsearch.yml.bak" +ELASTIC_MAJOR_VERSION=${ELASTIC_MAJOR_VERSION:-"5.x"} +BASIC_PACKAGES="java-1.8.0-openjdk nss_wrapper gettext" +SYSCTL_CONF="/etc/sysctl.conf" + +# Install Begins + +# Install epel +yum -y install epel-release; + +# Configure Elastic Repo +cat >${ELASTIC_REPO_FILE_LOCATION} < /tmp/passwd; +export LD_PRELOAD=libnss_wrapper.so; +export NSS_WRAPPER_PASSWD=/tmp/passwd; +export NSS_WRAPPER_GROUP=/etc/group; +ELASTIC_CONFIG="/etc/elasticsearch/elasticsearch.yml"; +ELASTIC_CONFIG_BAK="/etc/elasticsearch/elasticsearch.yml.bak"; + +rm -rf ${ELASTIC_CONFIG}; +cp ${ELASTIC_CONFIG_BAK} ${ELASTIC_CONFIG}; + +cat >>${ELASTIC_CONFIG} < Date: Tue, 11 Apr 2017 12:08:00 +0530 Subject: [PATCH 2/3] Uncommented the yum update. --- elasticsearch/centos7/Dockerfile.24 | 2 +- elasticsearch/centos7/Dockerfile.53 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch/centos7/Dockerfile.24 b/elasticsearch/centos7/Dockerfile.24 index f5dadfbf..891e9ee5 100644 --- a/elasticsearch/centos7/Dockerfile.24 +++ b/elasticsearch/centos7/Dockerfile.24 @@ -2,7 +2,7 @@ FROM registry.centos.org/centos/centos:7 MAINTAINER Mohammed Zeeshan Ahmed -# RUN yum -y update && yum clean all +RUN yum -y update && yum clean all ENV ELASTIC_MAJOR_VERSION="2.4.0" diff --git a/elasticsearch/centos7/Dockerfile.53 b/elasticsearch/centos7/Dockerfile.53 index 170db2f5..2c68b0ed 100644 --- a/elasticsearch/centos7/Dockerfile.53 +++ b/elasticsearch/centos7/Dockerfile.53 @@ -2,7 +2,7 @@ FROM registry.centos.org/centos/centos:7 MAINTAINER Mohammed Zeeshan Ahmed -# RUN yum -y update && yum clean all +RUN yum -y update && yum clean all ADD fix-permissions.sh install.sh run.sh passwd.template /opt/scripts/ From f2a2b48afa712bd81a739c6a4b8611cbf590cfa3 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Tue, 11 Apr 2017 12:22:57 +0530 Subject: [PATCH 3/3] Added missing cccp.yml for building on pipeline. --- elasticsearch/centos7/cccp.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 elasticsearch/centos7/cccp.yml diff --git a/elasticsearch/centos7/cccp.yml b/elasticsearch/centos7/cccp.yml new file mode 100644 index 00000000..f5bf97f7 --- /dev/null +++ b/elasticsearch/centos7/cccp.yml @@ -0,0 +1 @@ +job-id: elasticsearch