Skip to content
This repository was archived by the owner on Jan 3, 2024. It is now read-only.

Commit 2b94c3e

Browse files
committed
object store: proxy object store UI
Proxy object store UI in the nginx of the Longhorn UI. This allows for port-forwarding of the Longhorn UI to also access the administrative interface of the s3gw UI instances Signed-off-by: Moritz Röhrich <[email protected]>
1 parent c676c4e commit 2b94c3e

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@ RUN npm run build
1313
FROM registry.suse.com/bci/bci-base:15.4
1414

1515
RUN zypper -n ref && \
16-
zypper -n install curl libxml2 bash gettext shadow nginx
16+
zypper -n install curl libxml2 bash gettext shadow nginx awk
1717

1818
SHELL [ "/bin/bash", "-o", "pipefail", "-c" ]
1919

2020
RUN mkdir -p web/dist
2121
WORKDIR /web
2222

2323
COPY --from=builder /web/dist /web/dist
24-
COPY --from=builder /web/nginx.conf.template /etc/nginx/nginx.conf.template
24+
COPY nginx.conf.template /etc/nginx/nginx.conf.template
25+
COPY entrypoint.sh /entrypoint.sh
2526

2627
EXPOSE 8000
2728
ENV LONGHORN_MANAGER_IP http://localhost:9500
2829
ENV LONGHORN_UI_PORT 8000
30+
ENV LONGHORN_NAMESPACE longhorn-system
2931

3032
RUN mkdir -p /var/config/nginx/ \
3133
&& cp -r /etc/nginx/* /var/config/nginx/ \
@@ -35,4 +37,4 @@ RUN mkdir -p /var/config/nginx/ \
3537
# Use the uid of the default user (nginx) from the installed nginx package
3638
USER 499
3739

38-
CMD ["/bin/bash", "-c", "envsubst '${LONGHORN_MANAGER_IP},${LONGHORN_UI_PORT}' < /etc/nginx/nginx.conf.template > /var/config/nginx/nginx.conf && nginx -c /var/config/nginx/nginx.conf -g 'daemon off;'"]
40+
ENTRYPOINT ["/entrypoint.sh"]

entrypoint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
NAMESERVER_IP="$(grep -E '^nameserver' /etc/resolv.conf | head -n 1 | awk '{print $2}')"
4+
LONGHORN_NAMESPACE_DOMAIN="$(grep -E '^search' /etc/resolv.conf | head -n 1 | awk '{print $2}')"
5+
6+
export NAMESERVER_IP
7+
export LONGHORN_NAMESPACE_DOMAIN
8+
9+
envsubst '${LONGHORN_MANAGER_IP},${LONGHORN_UI_PORT},${LONGHORN_NAMESPACE_DOMAIN},${NAMESERVER_IP}' \
10+
< /etc/nginx/nginx.conf.template \
11+
> /var/config/nginx/nginx.conf
12+
13+
nginx -c /var/config/nginx/nginx.conf

nginx.conf.template

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
events { worker_connections 1024; }
2+
daemon off;
3+
4+
error_log /dev/stdout info;
5+
26
http {
7+
access_log /dev/stdout;
8+
39
server {
410
gzip on;
511
gzip_min_length 1k;
@@ -38,6 +44,11 @@ http {
3844
root /web/dist;
3945
}
4046

47+
location ~ ^/objectstore/([^/]+) {
48+
resolver ${NAMESERVER_IP};
49+
proxy_pass http://$1.${LONGHORN_NAMESPACE_DOMAIN}:8080;
50+
}
51+
4152
location / {
4253
root /web/dist;
4354
index index.html;

src/routes/objectStorage/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class ObjectStore extends React.Component {
183183
},
184184
administrateObjectStore: (record) => {
185185
if (record.name?.length) {
186-
window.open(record.name, '_blank', 'noreferrer')
186+
window.open(`objectstore/${record.name}/`, '_blank', 'noreferrer')
187187
}
188188
},
189189
deleteObjectStore: (record) => {

0 commit comments

Comments
 (0)