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:
devops 2026-12-04 00:15:47 -05:00
commit 42b985e07b
2 changed files with 129 additions and 0 deletions

View file

@ -0,0 +1,80 @@
name: backup-image
# Builds the backup tooling image used by the three nightly CronJobs
# (monitoring/grafana-backup, forgejo/cluster-backup, sirius-growth/leadgen-backup).
#
# Why this is a CI build at all (card t_9d0428d8): the jobs used to run
# `apk add rsync openssh-client` at container start, so the backup depended on
# the Alpine CDN at run time. Everything is baked here instead, from a base
# image pinned by digest, and the manifests pin the resulting image by digest.
#
# CI has no cluster credentials: this job only pushes an immutable :$sha tag to
# the in-cluster Forgejo registry and prints the digest to pin. The operator
# copies that digest into the three CronJob manifests in this same repo.
#
# amd64 only, on purpose: all three Jobs are nodeSelector'd to siriussec and
# the baked kubectl release checksum is amd64. Nothing here runs on rpi.
on:
push:
branches: [master]
paths:
- 'images/backup/**'
- '.forgejo/workflows/backup-image.yml'
workflow_dispatch:
jobs:
build:
runs-on: docker-amd64
steps:
- uses: actions/checkout@v4
# The job image (node:20-bullseye) has no docker CLI of its own; the
# runner mounts the dind sidecar's client and cli-plugins. Verify both
# instead of assuming, and fail loudly rather than half-pushing.
- name: Verify docker CLI + buildx
run: |
set -euo pipefail
command -v docker
docker version
docker buildx version
- name: Build and push (amd64, no attestation manifests)
env:
REG_USER: ${{ secrets.REGISTRY_USER }}
REG_PASS: ${{ secrets.REGISTRY_TOKEN }}
run: |
set -euo pipefail
sha=$(git rev-parse HEAD)
image=forgejo.siriusdevops.com/sirius/backup-tools
user="${REG_USER:-sirius}"
pass="${REG_PASS:-${{ github.token }}}"
echo "$pass" | docker login forgejo.siriusdevops.com -u "$user" --password-stdin
# --provenance=false --sbom=false: the tag must resolve to the single
# amd64 image manifest, so the digest a CronJob pins is exactly the
# image the pod runs (an index digest would resolve per-arch).
docker buildx build --platform linux/amd64 \
--provenance=false --sbom=false \
-t "$image:$sha" \
--push images/backup
echo "pushed $image:$sha"
- name: Print the digest to pin
env:
REG_USER: ${{ secrets.REGISTRY_USER }}
REG_PASS: ${{ secrets.REGISTRY_TOKEN }}
run: |
set -euo pipefail
sha=$(git rev-parse HEAD)
image=forgejo.siriusdevops.com/sirius/backup-tools
user="${REG_USER:-sirius}"
pass="${REG_PASS:-${{ github.token }}}"
echo "$pass" | docker login forgejo.siriusdevops.com -u "$user" --password-stdin
digest=$(docker buildx imagetools inspect "$image:$sha" --format '{{.Manifest.Digest}}')
echo "BACKUP_TOOLS_DIGEST=$digest"
{
echo "### Pin this in the three backup CronJob manifests"
echo ""
echo '```'
echo "$image@$digest"
echo '```'
} | tee -a "${GITHUB_STEP_SUMMARY:-/dev/stdout}"