Skip to content

Commit ba3ccaa

Browse files
committed
add elasticsearch exporter to opensearch image
1 parent 6c406ca commit ba3ccaa

7 files changed

Lines changed: 106 additions & 0 deletions

File tree

conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
opensearch_security_plugin = importlib.import_module(
3434
"opensearch.security-plugin.versions"
3535
)
36+
opensearch_elasticsearch_exporter = importlib.import_module(
37+
"opensearch.elasticsearch-exporter.versions"
38+
)
3639
spark_k8s = importlib.import_module("spark-k8s.versions")
3740
stackable_base = importlib.import_module("stackable-base.versions")
3841
stackable_devel = importlib.import_module("stackable-devel.versions")
@@ -75,6 +78,10 @@
7578
"name": "opensearch/security-plugin",
7679
"versions": opensearch_security_plugin.versions,
7780
},
81+
{
82+
"name": "opensearch/elasticsearch-exporter",
83+
"versions": opensearch_elasticsearch_exporter.versions,
84+
},
7885
{"name": "spark-k8s", "versions": spark_k8s.versions},
7986
{"name": "stackable-base", "versions": stackable_base.versions},
8087
{"name": "stackable-devel", "versions": stackable_devel.versions},

opensearch/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# check=error=true
33

44
FROM stackable/image/opensearch/security-plugin AS opensearch-security-plugin
5+
FROM stackable/image/opensearch/elasticsearch-exporter AS opensearch-elasticsearch-exporter
56
FROM stackable/image/java-devel AS opensearch-builder
67

78
ARG PRODUCT
@@ -77,6 +78,7 @@ FROM stackable/image/jdk-base AS final
7778
ARG PRODUCT
7879
ARG RELEASE
7980
ARG OPENSEARCH_SECURITY_PLUGIN
81+
ARG OPENSEARCH_ELASTICSEARCH_EXPORTER
8082
ARG STACKABLE_USER_UID
8183

8284
ARG NAME="OpenSearch"
@@ -109,6 +111,11 @@ COPY \
109111
--from=opensearch-builder \
110112
/stackable/opensearch-security \
111113
/stackable/opensearch-${PRODUCT}-stackable${RELEASE}/plugins/opensearch-security
114+
COPY \
115+
--chown=${STACKABLE_USER_UID}:0 \
116+
--from=opensearch-elasticsearch-exporter \
117+
/stackable/elasticsearch_exporter \
118+
/stackable/opensearch-${PRODUCT}-stackable${RELEASE}/bin/elasticsearch_exporter
112119
COPY \
113120
--chown=${STACKABLE_USER_UID}:0 \
114121
--from=opensearch-builder \
@@ -119,6 +126,11 @@ COPY \
119126
--from=opensearch-security-plugin \
120127
/stackable/opensearch-security-${OPENSEARCH_SECURITY_PLUGIN}-stackable${RELEASE}-src.tar.gz \
121128
/stackable
129+
COPY \
130+
--chown=${STACKABLE_USER_UID}:0 \
131+
--from=opensearch-elasticsearch-exporter \
132+
/stackable/opensearch-elasticsearch-exporter-${OPENSEARCH_ELASTICSEARCH_EXPORTER}-stackable${RELEASE}-src.tar.gz \
133+
/stackable
122134
COPY \
123135
--chown=${STACKABLE_USER_UID}:0 \
124136
--from=opensearch-builder \
@@ -129,6 +141,11 @@ COPY \
129141
--from=opensearch-security-plugin \
130142
/stackable/src/opensearch/security-plugin/patchable-work/worktree/${OPENSEARCH_SECURITY_PLUGIN}/build/reports/bom.json \
131143
/stackable/opensearch-security-${OPENSEARCH_SECURITY_PLUGIN}-stackable${RELEASE}.cdx.json
144+
COPY \
145+
--chown=${STACKABLE_USER_UID}:0 \
146+
--from=opensearch-elasticsearch-exporter \
147+
/stackable/opensearch-elasticsearch-exporter-${OPENSEARCH_ELASTICSEARCH_EXPORTER}-stackable${RELEASE}.cdx.json \
148+
/stackable
132149

