Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ jobs:
OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
echo "tags=ghcr.io/${OWNER}/s3proxy-python:${VERSION}" >> $GITHUB_OUTPUT
else
echo "tags=ghcr.io/${OWNER}/s3proxy-python:latest" >> $GITHUB_OUTPUT
VERSION=latest
fi
echo "proxy=ghcr.io/${OWNER}/s3proxy-python:${VERSION}" >> $GITHUB_OUTPUT
echo "dashboard=ghcr.io/${OWNER}/s3proxy-dashboard:${VERSION}" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
Expand All @@ -37,12 +38,24 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
- name: Build and push proxy image
uses: docker/build-push-action@v7
with:
context: .
file: s3proxy/Dockerfile
push: true
tags: ${{ steps.tags.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.tags.outputs.proxy }}
cache-from: type=gha,scope=proxy
cache-to: type=gha,mode=max,scope=proxy
platforms: linux/amd64,linux/arm64

- name: Build and push dashboard image
uses: docker/build-push-action@v7
with:
context: dashboard-frontend
file: dashboard-frontend/Dockerfile
push: true
tags: ${{ steps.tags.outputs.dashboard }}
cache-from: type=gha,scope=dashboard
cache-to: type=gha,mode=max,scope=dashboard
platforms: linux/amd64,linux/arm64
63 changes: 37 additions & 26 deletions .github/workflows/helm-install-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ jobs:
--set redis.enabled=true \
--set redis.auth.enabled=true \
--set redis.auth.password=testredispassword123 \
--set admin.enabled=true \
--set admin.secret=test-admin-secret-for-ci \
--set dashboard.enabled=true \
--set dashboard.secret=test-dashboard-secret-for-ci \
--set dashboard.frontend.image.repository=ghcr.io/${OWNER}/s3proxy-dashboard \
--set dashboard.frontend.image.tag=latest \
--set dashboard.frontend.image.pullPolicy=Always \
--set frontproxy.enabled=true \
--set replicaCount=3 \
--set resources.limits.cpu=100m \
Expand Down Expand Up @@ -225,66 +228,74 @@ jobs:
echo "✓ All smoke tests passed!"
'

- name: Verify admin dashboard
- name: Verify dashboard
run: |
set -euo pipefail
ENDPOINT="http://s3proxy-python:4433"
BUCKET="admin-ci"
KEY="admin-ci.txt"
BUCKET="dashboard-ci"
KEY="dashboard-ci.txt"

echo "=== Dashboard pod is ready ==="
kubectl wait --for=condition=ready pod \
-l app.kubernetes.io/component=dashboard -n s3proxy --timeout=120s
kubectl get pods -n s3proxy -l app.kubernetes.io/component=dashboard

echo "=== Upload an object through the proxy (so the dashboard has traffic) ==="
kubectl run admin-ci-upload -n s3proxy --rm -i --restart=Never \
kubectl run dashboard-ci-upload -n s3proxy --rm -i --restart=Never \
--image=amazon/aws-cli:latest \
--env="AWS_ACCESS_KEY_ID=minioadmin" \
--env="AWS_SECRET_ACCESS_KEY=minioadmin" \
--env="AWS_DEFAULT_REGION=us-east-1" \
--command -- /bin/sh -c "
set -e
echo 'admin dashboard ci object' > /tmp/o.txt
echo 'dashboard ci object' > /tmp/o.txt
aws --endpoint-url $ENDPOINT s3 mb s3://$BUCKET 2>/dev/null || true
aws --endpoint-url $ENDPOINT s3 cp /tmp/o.txt s3://$BUCKET/$KEY
aws --endpoint-url $ENDPOINT s3 cp s3://$BUCKET/$KEY /tmp/d.txt
test \"\$(cat /tmp/d.txt)\" = 'admin dashboard ci object'
test \"\$(cat /tmp/d.txt)\" = 'dashboard ci object'
echo UPLOAD_OK
"

