From 1647f35ce0a8cdec82bd070634fdc65dcff39a63 Mon Sep 17 00:00:00 2001 From: Sirius DevOps Date: Fri, 27 Nov 2026 00:22:56 -0500 Subject: [PATCH] docs(registry): rotate/add-namespace via the SOPS files, not kubectl PR #45 landed the forgejo-pull Secrets as SOPS ciphertext in git while this doc still described them as out-of-band. A kubectl apply of a new Secret is now reverted by the next apps reconcile, so the rotation and add-a-namespace recipes go through the encrypted file. Also records that the registry-reader token is non-expiring and that a rotated value is picked up on the next pull. --- docs/registry-pull-auth.md | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/docs/registry-pull-auth.md b/docs/registry-pull-auth.md index c52ab6c..b9e4a20 100644 --- a/docs/registry-pull-auth.md +++ b/docs/registry-pull-auth.md @@ -57,6 +57,9 @@ for **rotating** the token. ### Rotate it +The SOPS file is the source of truth — a `kubectl apply` of a new Secret is reverted by the next +`apps` reconcile, so rotate in git: + ```bash # 1. token (mint a fresh one; never echo it) kubectl -n forgejo exec deploy/forgejo -- su-exec git forgejo admin user generate-access-token \ @@ -65,7 +68,7 @@ kubectl -n forgejo exec deploy/forgejo -- su-exec git forgejo admin user generat # then the command above; the password is only needed for interactive login and is # never used by containerd.) -# 2. build the dockerconfigjson without printing it +# 2. rewrite the encrypted value in every namespace's file (no plaintext ever hits disk) umask 077 read -r -s -p 'token: ' RT; echo python3 - "$RT" > /tmp/dc.json <<'PY' @@ -75,21 +78,33 @@ print(json.dumps({"auths": {"forgejo.siriusdevops.com": { "username": "registry-reader", "password": t, "auth": base64.b64encode(f"registry-reader:{t}".encode()).decode()}}})) PY - -# 3. one Secret per namespace for ns in osint piedmont sirius-growth siriusdevops; do - kubectl create secret generic forgejo-pull -n "$ns" \ - --type=kubernetes.io/dockerconfigjson --from-file=.dockerconfigjson=/tmp/dc.json \ - --dry-run=client -o yaml | kubectl apply -f - + f=apps/base/$ns/secret-forgejo-pull.sops.yaml + sops decrypt --output-type json "$f" \ + | jq --rawfile dc /tmp/dc.json '.data[".dockerconfigjson"] = ($dc | rtrimstr("\n") | @base64)' \ + | sops encrypt --filename-override "$f" --input-type json --output-type yaml /dev/stdin > /tmp/new.yaml \ + && mv /tmp/new.yaml "$f" done shred -u /tmp/dc.json +git commit -am 'registry(auth): rotate the pull token' && git push && # then PR + merge + reconcile ``` +The consumer picks the new value up on its **next pull** — the Secret is read per pull, so no pod +restart is needed. Delete the old token in Forgejo afterwards (`profile → Applications`). + +The `registry-reader` token is minted without `--expires-at`, i.e. non-expiring; rotating it is +therefore an explicit action, not something the clock forces. + ### Add a namespace -`kubectl create secret` as above **and** `imagePullSecrets: [{name: forgejo-pull}]` in the -pod spec (or on the namespace's ServiceAccount) — do not add the secret to workloads that do -not pull from this registry. +Three edits, all in git: + +1. copy an existing `secret-forgejo-pull.sops.yaml` into `apps/base//` and point it at the + namespace (`sops` re-encrypts on save; `metadata.namespace` is not encrypted); +2. list it plus `secret-.sops.yaml` in that app's `kustomization.yaml` (the "Secrets, + SOPS/age-encrypted in git" block); +3. `imagePullSecrets: [{name: forgejo-pull}]` in the pod spec (or on the namespace's + ServiceAccount) — do not add the secret to workloads that do not pull from this registry. ## Why not a node-level credential -- 2.52.0