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

Commit

Permalink
object store: proxy object store UI
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
m-ildefons committed Nov 6, 2023
1 parent c676c4e commit 2b94c3e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ RUN npm run build
FROM registry.suse.com/bci/bci-base:15.4

RUN zypper -n ref && \
zypper -n install curl libxml2 bash gettext shadow nginx
zypper -n install curl libxml2 bash gettext shadow nginx awk

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

RUN mkdir -p web/dist
WORKDIR /web

COPY --from=builder /web/dist /web/dist
COPY --from=builder /web/nginx.conf.template /etc/nginx/nginx.conf.template
COPY nginx.conf.template /etc/nginx/nginx.conf.template
COPY entrypoint.sh /entrypoint.sh

EXPOSE 8000
ENV LONGHORN_MANAGER_IP http://localhost:9500
ENV LONGHORN_UI_PORT 8000
ENV LONGHORN_NAMESPACE longhorn-system

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

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;'"]
ENTRYPOINT ["/entrypoint.sh"]
13 changes: 13 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

NAMESERVER_IP="$(grep -E '^nameserver' /etc/resolv.conf | head -n 1 | awk '{print $2}')"
LONGHORN_NAMESPACE_DOMAIN="$(grep -E '^search' /etc/resolv.conf | head -n 1 | awk '{print $2}')"

export NAMESERVER_IP
export LONGHORN_NAMESPACE_DOMAIN

envsubst '${LONGHORN_MANAGER_IP},${LONGHORN_UI_PORT},${LONGHORN_NAMESPACE_DOMAIN},${NAMESERVER_IP}' \
< /etc/nginx/nginx.conf.template \
> /var/config/nginx/nginx.conf

nginx -c /var/config/nginx/nginx.conf
11 changes: 11 additions & 0 deletions nginx.conf.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
events { worker_connections 1024; }
daemon off;

error_log /dev/stdout info;

http {
access_log /dev/stdout;

server {
gzip on;
gzip_min_length 1k;
Expand Down Expand Up @@ -38,6 +44,11 @@ http {
root /web/dist;
}

location ~ ^/objectstore/([^/]+) {
resolver ${NAMESERVER_IP};
proxy_pass http://$1.${LONGHORN_NAMESPACE_DOMAIN}:8080;
}

location / {
root /web/dist;
index index.html;
Expand Down
2 changes: 1 addition & 1 deletion src/routes/objectStorage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class ObjectStore extends React.Component {
},
administrateObjectStore: (record) => {
if (record.name?.length) {
window.open(record.name, '_blank', 'noreferrer')
window.open(`objectstore/${record.name}/`, '_blank', 'noreferrer')
}
},
deleteObjectStore: (record) => {
Expand Down

0 comments on commit 2b94c3e

Please sign in to comment.