From abfb5713ae24799bc7fc2d5b007348fab154c4fd Mon Sep 17 00:00:00 2001 From: Piotr Parczewski Date: Tue, 22 Feb 2022 11:58:04 +0100 Subject: [PATCH] Add Opensearch image(s) Handles x86-64 and aarch64 targets. Change-Id: I70e2bb1d2744d38e08f5a9a79ab6a7265ebf24c9 --- .../opensearch-dashboards/Dockerfile.j2 | 37 +++++++++++++++++++ .../opensearch-dashboards/extend_start.sh | 17 +++++++++ docker/opensearch/opensearch/Dockerfile.j2 | 37 +++++++++++++++++++ docker/opensearch/opensearch/extend_start.sh | 8 ++++ kolla/common/config.py | 1 + kolla/common/users.py | 4 ++ .../notes/opensearch-f3a7b8bfc86a16f6.yaml | 4 ++ 7 files changed, 108 insertions(+) create mode 100644 docker/opensearch/opensearch-dashboards/Dockerfile.j2 create mode 100644 docker/opensearch/opensearch-dashboards/extend_start.sh create mode 100644 docker/opensearch/opensearch/Dockerfile.j2 create mode 100644 docker/opensearch/opensearch/extend_start.sh create mode 100644 releasenotes/notes/opensearch-f3a7b8bfc86a16f6.yaml diff --git a/docker/opensearch/opensearch-dashboards/Dockerfile.j2 b/docker/opensearch/opensearch-dashboards/Dockerfile.j2 new file mode 100644 index 0000000000..030ae925d4 --- /dev/null +++ b/docker/opensearch/opensearch-dashboards/Dockerfile.j2 @@ -0,0 +1,37 @@ +FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }} +{% block labels %} +LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}" +{% endblock %} + +{% block opensearch_header %}{% endblock %} + +{% import "macros.j2" as macros with context %} + +{{ macros.configure_user(name='opensearch', shell='/bin/bash', homedir='/usr/share/opensearch') }} + +{% block opensearch_version %} + + {% if base_arch == 'x86_64' %} + {% set arch_os='x64' %} + {% elif base_arch == 'aarch64' %} + {% set arch_os='arm64' %} + {% endif %} + +ARG opensearch_version=2.3.0 +ARG opensearch_dashboards_url=https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/${opensearch_version}/opensearch-dashboards-${opensearch_version}-linux-{{ arch_os }}.tar.gz +{% endblock %} + +ARG OPENSEARCH_DASHBOARDS_HOME=/usr/share/opensearch-dashboards + +RUN mkdir -p $OPENSEARCH_DASHBOARDS_HOME && \ + curl -o /tmp/opensearch-dashboards.tgz ${opensearch_dashboards_url} && \ + tar -xzpf /tmp/opensearch-dashboards.tgz -C $OPENSEARCH_DASHBOARDS_HOME --strip-components=1 && \ + rm /tmp/opensearch-dashboards.tgz + +COPY extend_start.sh /usr/local/bin/kolla_extend_start +RUN chmod 755 /usr/local/bin/kolla_extend_start + +{% block opensearch_footer %}{% endblock %} +{% block footer %}{% endblock %} + +USER opensearch diff --git a/docker/opensearch/opensearch-dashboards/extend_start.sh b/docker/opensearch/opensearch-dashboards/extend_start.sh new file mode 100644 index 0000000000..fa7872738f --- /dev/null +++ b/docker/opensearch/opensearch-dashboards/extend_start.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +if [[ ! -d "/var/log/kolla/opensearch" ]]; then + mkdir -p /var/log/kolla/opensearch +fi +if [[ $(stat -c %a /var/log/kolla/opensearch) != "755" ]]; then + chmod 755 /var/log/kolla/opensearch +fi + +export DASHBOARDS_HOME=/usr/share/opensearch-dashboards + +PLUGIN_LIST=$($DASHBOARDS_HOME/bin/opensearch-dashboards-plugin list) +if [[ "${OPENSEARCH_DASHBOARDS_SECURITY_PLUGIN:-True}" == "False" ]]; then + if [[ ${PLUGIN_LIST} =~ "securityDashboards" ]]; then + $DASHBOARDS_HOME/bin/opensearch-dashboards-plugin remove securityDashboards + fi +fi diff --git a/docker/opensearch/opensearch/Dockerfile.j2 b/docker/opensearch/opensearch/Dockerfile.j2 new file mode 100644 index 0000000000..be29256958 --- /dev/null +++ b/docker/opensearch/opensearch/Dockerfile.j2 @@ -0,0 +1,37 @@ +FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }} +{% block labels %} +LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}" +{% endblock %} + +{% block opensearch_header %}{% endblock %} + +{% import "macros.j2" as macros with context %} + +{{ macros.configure_user(name='opensearch', shell='/bin/bash', homedir='/usr/share/opensearch') }} + +{% block opensearch_version %} + + {% if base_arch == 'x86_64' %} + {% set arch_os='x64' %} + {% elif base_arch == 'aarch64' %} + {% set arch_os='arm64' %} + {% endif %} + +ARG opensearch_version=2.3.0 +ARG opensearch_url=https://artifacts.opensearch.org/releases/bundle/opensearch/${opensearch_version}/opensearch-${opensearch_version}-linux-{{ arch_os }}.tar.gz +{% endblock %} + +ARG OPENSEARCH_HOME=/usr/share/opensearch + +RUN curl -o /tmp/opensearch.tgz ${opensearch_url} && \ + tar -xzpf /tmp/opensearch.tgz -C $OPENSEARCH_HOME --strip-components=1 && \ + rm /tmp/opensearch.tgz && \ + mkdir -p $OPENSEARCH_HOME/data && chown -R opensearch:opensearch $OPENSEARCH_HOME/data + +COPY extend_start.sh /usr/local/bin/kolla_extend_start +RUN chmod 755 /usr/local/bin/kolla_extend_start + +{% block elasticsearch_footer %}{% endblock %} +{% block footer %}{% endblock %} + +USER opensearch diff --git a/docker/opensearch/opensearch/extend_start.sh b/docker/opensearch/opensearch/extend_start.sh new file mode 100644 index 0000000000..5855b1be2c --- /dev/null +++ b/docker/opensearch/opensearch/extend_start.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [[ ! -d "/var/log/kolla/opensearch" ]]; then + mkdir -p /var/log/kolla/opensearch +fi +if [[ $(stat -c %a /var/log/kolla/opensearch) != "755" ]]; then + chmod 755 /var/log/kolla/opensearch +fi diff --git a/kolla/common/config.py b/kolla/common/config.py index 7e06fd7f87..21c45a9214 100644 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -64,6 +64,7 @@ _PROFILE_OPTS = [ 'logstash', 'mariadb', 'memcached', + 'opensearch', 'openvswitch', 'proxysql', 'rabbitmq', diff --git a/kolla/common/users.py b/kolla/common/users.py index 3fc92a54a6..4d8aefa17f 100644 --- a/kolla/common/users.py +++ b/kolla/common/users.py @@ -329,5 +329,9 @@ USERS = { 'venus-user': { 'uid': 42489, 'gid': 42489, + }, + 'opensearch-user': { + 'uid': 42490, + 'gid': 42490, } } diff --git a/releasenotes/notes/opensearch-f3a7b8bfc86a16f6.yaml b/releasenotes/notes/opensearch-f3a7b8bfc86a16f6.yaml new file mode 100644 index 0000000000..01140f7666 --- /dev/null +++ b/releasenotes/notes/opensearch-f3a7b8bfc86a16f6.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Adds OpenSearch and OpenSearch Dashboards images.