echo "=== Port-forward the admin dashboard ==="
kubectl port-forward svc/s3proxy-python 4433:4433 -n s3proxy &
# The dashboard is single-origin behind its own service: nginx serves the
# static SPA and reverse-proxies /dashboard/api to the proxy. Port-forward
# the dashboard service and exercise the whole thing through it.
echo "=== Port-forward the dashboard service ==="
kubectl port-forward svc/s3proxy-python-dashboard 18080:80 -n s3proxy &
PF_PID=$!
trap "kill $PF_PID 2>/dev/null || true" EXIT
for i in $(seq 1 15); do curl -sf -o /dev/null http://localhost:4433/admin/login && break; sleep 1; done
BASE="http://localhost:18080/dashboard"
for i in $(seq 1 15); do curl -sf -o /dev/null "$BASE" && break; sleep 1; done

echo "=== 1. Login page is served (unauthenticated) ==="
curl -sf http://localhost:4433/admin/login | grep -q "Sign in to the admin dashboard"
echo "✓ Login page served"
echo "=== 1. Static SPA shell is served ==="
curl -sf "$BASE" | grep -q "_app/" || { echo "✗ SPA shell not served at $BASE"; exit 1; }
curl -sf -o /dev/null "$BASE/login" # SPA fallback for the login route
echo "✓ SPA shell served"

