apps(siriusdevops): serve owner media from the private Garage bucket
- site image pinned to :4d03fc814d39... (nginx.conf gains location /media/) - initContainer media-sync pulls s3://siriusdevops-media from 10.10.0.1:3900 over the WireGuard mesh into an emptyDir mounted at /usr/share/nginx/html/media; creds from secret garage-media-s3 - the sync retries 5x then exits 0, so a Garage outage cannot take the site down (headshot falls back to its monogram) - the bucket stays private: no website access, no public hostname
This commit is contained in:
parent
39654781a7
commit
05864f3c2c
1 changed files with 61 additions and 1 deletions
|
|
@ -19,13 +19,70 @@ spec:
|
||||||
effect: PreferNoSchedule
|
effect: PreferNoSchedule
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/hostname: siriussec
|
||||||
|
# Owner media is NOT in the image, and the Garage bucket stays private
|
||||||
|
# (WireGuard-only: no website access, no public hostname). This
|
||||||
|
# initContainer pulls s3://siriusdevops-media over the mesh into an
|
||||||
|
# emptyDir that nginx serves at /media/. Baked assets (site.css, og.png,
|
||||||
|
# favicon, screenshots) stay baked - scope is owner media only.
|
||||||
|
#
|
||||||
|
# It must never take the site down: if Garage is unreachable at boot it
|
||||||
|
# retries a few times, then exits 0 with a warning and the page serves
|
||||||
|
# with the monogram fallback instead of the headshot.
|
||||||
|
initContainers:
|
||||||
|
- name: media-sync
|
||||||
|
image: amazon/aws-cli@sha256:7a77ccb39e3272191adbf905c50db8c127db88fd79454911a41a6b1c0e419e9b
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
set -u
|
||||||
|
for attempt in 1 2 3 4 5; do
|
||||||
|
if aws s3 sync "s3://siriusdevops-media/" /media/ \
|
||||||
|
--endpoint-url http://10.10.0.1:3900 \
|
||||||
|
--only-show-errors; then
|
||||||
|
echo "media sync ok (attempt $attempt): $(ls -R /media | head -20)"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "media sync attempt $attempt failed; retrying in 10s"
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
echo "WARNING: media sync failed after 5 attempts - serving without /media (headshot falls back to monogram)"
|
||||||
|
exit 0
|
||||||
|
env:
|
||||||
|
# aws-cli v2 sends a CRC32 checksum header on PutObject/HeadObject
|
||||||
|
# by default and Garage v1.1.0 rejects it as "invalid checksum
|
||||||
|
# algorithm" - only send checksums when an operation requires one.
|
||||||
|
- name: AWS_DEFAULT_REGION
|
||||||
|
value: garage
|
||||||
|
- name: AWS_EC2_METADATA_DISABLED
|
||||||
|
value: "true"
|
||||||
|
- name: AWS_REQUEST_CHECKSUM_CALCULATION
|
||||||
|
value: when_required
|
||||||
|
- name: AWS_RESPONSE_CHECKSUM_VALIDATION
|
||||||
|
value: when_required
|
||||||
|
envFrom:
|
||||||
|
- secretRef:
|
||||||
|
name: garage-media-s3
|
||||||
|
volumeMounts:
|
||||||
|
- name: media
|
||||||
|
mountPath: /media
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 32Mi
|
||||||
|
limits:
|
||||||
|
memory: 128Mi
|
||||||
containers:
|
containers:
|
||||||
- name: nginx
|
- name: nginx
|
||||||
image: forgejo.siriusdevops.com/sirius/siriusdevops-site:f0dde2f48c8224fb80d801ecb0d155c93332dc13
|
image: forgejo.siriusdevops.com/sirius/siriusdevops-site:4d03fc814d39faaf5d8cc64b794aa4bc19f72995
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
name: http
|
name: http
|
||||||
|
volumeMounts:
|
||||||
|
- name: media
|
||||||
|
mountPath: /usr/share/nginx/html/media
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /
|
path: /
|
||||||
|
|
@ -38,3 +95,6 @@ spec:
|
||||||
memory: 64Mi
|
memory: 64Mi
|
||||||
limits:
|
limits:
|
||||||
memory: 256Mi
|
memory: 256Mi
|
||||||
|
volumes:
|
||||||
|
- name: media
|
||||||
|
emptyDir: {}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue