homek8s/apps/base/siriusdevops/deployment-site.yaml

100 lines
3.4 KiB
YAML
Raw Normal View History

apiVersion: apps/v1
kind: Deployment
metadata:
name: siriusdevops-site
namespace: siriusdevops
spec:
replicas: 1
selector:
matchLabels:
app: siriusdevops-site
template:
metadata:
labels:
app: siriusdevops-site
spec:
tolerations:
- key: dedicated
operator: Exists
effect: PreferNoSchedule
nodeSelector:
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:
- name: nginx
image: forgejo.siriusdevops.com/sirius/siriusdevops-site:e2fd76ad1dfeb6c758974f04a9b3d3308c78d43d
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
name: http
volumeMounts:
- name: media
mountPath: /usr/share/nginx/html/media
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 10
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
memory: 256Mi
volumes:
- name: media
emptyDir: {}