8절 결정 1·6과 7.1·7.7절을 넣는다. 지금 k3s datastore와 Gitea(저장소·패키지·첨부·Actions·app.ini)는 백업이 하나도 없다. W1은 platform-postgres만 맡는다.
백업(호스트 systemd 타이머, root): k3s datastore 매일(sqlite3 .backup + server/token), Gitea 매주(gitea dump --skip-db를 라이브 파드에서 stdout으로). 둘 다 새 AIStor bucket platform-host-backups(HDD sdb3, W1의 postgres 백업과 같은 AIStor)에 sha256과 함께 올린다. 보관은 lifecycle로 gitea 56일, k3s 30일.
off-host 사본: 변수 둘(gpg 공개 키 파일, rclone 대상)로 준비만 하고 기본은 꺼 둔다. 위치는 소유자 최종 보고로 넘긴다.
점검 타이머(일반 사용자): k3s 6443·10250 serving 인증서 만료, origin/main 기준 라이브 drift 검사(PR #4 스크립트).
경보: services/platform-host-checks PrometheusRule — 백업 나이·실패·지표 없음, drift 6시간, drift 검사 멈춤, 인증서 100일·14일. kube-prometheus-stack의 울릴 수 없는 Kubelet 인증서 경보 둘을 끈다.
복원 리허설: k3s는 같은 버전 k3s를 네트워크 없는 일회용 컨테이너로 띄워 Secret 수와 복호화까지, Gitea는 dump를 풀어 app.ini·git fsck·저장소 수까지 본다.
AIStor(Loki·Tempo)는 백업하지 않는다고 README에 적었다(결정 6).
고른 방법과 버린 대안
클러스터 안 CronJob을 버렸다. datastore는 root 소유 호스트 파일이라 hostPath root 파드가 필요하고, gitea dump는 DB 연결이 필요해 Gitea 라벨을 단 두 번째 파드(그러면 Service가 그 파드로도 보낸다)나 새 DB 허용이 필요하다. 호스트 타이머가 권한이 더 작다. 호스트에서 AIStor Service(ClusterIP:80)로 바로 닿는 것을 확인했다.
지표는 node-exporter textfile 수집기로 올린다. kube-state-metrics는 호스트 작업을 모른다. 수집기를 켜는 한 줄은 W1 파일이라 W1에 요청했다(--collector.textfile.directory=/host/root/var/lib/node_exporter/textfile_collector).
root 타이머가 쓰는 스크립트는 설치 스크립트가 /usr/local/lib/platform-backup(root 소유)으로 복사한다. 데스크톱 사용자가 고칠 수 있는 checkout의 파일을 root가 실행하지 않게 하려는 것이다.
mc에는 키를 명령줄로 넘기지 않는다(ps에 보임). 0600 env 파일과 --env-file만 쓴다.
API 서버 인증서 만료는 blackbox가 아니라 호스트 openssl로 잰다. blackbox 모듈은 모두 검증하는 http라 k3s CA를 모르고, 모듈을 늘리면 관측 core 렌더 불변식까지 바꿔야 한다.
타이머에 PrivateTmp를 쓰지 않는다. dockerd가 그 경로를 못 봐서 mc 컨테이너의 mount가 빈 폴더가 된다.
위험과 영향
이 PR은 아무것도 설치하지 않는다. 소유자 단계: create-host-backup-credentials.sh(sudo, bucket·정책·사용자·/etc/platform-backup/aistor.env) → install-host-checks.sh --execute(sudo) → kubectl apply -k services/platform-host-checks → 리허설 둘. 순서와 명령은 services/platform-host-checks/README.md.
k3s 백업에는 token이 들어 있다. datastore와 함께면 모든 Secret을 풀 수 있다. Gitea dump의 app.ini에도 비밀 값이 있다. bucket은 전용 사용자만 읽고 쓴다.
textfile 수집기(W1)가 들어오기 전에는 PlatformHostBackupMetricsAbsent가 하루 뒤 울린다. 의도한 동작이다.
Gitea dump는 일요일 04:00에 라이브 Gitea 컨테이너에서 돈다(지금 약 370MB, 몇십 초 CPU).
kube-prometheus-stack values 변경은 관측 core를 다시 적용해야 반영된다(PrometheusRule 둘이 빠지는 것뿐, 재시작 없음).
docs/reviews/2026-11-11-k3s-maturity-review.md A1·A11·A13·A14, 7.1·7.7, 8절 결정 1·6
W1 services/platform-postgres-backup/README.md(같은 AIStor, 같은 mc 이미지)
뒤에 더한 커밋 둘 (총괄이 병합 전 본문에 덧붙임)
9e9ea94 k3s datastore 백업을 AIStor 밖에도 둔다: /srv/k3s/aistor/host-backups/k3s-datastore/(root 0700, HDD sdb3)에 최근 7개를 남긴다. AIStor는 같은 k3s 위에서 돌아서, 클러스터를 통째로 잃으면 AIStor를 다시 띄우기 전에는 그 안의 사본을 못 꺼낸다. 로컬 사본은 sdb3를 mount만 하면 읽힌다(docs/runbooks/k3s-datastore-restore.md).
cb78ccd Gitea dump 옆에 그 dump를 만든 Gitea 버전과 저장소 수를 적은 .meta를 같이 올린다. 복원할 때 같은 버전 이미지를 고르고, 복원 뒤 저장소 수를 대조한다.
## 무엇을, 왜
8절 결정 1·6과 7.1·7.7절을 넣는다. 지금 k3s datastore와 Gitea(저장소·패키지·첨부·Actions·`app.ini`)는 백업이 하나도 없다. W1은 platform-postgres만 맡는다.
- **백업(호스트 systemd 타이머, root)**: k3s datastore 매일(`sqlite3 .backup` + `server/token`), Gitea 매주(`gitea dump --skip-db`를 라이브 파드에서 stdout으로). 둘 다 새 AIStor bucket `platform-host-backups`(HDD sdb3, W1의 postgres 백업과 같은 AIStor)에 sha256과 함께 올린다. 보관은 lifecycle로 gitea 56일, k3s 30일.
- **off-host 사본**: 변수 둘(gpg 공개 키 파일, rclone 대상)로 준비만 하고 기본은 꺼 둔다. 위치는 소유자 최종 보고로 넘긴다.
- **점검 타이머(일반 사용자)**: k3s 6443·10250 serving 인증서 만료, `origin/main` 기준 라이브 drift 검사(PR #4 스크립트).
- **경보**: `services/platform-host-checks` PrometheusRule — 백업 나이·실패·지표 없음, drift 6시간, drift 검사 멈춤, 인증서 100일·14일. kube-prometheus-stack의 울릴 수 없는 Kubelet 인증서 경보 둘을 끈다.
- **복원 리허설**: k3s는 같은 버전 k3s를 네트워크 없는 일회용 컨테이너로 띄워 Secret 수와 복호화까지, Gitea는 dump를 풀어 `app.ini`·`git fsck`·저장소 수까지 본다.
- **AIStor(Loki·Tempo)는 백업하지 않는다**고 README에 적었다(결정 6).
## 고른 방법과 버린 대안
- 클러스터 안 CronJob을 버렸다. datastore는 root 소유 호스트 파일이라 hostPath root 파드가 필요하고, `gitea dump`는 DB 연결이 필요해 Gitea 라벨을 단 두 번째 파드(그러면 Service가 그 파드로도 보낸다)나 새 DB 허용이 필요하다. 호스트 타이머가 권한이 더 작다. 호스트에서 AIStor Service(ClusterIP:80)로 바로 닿는 것을 확인했다.
- 지표는 node-exporter textfile 수집기로 올린다. kube-state-metrics는 호스트 작업을 모른다. 수집기를 켜는 한 줄은 W1 파일이라 W1에 요청했다(`--collector.textfile.directory=/host/root/var/lib/node_exporter/textfile_collector`).
- root 타이머가 쓰는 스크립트는 설치 스크립트가 `/usr/local/lib/platform-backup`(root 소유)으로 복사한다. 데스크톱 사용자가 고칠 수 있는 checkout의 파일을 root가 실행하지 않게 하려는 것이다.
- `mc`에는 키를 명령줄로 넘기지 않는다(`ps`에 보임). 0600 env 파일과 `--env-file`만 쓴다.
- API 서버 인증서 만료는 blackbox가 아니라 호스트 `openssl`로 잰다. blackbox 모듈은 모두 검증하는 http라 k3s CA를 모르고, 모듈을 늘리면 관측 core 렌더 불변식까지 바꿔야 한다.
- 타이머에 `PrivateTmp`를 쓰지 않는다. dockerd가 그 경로를 못 봐서 `mc` 컨테이너의 mount가 빈 폴더가 된다.
## 위험과 영향
- 이 PR은 아무것도 설치하지 않는다. 소유자 단계: `create-host-backup-credentials.sh`(sudo, bucket·정책·사용자·`/etc/platform-backup/aistor.env`) → `install-host-checks.sh --execute`(sudo) → `kubectl apply -k services/platform-host-checks` → 리허설 둘. 순서와 명령은 `services/platform-host-checks/README.md`.
- k3s 백업에는 token이 들어 있다. datastore와 함께면 모든 Secret을 풀 수 있다. Gitea dump의 `app.ini`에도 비밀 값이 있다. bucket은 전용 사용자만 읽고 쓴다.
- textfile 수집기(W1)가 들어오기 전에는 `PlatformHostBackupMetricsAbsent`가 하루 뒤 울린다. 의도한 동작이다.
- Gitea dump는 일요일 04:00에 라이브 Gitea 컨테이너에서 돈다(지금 약 370MB, 몇십 초 CPU).
- kube-prometheus-stack values 변경은 관측 core를 다시 적용해야 반영된다(PrometheusRule 둘이 빠지는 것뿐, 재시작 없음).
## 검증
desktop. 로그: 공유 노트 `k3s-w6-pr-c-verify.log`.
```text
$ bash scripts/validate/test-platform-host-checks-alerts.sh
SUCCESS: 9 rules found / SUCCESS
PLATFORM HOST CHECK ALERTS PASS (exit 0)
# k3s 문턱을 2일 → 5일로 바꾼 사본: FAILED PlatformK3sDatastoreBackupTooOld (exit 1)
$ bash scripts/validate/render-observability-core.sh --verified-output-dir …
OBSERVABILITY CORE STATIC RENDER PASS
KubeletServerCertificateExpiration 0, KubeletClientCertificateExpiration 0, KubeClientCertificateExpiration 2
$ bash scripts/validate/test-k3s-datastore-restore-drill.sh # 운영 데이터 없음
seed: 3 Secrets, encrypted test Secret rows=3
restored: namespaces=4 secrets=4 with-data=4 in 7s
K3S DATASTORE RESTORE DRILL PASS
$ bash scripts/validate/gitea-backup-restore-drill.sh --from-file <라이브 저장소 dump, 354MB, 시험 뒤 삭제>
repositories in dump: 29, fsck failures: 0 / live Gitea repositories: 29
GITEA RESTORE DRILL PASS
$ bash scripts/validate/k3s-cert-expiry.sh
apiserver certificate notAfter Jul 18 07:28:16 2027 GMT / kubelet … Nov 11 10:21:32 2027 GMT
$ bash scripts/bootstrap/install-host-checks.sh --check
units: systemd-analyze verify clean … CHECK ONLY: nothing changed (exit 0)
```
- `gitea dump --file -`가 정상 tar.gz를 내고 로그는 stderr로 가는 것, 저장소 경로가 `repos/<owner>/<name>.git/`인 것을 라이브에서 확인했다.
- 돌리지 않은 것: 두 백업 스크립트의 업로드 경로와 `create-host-backup-credentials.sh`(root·AIStor 자격 증명 필요), root로 하는 리허설 기본 경로(AIStor에서 내려받기).
## 리뷰어가 볼 곳
- `scripts/lib/host-backup.sh`: 키 전달(`--env-file`), textfile 원자적 쓰기, ClusterIP 찾기.
- `scripts/backup/k3s-datastore-backup.sh`: token 취급, off-host 경로.
- `services/platform-host-checks/prometheus-rules.yaml`: 문턱.
- `scripts/validate/k3s-datastore-restore-drill.sh`: `--network none` 일회용 k3s.
## 관련
- `docs/reviews/2026-11-11-k3s-maturity-review.md` A1·A11·A13·A14, 7.1·7.7, 8절 결정 1·6
- W1 `services/platform-postgres-backup/README.md`(같은 AIStor, 같은 `mc` 이미지)
## 뒤에 더한 커밋 둘 (총괄이 병합 전 본문에 덧붙임)
- `9e9ea94` k3s datastore 백업을 AIStor 밖에도 둔다: `/srv/k3s/aistor/host-backups/k3s-datastore/`(root 0700, HDD sdb3)에 최근 7개를 남긴다. AIStor는 같은 k3s 위에서 돌아서, 클러스터를 통째로 잃으면 AIStor를 다시 띄우기 전에는 그 안의 사본을 못 꺼낸다. 로컬 사본은 sdb3를 mount만 하면 읽힌다(`docs/runbooks/k3s-datastore-restore.md`).
- `cb78ccd` Gitea dump 옆에 그 dump를 만든 Gitea 버전과 저장소 수를 적은 `.meta`를 같이 올린다. 복원할 때 같은 버전 이미지를 고르고, 복원 뒤 저장소 수를 대조한다.
Nothing backs up the k3s datastore or Gitea's repositories, packages and
app.ini. W1 covers platform-postgres only. One SSD failure loses the
source, CI artefacts, published libraries and every cluster Secret.
Add two root systemd timers that write to a new AIStor bucket on the
HDD (platform-host-backups, same AIStor as W1's postgres backups):
- k3s datastore, daily: sqlite3 .backup of the live state.db plus the
server token (k3s backup/restore docs: the token is needed to read
it back), integrity_check, tar.gz, sha256, upload. Off-host copy is
prepared behind two variables (gpg recipient file, rclone target) and
stays off until the owner chooses a place.
- Gitea, weekly: gitea dump --skip-db streamed from the live container,
listing checked for app.ini and repositories, sha256, upload. The DB
is in the CNPG backup.
Each run writes textfile metrics for the alerts in the next commit.
create-host-backup-credentials.sh makes the bucket (50GiB quota,
lifecycle 56 days for gitea/, 30 days for k3s-datastore/), a
bucket-scoped policy and user, and a root-only env file; no key is
printed and mc gets keys only through a 0600 env file.
Rejected: in-cluster CronJobs. The datastore is a root-owned host file
and the dump needs the Gitea DB connection; a hostPath root pod or a
second Gitea-labelled pod is a larger privilege than a root timer.
Risk: not installed here (owner sudo steps). The k3s archive holds the
token; together with the datastore it decrypts every Secret. It lives
in a bucket only the backup user can read.
Verification (desktop): a dump streamed with --file - is a valid
tar.gz with app.ini; repositories appear as repos/<owner>/<name>.git
(29, matching the live count). The scripts parse with bash -n.
Backups, the daily drift check and the k3s serving certificates have no
alert. k3s renews certificates only when it starts within 120 days of
expiry, and the two kube-prometheus-stack kubelet certificate alerts
can never fire because the k3s kubelet exports no
kubelet_certificate_manager_* metric.
Add a PrometheusRule (platform-host-checks) for backup age, failed
runs, missing metrics, drift left for 6h, a stale drift check, and
serving certificate expiry (warning under 100 days, critical under 14).
Add the two remaining host timers (certificate expiry via openssl on
6443 and 10250; the drift check against origin/main) and an installer
that copies the scripts to a root-owned path, creates the textfile and
work directories and enables all four timers. Disable the two dead
kubelet certificate rules in kube-prometheus-stack.
Risk: the metrics need the node-exporter textfile collector, a one-line
change in W1's node-exporter values that was asked of W1. Until then
PlatformHostBackupMetricsAbsent fires after a day, which is the point.
Verification (desktop):
- test-platform-host-checks-alerts.sh: promtool check and unit tests
pass; with the k3s threshold changed from 2 to 5 days they fail.
- render-observability-core.sh passes; the render has no Kubelet*
certificate alerts and still has both KubeClientCertificateExpiration.
- k3s-cert-expiry.sh as the desktop user reads both certificates.
- install-host-checks.sh --check: systemd-analyze verify is clean.
A backup nobody has restored is not known to work. The 2026-08 k3s
recovery bundle never got its isolated restore drill.
k3s-datastore-restore-drill.sh downloads the latest archive, checks its
sha256 and integrity, starts the same k3s version in a network-less
throwaway container on the copy, and checks the API comes up, the
Secret count is close to live and every Secret decrypts with the
token. gitea-backup-restore-drill.sh extracts the latest dump and
checks app.ini (INTERNAL_TOKEN, SECRET_KEY), git fsck on every
repository and the repository count against live Gitea. Both accept a
local copy and write a drill timestamp metric.
Risk: read-only for the cluster. The k3s drill runs the restored
control plane with --network none, so its controllers reach nothing.
Verification (desktop):
- test-k3s-datastore-restore-drill.sh: a fresh k3s with three test
Secrets (stored encrypted, k8s:enc:) restores with all Secrets
decrypted in 7s; before folding the WAL the test saw 2 of 3 rows,
which is why the real backup uses sqlite3 .backup.
- gitea-backup-restore-drill.sh on a live repository dump: 29
repositories, 0 fsck failures, 29 live; the dump was deleted after.
AIStor runs inside the k3s cluster that the datastore archive restores.
After losing the whole cluster the AIStor copy cannot be read until k3s
is running again, which is what the archive is for.
Also keep the seven newest archives in
/srv/k3s/aistor/host-backups/k3s-datastore (root 0700) on the same HDD
filesystem (sdb3). The directory is next to AIStor's drive directory
data/, so AIStor does not list it as a bucket, and it is readable by
mounting sdb3 alone. A metric reports how many local copies exist.
Rejected: the NTFS archive partition (sdb2). It has no Unix
permissions and Windows on the same machine can read it; the archive
holds the server token.
Risk: the files live inside the AIStor PersistentVolume root, which is
mounted into the MinIO pod (uid 1000); mode 0700 root keeps the pod
from reading them.
Verification: bash -n; /srv/k3s/aistor contains only data/ (2026-11-12).
A Gitea dump must be restored with the Gitea version that wrote it, and
a restore checks the repository count against the dump. Neither was
recorded outside the archive, so the restore runbook had nothing to
compare with.
Upload a small .meta file with each dump: creation time, the
Deployment image, the gitea --version output and the repository count.
docs/runbooks/gitea-restore.md reads it.
Risk: none for the backup itself; the file holds no secret.
Verification: bash -n; kubectl -n gitea exec deploy/gitea -c gitea --
gitea --version prints "gitea version 1.27.0 built with ..." on the
desktop, so the third field is the version.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
무엇을, 왜
8절 결정 1·6과 7.1·7.7절을 넣는다. 지금 k3s datastore와 Gitea(저장소·패키지·첨부·Actions·
app.ini)는 백업이 하나도 없다. W1은 platform-postgres만 맡는다.sqlite3 .backup+server/token), Gitea 매주(gitea dump --skip-db를 라이브 파드에서 stdout으로). 둘 다 새 AIStor bucketplatform-host-backups(HDD sdb3, W1의 postgres 백업과 같은 AIStor)에 sha256과 함께 올린다. 보관은 lifecycle로 gitea 56일, k3s 30일.origin/main기준 라이브 drift 검사(PR #4 스크립트).services/platform-host-checksPrometheusRule — 백업 나이·실패·지표 없음, drift 6시간, drift 검사 멈춤, 인증서 100일·14일. kube-prometheus-stack의 울릴 수 없는 Kubelet 인증서 경보 둘을 끈다.app.ini·git fsck·저장소 수까지 본다.고른 방법과 버린 대안
gitea dump는 DB 연결이 필요해 Gitea 라벨을 단 두 번째 파드(그러면 Service가 그 파드로도 보낸다)나 새 DB 허용이 필요하다. 호스트 타이머가 권한이 더 작다. 호스트에서 AIStor Service(ClusterIP:80)로 바로 닿는 것을 확인했다.--collector.textfile.directory=/host/root/var/lib/node_exporter/textfile_collector)./usr/local/lib/platform-backup(root 소유)으로 복사한다. 데스크톱 사용자가 고칠 수 있는 checkout의 파일을 root가 실행하지 않게 하려는 것이다.mc에는 키를 명령줄로 넘기지 않는다(ps에 보임). 0600 env 파일과--env-file만 쓴다.openssl로 잰다. blackbox 모듈은 모두 검증하는 http라 k3s CA를 모르고, 모듈을 늘리면 관측 core 렌더 불변식까지 바꿔야 한다.PrivateTmp를 쓰지 않는다. dockerd가 그 경로를 못 봐서mc컨테이너의 mount가 빈 폴더가 된다.위험과 영향
create-host-backup-credentials.sh(sudo, bucket·정책·사용자·/etc/platform-backup/aistor.env) →install-host-checks.sh --execute(sudo) →kubectl apply -k services/platform-host-checks→ 리허설 둘. 순서와 명령은services/platform-host-checks/README.md.app.ini에도 비밀 값이 있다. bucket은 전용 사용자만 읽고 쓴다.PlatformHostBackupMetricsAbsent가 하루 뒤 울린다. 의도한 동작이다.검증
desktop. 로그: 공유 노트
k3s-w6-pr-c-verify.log.gitea dump --file -가 정상 tar.gz를 내고 로그는 stderr로 가는 것, 저장소 경로가repos/<owner>/<name>.git/인 것을 라이브에서 확인했다.create-host-backup-credentials.sh(root·AIStor 자격 증명 필요), root로 하는 리허설 기본 경로(AIStor에서 내려받기).리뷰어가 볼 곳
scripts/lib/host-backup.sh: 키 전달(--env-file), textfile 원자적 쓰기, ClusterIP 찾기.scripts/backup/k3s-datastore-backup.sh: token 취급, off-host 경로.services/platform-host-checks/prometheus-rules.yaml: 문턱.scripts/validate/k3s-datastore-restore-drill.sh:--network none일회용 k3s.관련
docs/reviews/2026-11-11-k3s-maturity-review.mdA1·A11·A13·A14, 7.1·7.7, 8절 결정 1·6services/platform-postgres-backup/README.md(같은 AIStor, 같은mc이미지)뒤에 더한 커밋 둘 (총괄이 병합 전 본문에 덧붙임)
9e9ea94k3s datastore 백업을 AIStor 밖에도 둔다:/srv/k3s/aistor/host-backups/k3s-datastore/(root 0700, HDD sdb3)에 최근 7개를 남긴다. AIStor는 같은 k3s 위에서 돌아서, 클러스터를 통째로 잃으면 AIStor를 다시 띄우기 전에는 그 안의 사본을 못 꺼낸다. 로컬 사본은 sdb3를 mount만 하면 읽힌다(docs/runbooks/k3s-datastore-restore.md).cb78ccdGitea dump 옆에 그 dump를 만든 Gitea 버전과 저장소 수를 적은.meta를 같이 올린다. 복원할 때 같은 버전 이미지를 고르고, 복원 뒤 저장소 수를 대조한다.