echo "=== 2. Auth is enforced ==="
CODE=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:4433/admin/api/status)
echo "=== 2. Auth is enforced (API reverse-proxied through the dashboard) ==="
CODE=$(curl -s -o /dev/null -w '%{http_code}' "$BASE/api/status")
[ "$CODE" = "401" ] || { echo "✗ status API without auth returned $CODE (expected 401)"; exit 1; }
# The AWS secret key must NOT work as a dashboard password (fallback removed).
CODE=$(curl -s -o /dev/null -w '%{http_code}' -u minioadmin:minioadmin http://localhost:4433/admin/api/status)
[ "$CODE" = "401" ] || { echo "✗ AWS creds accepted as admin login ($CODE) — fallback not removed"; exit 1; }
CODE=$(curl -s -o /dev/null -w '%{http_code}' -u minioadmin:minioadmin "$BASE/api/status")
[ "$CODE" = "401" ] || { echo "✗ AWS creds accepted as dashboard login ($CODE) — fallback not removed"; exit 1; }
echo "✓ Unauthenticated + AWS-cred requests rejected (401)"

echo "=== 3. Dashboard + status API work with admin credentials (admin/admin) ==="
CODE=$(curl -s -o /dev/null -w '%{http_code}' -u admin:admin http://localhost:4433/admin/)
[ "$CODE" = "200" ] || { echo "✗ dashboard returned $CODE (expected 200)"; exit 1; }
STATUS=$(curl -sf -u admin:admin http://localhost:4433/admin/api/status)
echo "=== 3. Status API works with dashboard credentials (admin/admin) ==="
STATUS=$(curl -sf -u admin:admin "$BASE/api/status")
echo "$STATUS" | grep -q '"status":"Running"' || { echo "✗ status not Running: $STATUS"; exit 1; }
echo "✓ Dashboard + status API healthy"
echo "✓ Status API healthy"

echo "=== 4. Bucket listing API shows the uploaded object ==="
BUCKETS=$(curl -sf -u admin:admin "http://localhost:4433/admin/api/buckets/$BUCKET")
BUCKETS=$(curl -sf -u admin:admin "$BASE/api/buckets/$BUCKET")
echo "$BUCKETS" | grep -q "\"$KEY\"" || { echo "✗ '$KEY' not in bucket listing: $BUCKETS"; exit 1; }
echo "✓ Bucket listing shows '$KEY'"

echo "=== 5. Object detail API reports encryption ==="
OBJ=$(curl -sf -u admin:admin "http://localhost:4433/admin/api/objects/$BUCKET/$KEY")
OBJ=$(curl -sf -u admin:admin "$BASE/api/objects/$BUCKET/$KEY")
echo "$OBJ" | grep -q '"encrypted":true' || { echo "✗ object detail not encrypted: $OBJ"; exit 1; }
echo "✓ Object detail reports encrypted"

echo ""
echo "✓ Admin dashboard verified end-to-end"
echo "✓ Dashboard verified end-to-end"

- name: Show logs on failure
if: failure()
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ A request signed by an access key with no configured KEK is rejected. Via Helm:
| `s3.region` | `us-east-1` | AWS region |
| `secrets.credentials` | `[]` | AWS credentials, each `{accessKey, secretKey, kek}` |
| `secrets.existingSecrets.enabled` | `false` | Use existing K8s secret |
| `admin.secret` | `change-me` | Secret signing admin session cookies (when admin UI on) |
| `dashboard.enabled` | `false` | Enable the dashboard API + its separate UI deployment |
| `dashboard.secret` | `change-me` | Secret signing dashboard session cookies (when the dashboard is on) |
| `redis.enabled` | `true` | Deploy the bundled single Redis pod (transient upload state) |
| `frontproxy.enabled` | `false` | Bundled HAProxy for even load distribution (no external dependency) |
| `ingress.enabled` | `false` | Expose S3 outside the cluster via Ingress (requires `frontproxy.enabled`) |
Expand Down
31 changes: 17 additions & 14 deletions chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,23 @@ helm install s3proxy oci://ghcr.io/serversidehannes/s3proxy-python/charts/s3prox
| `secrets.existingSecrets.enabled` | `false` | Use pre-created K8s secret |
| `secrets.existingSecrets.name` | `""` | Existing secret name |
| `secrets.existingSecrets.keys.credentials` | `S3PROXY_CREDENTIALS` | Credentials key name in existing secret |
| `admin.enabled` | `false` | Enable the admin dashboard |
| `admin.path` | `/admin` | URL path prefix for the dashboard |
| `admin.username` | `admin` | Dashboard username (stored in the Secret; override in production) |
| `admin.password` | `admin` | Dashboard password (stored in the Secret; override in production) |
| `admin.secret` | `change-me` | Secret signing dashboard session cookies (override in production) |
| `admin.existingSecret.name` | `""` | Pre-created secret holding admin credentials |
| `admin.existingSecret.usernameKey` | `S3PROXY_ADMIN_USERNAME` | Username key in the existing secret |
| `admin.existingSecret.passwordKey` | `S3PROXY_ADMIN_PASSWORD` | Password key in the existing secret |
| `admin.existingSecret.secretKey` | `S3PROXY_ADMIN_SECRET` | Session-secret key in the existing secret |
| `admin.ingress.enabled` | `false` | Dedicated Ingress for the dashboard (keep off unless intentionally exposing it) |
| `admin.ingress.className` | `""` | Ingress class for the admin Ingress (set to your cluster's controller) |
| `admin.ingress.host` | `""` | Hostname for the dashboard (required when enabled) |
| `admin.ingress.annotations` | `{}` | Annotations (e.g. IP allowlist) for the admin Ingress |
| `admin.ingress.tls` | `[]` | TLS config for the admin Ingress |
| `dashboard.enabled` | `false` | Enable the dashboard |
| `dashboard.path` | `/dashboard` | URL path prefix for the dashboard |
| `dashboard.username` | `admin` | Dashboard username (stored in the Secret; override in production) |
| `dashboard.password` | `admin` | Dashboard password (stored in the Secret; override in production) |
| `dashboard.frontend.enabled` | `true` | Run the Svelte UI as its own Deployment (nginx serving the static build + reverse-proxying the API) |
| `dashboard.frontend.image.repository` | `ghcr.io/serversidehannes/s3proxy-dashboard` | Dashboard UI image |
| `dashboard.frontend.image.tag` | `latest` | Dashboard UI image tag |
| `dashboard.frontend.replicaCount` | `1` | Dashboard UI replicas |
| `dashboard.frontend.service.port` | `80` | Dashboard Service port |
| `dashboard.existingSecret.name` | `""` | Pre-created secret holding dashboard credentials |
| `dashboard.existingSecret.usernameKey` | `S3PROXY_DASHBOARD_USERNAME` | Username key in the existing secret |
| `dashboard.existingSecret.passwordKey` | `S3PROXY_DASHBOARD_PASSWORD` | Password key in the existing secret |
| `dashboard.ingress.enabled` | `false` | Dedicated Ingress for the dashboard (keep off unless intentionally exposing it) |
| `dashboard.ingress.className` | `""` | Ingress class for the dashboard Ingress (set to your cluster's controller) |
| `dashboard.ingress.host` | `""` | Hostname for the dashboard (required when enabled) |
| `dashboard.ingress.annotations` | `{}` | Annotations (e.g. IP allowlist) for the dashboard Ingress |
| `dashboard.ingress.tls` | `[]` | TLS config for the dashboard Ingress |
| `redis.enabled` | `true` | Deploy the bundled single Redis pod (transient upload state) |
| `redis.image.repository` | `redis` | Redis image (bump manually; not tracked by dependabot) |
| `redis.image.tag` | `7-alpine` | Redis image tag |
Expand Down
38 changes: 0 additions & 38 deletions chart/templates/admin-ingress.yaml

This file was deleted.

55 changes: 55 additions & 0 deletions chart/templates/dashboard/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{{- if and .Values.dashboard.enabled .Values.dashboard.frontend.enabled -}}
{{- $base := .Values.dashboard.path | trimSuffix "/" -}}
{{- $proxy := printf "http://%s.%s.svc.cluster.local:%v" .Chart.Name .Release.Namespace .Values.service.port -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Chart.Name }}-dashboard-nginx
labels:
{{- include "s3proxy.labels" . | nindent 4 }}
app.kubernetes.io/component: dashboard
data:
default.conf: |
# Serves the static dashboard under dashboard.path and reverse-proxies the API +
# auth endpoints to the proxy service, so the dashboard is single-origin: the
# SPA's relative /api fetches and the session cookie work whether reached via
# this pod directly (a single port-forward) or through the ingress.
server {
listen {{ .Values.dashboard.frontend.containerPort }};
server_name _;

root /usr/share/nginx/html;

# API + SSE and form auth (POST /api/login, GET /api/logout) all live in
# the proxy process. The /login page itself is the static SPA below.
location {{ $base }}/api/ {
proxy_pass {{ $proxy }};
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# SSE: stream events as they arrive rather than buffering.
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 1h;
}

# Hashed, immutable build assets.
location {{ $base }}/_app/ {
alias /usr/share/nginx/html/_app/;
access_log off;
expires 1y;
add_header Cache-Control "public, immutable";
}

# Everything else under dashboard.path falls back to the SPA shell so client
# hash routing and the {{ $base }}/login page work on hard refresh.
location {{ $base }} {
try_files $uri /index.html;
}

location = / {
return 302 {{ $base }};
}
}
{{- end }}
92 changes: 92 additions & 0 deletions chart/templates/dashboard/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{{- if and .Values.dashboard.enabled .Values.dashboard.frontend.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Chart.Name }}-dashboard
labels:
{{- include "s3proxy.labels" . | nindent 4 }}
app.kubernetes.io/component: dashboard
spec:
replicas: {{ .Values.dashboard.frontend.replicaCount }}
selector:
matchLabels:
{{- include "s3proxy.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: dashboard
template:
metadata:
labels:
{{- include "s3proxy.labels" . | nindent 8 }}
app.kubernetes.io/component: dashboard
annotations:
checksum/nginx: {{ include (print $.Template.BasePath "/dashboard/configmap.yaml") . | sha256sum }}
spec:
containers:
- name: dashboard
image: "{{ .Values.dashboard.frontend.image.repository }}:{{ .Values.dashboard.frontend.image.tag }}"
imagePullPolicy: {{ .Values.dashboard.frontend.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.dashboard.frontend.containerPort }}
protocol: TCP
volumeMounts:
- name: nginx-conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: default.conf
readOnly: true
- name: nginx-cache
mountPath: /var/cache/nginx
- name: nginx-run
mountPath: /tmp
resources:
{{- toYaml .Values.dashboard.frontend.resources | nindent 12 }}
startupProbe:
httpGet:
path: {{ .Values.dashboard.path | trimSuffix "/" }}
port: http
initialDelaySeconds: 2
periodSeconds: 2
timeoutSeconds: 3
failureThreshold: 30
livenessProbe:
httpGet:
path: {{ .Values.dashboard.path | trimSuffix "/" }}
port: http
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: {{ .Values.dashboard.path | trimSuffix "/" }}
port: http
initialDelaySeconds: 2
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3
securityContext:
runAsNonRoot: true
runAsUser: 101
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
volumes:
- name: nginx-conf
configMap:
name: {{ .Chart.Name }}-dashboard-nginx
- name: nginx-cache
emptyDir: {}
- name: nginx-run
emptyDir: {}
terminationGracePeriodSeconds: 15
{{- with .Values.dashboard.frontend.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.dashboard.frontend.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.dashboard.frontend.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
Loading