133150
RUN <<EOF
134151
microdnf update
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# syntax=docker/dockerfile:1.16.0@sha256:e2dd261f92e4b763d789984f6eab84be66ab4f5f08052316d8eb8f173593acf7
2+
# check=error=true;skip=InvalidDefaultArgInFrom
3+
4+
ARG GOLANG
5+
6+
FROM oci.stackable.tech/sdp/library/golang:${GOLANG} AS golang-image
7+
8+
FROM stackable/image/stackable-devel AS elasticsearch-exporter-builder
9+
10+
ARG PRODUCT
11+
ARG PROMU
12+
ARG RELEASE
13+
ARG STACKABLE_USER_UID
14+
ARG TARGETARCH
15+
ARG TARGETOS
16+
17+
ENV GOARCH=$TARGETARCH
18+
ENV GOOS=$TARGETOS
19+
20+
# tar - used to archive the elasticsearch-exporter source
21+
# git - needed by patchable and the cyclonedx-gomod tool to determine the version of elasticsearch-exporter
22+
RUN <<EOF
23+
microdnf update
24+
microdnf install \
25+
git \
26+
tar
27+
microdnf clean all
28+
EOF
29+
30+
# Manually install Go since the dnf package is sometimes not recent enough
31+
COPY --from=golang-image /usr/local/go/ /usr/local/go/
32+
ENV PATH="/usr/local/go/bin:${PATH}"
33+
34+
COPY --chown=${STACKABLE_USER_UID}:0 opensearch/elasticsearch-exporter/stackable/patches/patchable.toml /stackable/src/opensearch/elasticsearch-exporter/stackable/patches/patchable.toml
35+
COPY --chown=${STACKABLE_USER_UID}:0 opensearch/elasticsearch-exporter/stackable/patches/${PRODUCT} /stackable/src/opensearch/elasticsearch-exporter/stackable/patches/${PRODUCT}
36+
37+
WORKDIR /stackable
38+
39+
RUN <<EOF
40+
# We use version 1.7.0, since a newer version of cyclonedx-gomod is not compatible with the version of Golang (>= 1.23.1)
41+
go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@v1.7.0
42+
# prometheus utility
43+
go install github.com/prometheus/promu@v0.17.0
44+
45+
cd "$(/stackable/patchable --images-repo-root=src checkout opensearch/elasticsearch-exporter ${PRODUCT})"
46+
47+
ORIGINAL_VERSION=${PRODUCT}
48+
NEW_VERSION="${PRODUCT}-stackable${RELEASE}"
49+
50+
# Create snapshot of the source code including custom patches
51+
tar -czf /stackable/opensearch-elasticsearch-exporter-${NEW_VERSION}-src.tar.gz .
52+
53+
# Unfortunately, we need to create a dummy Git repository to allow cyclonedx-gomod to determine the version of elasticsearch-exporter
54+
rm .git
55+
git init
56+
git config user.email "fake.commiter@stackable.tech"
57+
git config user.name "Fake commiter"
58+
git commit --allow-empty --message "Fake commit, so that we can create a tag"
59+
git tag "v${NEW_VERSION}"
60+
# required by promu
61+
git remote add origin https://github.com/stackabletech/elasticsearch_exporter.git
62+
make build
63+
# move artifact to /stackable/*/ to copy in final image
64+
~/go/bin/cyclonedx-gomod app -json -output-version 1.5 -output "/stackable/opensearch-elasticsearch-exporter-${NEW_VERSION}.cdx.json" -packages -files
65+
sed -i "s/${NEW_VERSION}/${ORIGINAL_VERSION}/g" "/stackable/opensearch-elasticsearch-exporter-${NEW_VERSION}.cdx.json"
66+
# move artifact to /stackable/* to copy in final image
67+
mv elasticsearch_exporter /stackable/elasticsearch_exporter
68+
# set correct groups
69+
chmod -R g=u /stackable/elasticsearch_exporter /stackable/opensearch-elasticsearch-exporter-${NEW_VERSION}-src.tar.gz /stackable/opensearch-elasticsearch-exporter-${NEW_VERSION}.cdx.json
70+
EOF
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
base = "4301b8d65587ace76803247a7329b5aaba27a574"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
upstream = "https://github.com/prometheus-community/elasticsearch_exporter"
2+
default-mirror = "https://github.com/stackabletech/elasticsearch_exporter"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
versions = [
2+
{
3+
"product": "1.9.0",
4+
"golang": "1.23.9",
5+
"stackable-devel": "1.0.0",
6+
"promu": "0.17.0",
7+
},
8+
]

opensearch/versions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"java-devel": "21",
55
"jdk-base": "21",
66
"opensearch/security-plugin": "3.1.0.0",
7+
"opensearch/elasticsearch-exporter": "1.9.0",
78
},
89
]

0 commit comments

Comments
 (0)