ci(backup): build a pinned backup-tools image (rsync/ssh/bash/kubectl baked in)
The three nightly backups (grafana-backup, cluster-backup, leadgen-backup) installed rsync + openssh-client with apk at container start, so every run depended on the Alpine CDN (Fastly anycast 151.101.x.132:443) and moved the egress-new-dst alert whenever that anycast address rotated. This adds the build only; the CronJob pins land in the next commit. Base image python:3.12-alpine pinned by digest, kubectl v1.36.4 from dl.k8s.io with its release sha256, amd64 only (all three jobs are nodeSelector'd to siriussec).
This commit is contained in:
parent
32de4e04ef
commit
42b985e07b
2 changed files with 129 additions and 0 deletions
49
images/backup/Dockerfile
Normal file
49
images/backup/Dockerfile
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# Backup tooling image for the three nightly state-backup CronJobs
|
||||
# (monitoring/grafana-backup, forgejo/cluster-backup, sirius-growth/leadgen-backup).
|
||||
#
|
||||
# Why this exists (card t_9d0428d8): every one of those jobs used to run
|
||||
# `apk add --no-cache rsync openssh-client` at container start, which dialled
|
||||
# dl-cdn.alpinelinux.org (Fastly anycast 151.101.x.132:443) on every run. That
|
||||
# made the nightly backup depend on the public internet, tripped the
|
||||
# `egress-new-dst` flow alert whenever Fastly rotated an address, and put a
|
||||
# package install on the one pod that carries the Grafana PVC and an SSH key.
|
||||
# The toolchain is baked in at build time instead, and the pods get an egress
|
||||
# NetworkPolicy that admits DNS + the backup host only.
|
||||
#
|
||||
# Base image is pinned by digest (multi-arch index digest; this build is
|
||||
# linux/amd64 because all three jobs are nodeSelector'd to siriussec).
|
||||
FROM python:3.12-alpine@sha256:c5ba3deef00c7758561a0f03c26f44f10589263d40e732b8748e0d1f38f6dd89
|
||||
|
||||
# kubectl is needed by forgejo/cluster-backup only (CNPG `get cluster` +
|
||||
# `exec` pg_dump); the cluster runs v1.36.4, so the client is pinned to the
|
||||
# same minor and its release checksum is verified at build time.
|
||||
ARG KUBECTL_VERSION=v1.36.4
|
||||
ARG KUBECTL_SHA256=8b8f088da2dab964f853b38464033b1be15ede2839eca751482357c45abdd05a
|
||||
|
||||
LABEL org.opencontainers.image.title="backup-tools" \
|
||||
org.opencontainers.image.description="python3.12-alpine + rsync + openssh-client + bash + kubectl for the nightly state backups" \
|
||||
org.opencontainers.image.source="https://forgejo.siriusdevops.com/sirius/homek8s"
|
||||
|
||||
RUN set -eux; \
|
||||
# bash: cluster-backup and leadgen-backup use arrays, `set -o pipefail`
|
||||
# and `tee >(...)` process substitution, so /bin/sh (busybox ash) is not
|
||||
# enough -- the CronJob entrypoints stay /bin/bash, unchanged.
|
||||
apk add --no-cache rsync openssh-client bash; \
|
||||
test "${TARGETARCH:-amd64}" = "amd64" || { echo "kubectl pin is amd64-only; the backup jobs run on siriussec" >&2; exit 1; }; \
|
||||
apk add --no-cache --virtual .fetch curl ca-certificates; \
|
||||
curl -fsSL -o /usr/local/bin/kubectl \
|
||||
"https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl"; \
|
||||
echo "${KUBECTL_SHA256} /usr/local/bin/kubectl" | sha256sum -c -; \
|
||||
chmod 0755 /usr/local/bin/kubectl; \
|
||||
apk del .fetch; \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
# Build-time proof that nothing has to be installed at run time.
|
||||
RUN set -eux; \
|
||||
rsync --version | head -1; \
|
||||
ssh -V; \
|
||||
bash --version | head -1; \
|
||||
python3 --version; \
|
||||
kubectl version --client
|
||||
|
||||
CMD ["/bin/sh"]
|
||||
Loading…
Reference in a new issue