Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddc1a5732e |
33 changed files with 356 additions and 1280 deletions
|
|
@ -1,74 +0,0 @@
|
||||||
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).
|
|
||||||
# --metadata-file carries the pushed manifest digest. Do NOT read it
|
|
||||||
# back with `buildx imagetools inspect`: Forgejo's /v2/token answers
|
|
||||||
# 403 to that scope set (measured), while push and kubelet pull are
|
|
||||||
# fine.
|
|
||||||
docker buildx build --platform linux/amd64 \
|
|
||||||
--provenance=false --sbom=false \
|
|
||||||
-t "$image:$sha" \
|
|
||||||
--push --metadata-file /tmp/build-meta.json images/backup
|
|
||||||
echo "pushed $image:$sha"
|
|
||||||
digest=$(tr -d '\n' < /tmp/build-meta.json \
|
|
||||||
| sed -n 's/.*"containerimage\.digest": *"\(sha256:[a-f0-9]*\)".*/\1/p')
|
|
||||||
[ -n "$digest" ] || { echo "::error::no containerimage.digest in build metadata"; cat /tmp/build-meta.json; exit 1; }
|
|
||||||
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}"
|
|
||||||
|
|
@ -87,10 +87,12 @@ data:
|
||||||
# (the node runs close to DiskPressure and `local-path` lives on it).
|
# (the node runs close to DiskPressure and `local-path` lives on it).
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# No package install here on purpose: rsync/openssh-client/bash/kubectl are
|
# alpine/k8s ships kubectl/bash but not rsync/ssh; install them per run
|
||||||
# baked into the pinned image (images/backup/Dockerfile) and this pod's
|
# (~2 s). Nothing else is needed: the DB dumps run inside the CNPG pod.
|
||||||
# egress policy admits DNS, 10.10.0.5:22 and the API only, so a runtime
|
if ! command -v rsync >/dev/null || ! command -v ssh >/dev/null; then
|
||||||
# fetch would fail rather than silently dial the Alpine CDN (t_9d0428d8).
|
echo "== installing rsync + openssh-client"
|
||||||
|
apk add --no-cache rsync openssh-client >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
BACKUP_HOST=${BACKUP_HOST:[email protected]}
|
BACKUP_HOST=${BACKUP_HOST:[email protected]}
|
||||||
BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup}
|
BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup}
|
||||||
|
|
@ -244,20 +246,16 @@ spec:
|
||||||
spec:
|
spec:
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
serviceAccountName: cluster-backup
|
serviceAccountName: cluster-backup
|
||||||
# Pulled from the in-cluster Forgejo registry (which requires auth).
|
|
||||||
imagePullSecrets:
|
|
||||||
- name: forgejo-pull
|
|
||||||
# The forgejo-data PVC is local-path on siriussec; the pod must run
|
# The forgejo-data PVC is local-path on siriussec; the pod must run
|
||||||
# where the volume is.
|
# where the volume is.
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/hostname: siriussec
|
||||||
containers:
|
containers:
|
||||||
- name: backup
|
- name: backup
|
||||||
# python3.12-alpine + rsync + openssh-client + bash + kubectl
|
# alpine/k8s carries kubectl 1.36.4 (== cluster version) so the
|
||||||
# v1.36.4 (== cluster version, so the CNPG dumps can be taken
|
# CNPG dumps can be taken through the exec API; rsync + openssh
|
||||||
# through the exec API), all baked at build time and pinned by
|
# are added at start (the pod has normal egress).
|
||||||
# digest. Nothing is installed at run time.
|
image: alpine/k8s:1.36.4
|
||||||
image: forgejo.siriusdevops.com/sirius/backup-tools@sha256:cc8dc1645111b3a80b7c4d5168f6bce3002cae7417b3725683c057976f6e379a
|
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
command: ["/bin/bash", "/scripts/backup.sh"]
|
command: ["/bin/bash", "/scripts/backup.sh"]
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,6 @@ resources:
|
||||||
- httproute.yaml
|
- httproute.yaml
|
||||||
# Default-deny ingress+egress + the namespace allow list (audit F3 / t_fed52919).
|
# Default-deny ingress+egress + the namespace allow list (audit F3 / t_fed52919).
|
||||||
- networkpolicy.yaml
|
- networkpolicy.yaml
|
||||||
# Egress lockdown for the cluster-backup pod: DNS + 10.10.0.5:22 + the API
|
|
||||||
# only. The allow list above cannot be narrowed per pod, so the deny for
|
|
||||||
# `world` in this policy is what applies to the job (card t_9d0428d8).
|
|
||||||
- networkpolicy-backup.yaml
|
|
||||||
- pvc.yaml
|
- pvc.yaml
|
||||||
- cluster.yaml
|
- cluster.yaml
|
||||||
- podmonitor.yaml
|
- podmonitor.yaml
|
||||||
|
|
@ -48,7 +44,3 @@ resources:
|
||||||
- secret-forgejo-runner-amd64-token.sops.yaml
|
- secret-forgejo-runner-amd64-token.sops.yaml
|
||||||
- secret-forgejo-runner-deploy-arm64-token.sops.yaml
|
- secret-forgejo-runner-deploy-arm64-token.sops.yaml
|
||||||
- secret-cluster-backup-ssh.sops.yaml
|
- secret-cluster-backup-ssh.sops.yaml
|
||||||
# Registry pull credential: cluster-backup now runs an image from the
|
|
||||||
# in-cluster Forgejo registry instead of alpine/k8s from Docker Hub
|
|
||||||
# (card t_9d0428d8).
|
|
||||||
- secret-forgejo-pull.sops.yaml
|
|
||||||
|
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
# Egress lockdown for the nightly cluster-backup CronJob (card t_9d0428d8).
|
|
||||||
#
|
|
||||||
# Why: the job used to `apk add --no-cache rsync openssh-client` at container
|
|
||||||
# start, so each run depended on the Alpine CDN (Fastly 151.101.x.132:443) and
|
|
||||||
# tripped `egress-new-dst` whenever that anycast address rotated. rsync/ssh/
|
|
||||||
# bash/kubectl are baked into images/backup/Dockerfile now.
|
|
||||||
#
|
|
||||||
# `forgejo-allow` (networkpolicy.yaml) selects every pod in this namespace and
|
|
||||||
# allows `world`, so a pod-scoped allow list alone would NOT restrict the job —
|
|
||||||
# Cilium unions multiple policies. The `egressDeny` for `world` below is what
|
|
||||||
# actually closes it (deny always beats allow), and it is scoped to this pod by
|
|
||||||
# the endpointSelector, so Forgejo's own webhooks/mirror/avatar egress is
|
|
||||||
# untouched.
|
|
||||||
#
|
|
||||||
# Allow list, and nothing else:
|
|
||||||
# * cluster DNS;
|
|
||||||
# * [email protected]:22 — the Linode node's InternalIP, so `remote-node`, not
|
|
||||||
# `world` (the rsync target and every ssh_r call);
|
|
||||||
# * kube-apiserver on 6443/443 — `kubectl get cluster` for the CNPG primary
|
|
||||||
# and `kubectl exec ... pg_dump` for both CNPG and the plain Postgres
|
|
||||||
# Deployment. Port-scoped on purpose: the apiserver shares its host IP with
|
|
||||||
# the internal Gateway listeners on 8081/8084-8087.
|
|
||||||
apiVersion: cilium.io/v2
|
|
||||||
kind: CiliumNetworkPolicy
|
|
||||||
metadata:
|
|
||||||
name: cluster-backup-egress
|
|
||||||
namespace: forgejo
|
|
||||||
labels:
|
|
||||||
app: cluster-backup
|
|
||||||
spec:
|
|
||||||
description: >-
|
|
||||||
cluster-backup pod: cluster DNS, SSH to the backup host (10.10.0.5:22) and
|
|
||||||
the API (6443/443) only; no internet egress at run time.
|
|
||||||
endpointSelector:
|
|
||||||
matchLabels:
|
|
||||||
app: cluster-backup
|
|
||||||
egress:
|
|
||||||
- toEndpoints:
|
|
||||||
- matchLabels:
|
|
||||||
io.kubernetes.pod.namespace: kube-system
|
|
||||||
k8s-app: kube-dns
|
|
||||||
toPorts:
|
|
||||||
- ports:
|
|
||||||
- port: "53"
|
|
||||||
protocol: UDP
|
|
||||||
- port: "53"
|
|
||||||
protocol: TCP
|
|
||||||
- toEntities:
|
|
||||||
- remote-node
|
|
||||||
toPorts:
|
|
||||||
- ports:
|
|
||||||
- port: "22"
|
|
||||||
protocol: TCP
|
|
||||||
- toEntities:
|
|
||||||
- kube-apiserver
|
|
||||||
toPorts:
|
|
||||||
- ports:
|
|
||||||
- port: "6443"
|
|
||||||
protocol: TCP
|
|
||||||
- port: "443"
|
|
||||||
protocol: TCP
|
|
||||||
egressDeny:
|
|
||||||
- toEntities:
|
|
||||||
- world
|
|
||||||
|
|
@ -3,24 +3,13 @@
|
||||||
# `default-deny` (stock NetworkPolicy, podSelector {}, both directions) is the
|
# `default-deny` (stock NetworkPolicy, podSelector {}, both directions) is the
|
||||||
# deny. `forgejo-allow` (CiliumNetworkPolicy) re-adds what this namespace uses:
|
# deny. `forgejo-allow` (CiliumNetworkPolicy) re-adds what this namespace uses:
|
||||||
# ingress: the Cilium Gateway proxy (`reserved:ingress`) for
|
# ingress: the Cilium Gateway proxy (`reserved:ingress`) for
|
||||||
# forgejo.siriusdevops.com -> forgejo:3000; the CI runners in
|
# forgejo.siriusdevops.com -> forgejo:3000. The CI runners live in
|
||||||
# `ci-runners` on 3000 only (they register/poll over the PUBLIC URL,
|
# `ci-runners` and register/poll over the PUBLIC URL
|
||||||
# so THAT traffic arrives as `reserved:ingress` — but their image
|
# (runner-amd64.yaml: `--instance https://forgejo.siriusdevops.com`),
|
||||||
# pushes go pod->pod to the internal ClusterIP
|
# so they arrive through the Gateway as `reserved:ingress` too and no
|
||||||
# `forgejo.forgejo.svc.cluster.local:3000`
|
# cross-namespace rule is needed. Node/health entities cover kubelet
|
||||||
# (`PUSH_REGISTRY` in each repo's `.forgejo/workflows/build.yml`,
|
# probes; Prometheus in `monitoring` is allowed on 9187 only (the
|
||||||
# docker daemon in the dind sidecar of the runner pod). Pod->pod is
|
# `cnpg-pg` PodMonitor scrapes the CNPG instance manager).
|
||||||
# not `reserved:ingress`, so `default-deny` dropped it and every
|
|
||||||
# image build failed 2026-11-27 .. 2026-12-05 with
|
|
||||||
# `Get "http://forgejo.forgejo.svc.cluster.local:3000/v2/": request
|
|
||||||
# canceled ... Client.Timeout exceeded` — the cross-namespace rule IS
|
|
||||||
# required; do not delete it as redundant. Node/health entities
|
|
||||||
# cover kubelet probes; Prometheus in `monitoring` is allowed on
|
|
||||||
# 9187 only (the
|
|
||||||
# `cnpg-pg` PodMonitor scrapes the CNPG instance manager), and the
|
|
||||||
# CNPG operator in `cnpg-system` on 8000 only — the instance
|
|
||||||
# manager's HTTPS status endpoint the operator reads to derive the
|
|
||||||
# system ID and drive failover (card t_4210edec).
|
|
||||||
# egress: cluster DNS; its own pods (forgejo -> pg-rw:5432); `world` for
|
# egress: cluster DNS; its own pods (forgejo -> pg-rw:5432); `world` for
|
||||||
# outbound HTTPS (Forgejo webhooks, avatar/mirror fetches, the
|
# outbound HTTPS (Forgejo webhooks, avatar/mirror fetches, the
|
||||||
# public-URL callbacks the runner flow needs); node IPs on 22, which
|
# public-URL callbacks the runner flow needs); node IPs on 22, which
|
||||||
|
|
@ -30,8 +19,7 @@
|
||||||
# `kubectl exec` DB dumps.
|
# `kubectl exec` DB dumps.
|
||||||
#
|
#
|
||||||
# The CI runner pods themselves are NOT in this namespace (they moved to
|
# The CI runner pods themselves are NOT in this namespace (they moved to
|
||||||
# `ci-runners` for `enforce: privileged`); `forgejo-allow` only grants them
|
# `ci-runners` for `enforce: privileged`) and are out of scope for this card.
|
||||||
# forgejo:3000, which is the registry push path the builds depend on.
|
|
||||||
apiVersion: networking.k8s.io/v1
|
apiVersion: networking.k8s.io/v1
|
||||||
kind: NetworkPolicy
|
kind: NetworkPolicy
|
||||||
metadata:
|
metadata:
|
||||||
|
|
@ -50,9 +38,8 @@ metadata:
|
||||||
namespace: forgejo
|
namespace: forgejo
|
||||||
spec:
|
spec:
|
||||||
description: >-
|
description: >-
|
||||||
forgejo: gateway + kubelet + Prometheus + ci-runners registry-push ingress;
|
forgejo: gateway + kubelet + Prometheus ingress; egress to own namespace,
|
||||||
egress to own namespace, cluster DNS, the internet, SSH on node IPs and the
|
cluster DNS, the internet, SSH on node IPs and the API.
|
||||||
API.
|
|
||||||
endpointSelector: {}
|
endpointSelector: {}
|
||||||
ingress:
|
ingress:
|
||||||
- fromEntities:
|
- fromEntities:
|
||||||
|
|
@ -67,33 +54,6 @@ spec:
|
||||||
- fromEndpoints:
|
- fromEndpoints:
|
||||||
- matchLabels:
|
- matchLabels:
|
||||||
io.kubernetes.pod.namespace: forgejo
|
io.kubernetes.pod.namespace: forgejo
|
||||||
# CI runners (`ci-runners`) push images to the in-cluster registry at
|
|
||||||
# forgejo.forgejo.svc.cluster.local:3000 (PUSH_REGISTRY in each repo's
|
|
||||||
# build workflow; the docker daemon lives in the dind sidecar of the same
|
|
||||||
# pod, so one namespace selector covers runner + sidecar). Registration and
|
|
||||||
# polling use the public URL and arrive as `reserved:ingress`, but the push
|
|
||||||
# is pod -> pod and default-deny drops it without this rule. Port-scoped on
|
|
||||||
# purpose: the registry API only, nothing else in the namespace.
|
|
||||||
- fromEndpoints:
|
|
||||||
- matchLabels:
|
|
||||||
io.kubernetes.pod.namespace: ci-runners
|
|
||||||
toPorts:
|
|
||||||
- ports:
|
|
||||||
- port: "3000"
|
|
||||||
protocol: TCP
|
|
||||||
# The CNPG operator (`cnpg-system`) reads the instance manager's HTTPS
|
|
||||||
# status endpoint to derive the system ID and drive switchover/promotion.
|
|
||||||
# Without it the Cluster reports `Instance Status Extraction Error` and
|
|
||||||
# Ready=False while the pods serve traffic, and automated failover is dead
|
|
||||||
# (card t_4210edec). Scoped to 8000: not 5432, not the whole namespace.
|
|
||||||
- fromEndpoints:
|
|
||||||
- matchLabels:
|
|
||||||
io.kubernetes.pod.namespace: cnpg-system
|
|
||||||
app.kubernetes.io/name: cloudnative-pg
|
|
||||||
toPorts:
|
|
||||||
- ports:
|
|
||||||
- port: "8000"
|
|
||||||
protocol: TCP
|
|
||||||
# Prometheus scrapes the CNPG `pg` instance manager on 9187.
|
# Prometheus scrapes the CNPG `pg` instance manager on 9187.
|
||||||
- fromEndpoints:
|
- fromEndpoints:
|
||||||
- matchLabels:
|
- matchLabels:
|
||||||
|
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
data:
|
|
||||||
.dockerconfigjson: ENC[AES256_GCM,data:QS5gZUJ0zi3YYSaCpJWSCA/JakeknWmlQ8WVKlyxh2k4zo/Ul33lhH5iQP27Z3ec6FyEtV8TUSdhkq1wGSCF7cRu00ze4qljMuviU35x2Dl5aMc7JEWvRPnypoBYNmTRulPZh5E3GdiR9VUzok643P0igJyHlQBjO8HkLiuZ41Zd7JYordQRPTH4tXlDbiJPEPfkMEyFHY/6XdEEUNv5eIUyb004d1xZccnGaMwliVNBL5xIbJpb4Bza9/Z8NYsq70cmjHH/hFq7uotnSt3B53vPnwf6Rsq9j44i3M0xQjHQf+QYa34mFncHznwxPczLo8wcmKFmZYkNZNXxzc/NryeC4w950GUZ+cSO1UKLhS8IGIal8S05IWmeIuda1k9V,iv:AN7Fn/JmSYqiERsqneSOMeV3kMRGcawgV4Y9iJrjF7E=,tag:XwEZy+ULOGiFTW1diodMgg==,type:str]
|
|
||||||
kind: Secret
|
|
||||||
metadata:
|
|
||||||
name: forgejo-pull
|
|
||||||
namespace: forgejo
|
|
||||||
type: kubernetes.io/dockerconfigjson
|
|
||||||
sops:
|
|
||||||
age:
|
|
||||||
- enc: |
|
|
||||||
-----BEGIN AGE ENCRYPTED FILE-----
|
|
||||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBjTmlMUDZOdnc1U3RGM1Jh
|
|
||||||
TTNmU3pRV3M1Y2lkNitqMkE0WHRZdXNOSlRJCnZ2eDB3ZXpvWDR6dHJBeWJpdElI
|
|
||||||
a24xelp4dGluNXNGUzJYOWlPNzdwM0EKLS0tIGJuUk1CUEEvZlVWYlFKTnVwWVRS
|
|
||||||
M2o5LzBJSEpXaklKc0ZMZ0FDa3NlV0UKmNVnlKd/Xqbisox3hrAeK45sbLJW5yS3
|
|
||||||
Y6KfweCLwk6edQ9YflAvmk2FWVi0PIMdmloObXVSvB/ZY+jeLlK4lA==
|
|
||||||
-----END AGE ENCRYPTED FILE-----
|
|
||||||
recipient: age12zdn7x72zrgu9cdv8wdj7xfx42nz09nrwpc2g09cwx5fwdm0ry6qp5h4jp
|
|
||||||
encrypted_regex: ^(data|stringData)$
|
|
||||||
lastmodified: "2026-12-04T05:28:22Z"
|
|
||||||
mac: ENC[AES256_GCM,data:goW5PeSFtc0ga5gTDAZpYFQ8xBTXA2dgOomUK9t9GX3T7nswhu6fmfXJ2zjqyYLKJ5wnVEY4pvwx9RThEpU0khcP8iBqyrzUvIEXUsoQ5lTegRxgyuowPKWBkQcrJPx5GEgHSJr5J6XlDKbbCeOW0SxnerPhpJ03ueh3yULPgKw=,iv:Z/hm3jpUXzWeabPXuecuAIm+bemjluy/xjas8dg7bUY=,tag:3coZnG6p2v6ZT0raG7b1IQ==,type:str]
|
|
||||||
version: 3.13.3
|
|
||||||
|
|
@ -15,7 +15,7 @@ instead of a host Docker container on the Pi.
|
||||||
| `osint-camera-service` | same app image | public-camera discovery + snapshots (PVC `osint-camera-snapshots` 3 Gi, shared with the app) |
|
| `osint-camera-service` | same app image | public-camera discovery + snapshots (PVC `osint-camera-snapshots` 3 Gi, shared with the app) |
|
||||||
| `osint-titiler` | `forgejo…/sirius/titiler:0.26.0` | SAR COG tile proxy, exposed same-origin at `/titiler` |
|
| `osint-titiler` | `forgejo…/sirius/titiler:0.26.0` | SAR COG tile proxy, exposed same-origin at `/titiler` |
|
||||||
| `osint-news-scraper` | `forgejo…/sirius/osint-news-scraper:amd64-58f71f5b4520` | Scrapy news scraper loop |
|
| `osint-news-scraper` | `forgejo…/sirius/osint-news-scraper:amd64-58f71f5b4520` | Scrapy news scraper loop |
|
||||||
| `osint-news-summarizer` | `forgejo…/sirius/osint-news-summarizer:amd64-fb5285df7f38` | "analyst" — Nous Portal briefs every 15 min + 23:00 recap |
|
| `osint-news-summarizer` | `forgejo…/sirius/osint-news-summarizer:amd64-fe2b5df369d0` | "analyst" — Nous Portal briefs every 15 min + 23:00 recap |
|
||||||
|
|
||||||
Every workload is pinned to `kubernetes.io/hostname: siriussec` (Gateway/Envoy
|
Every workload is pinned to `kubernetes.io/hostname: siriussec` (Gateway/Envoy
|
||||||
co-location + local-path PVs).
|
co-location + local-path PVs).
|
||||||
|
|
@ -133,29 +133,11 @@ it can actually parse.
|
||||||
|
|
||||||
## Analyst model
|
## Analyst model
|
||||||
|
|
||||||
`SUMMARY_MODEL=deepseek/deepseek-v4.1-flash-1017` (Nous Portal, 1M context,
|
`SUMMARY_MODEL=meituan/longcat-2.5:free` (free tier on the Nous Portal,
|
||||||
verified to honour `response_format: json_object`; the previous free
|
1M context, verified to honour `response_format: json_object`). It is set in
|
||||||
`meituan/longcat-2.5:free` id was retired and 404'd every call). When picking a
|
|
||||||
replacement, confirm it is in `GET /v1/models` — a stale id fails silently
|
|
||||||
because `chat()` swallows non-200s and returns an empty string. It is set in
|
|
||||||
`configmap.yaml`; changing it in the UI (`PUT /api/settings`) only takes effect
|
`configmap.yaml`; changing it in the UI (`PUT /api/settings`) only takes effect
|
||||||
when the env var is empty, because `resolve_model()` prefers the env.
|
when the env var is empty, because `resolve_model()` prefers the env.
|
||||||
|
|
||||||
## Analyst resilience + map concurrency (PR #72)
|
|
||||||
|
|
||||||
`SUMMARY_MAP_CONCURRENCY` (16, in `configmap.yaml`) sets how many map calls are
|
|
||||||
in flight. Each call is a ~20 s wall clock, so the phase is latency-bound: the
|
|
||||||
746-batch recap measured **951 s** end-to-end at 16, where 8 is projected at
|
|
||||||
~98 min. The code default is also 16; the env var is pinned so a default change
|
|
||||||
upstream cannot silently stretch the 15-min interval past its window.
|
|
||||||
|
|
||||||
A non-retryable Nous rejection (400/404/422 — e.g. a retired model id) now
|
|
||||||
raises `NousAPIError` and aborts the run with `rc=1` instead of being swallowed
|
|
||||||
as an empty completion, so the failure shows up in the pod log on the *first*
|
|
||||||
tick rather than as nine days of "idle" ticks. The per-run summary line is
|
|
||||||
`summarize done kind=<interval|recap> summary_id=… model=… batches=… articles=…
|
|
||||||
ticker=… map=… elapsed=…s`.
|
|
||||||
|
|
||||||
## Analyst grading (PR #53 + #54)
|
## Analyst grading (PR #53 + #54)
|
||||||
|
|
||||||
The map call scores every article **0-100** against a rubric in the same request
|
The map call scores every article **0-100** against a rubric in the same request
|
||||||
|
|
|
||||||
|
|
@ -1,332 +0,0 @@
|
||||||
# Freshness exporter for the osint analyst (card t_22334588).
|
|
||||||
#
|
|
||||||
# The summarizer (deploy/osint-news-summarizer) wrote no article_summaries rows
|
|
||||||
# from 2026-11-25 to 2026-12-04 while the scraper kept the articles table fresh
|
|
||||||
# (61.5k rows, newest within minutes). Nothing paged: the container was Running
|
|
||||||
# with restarts 0 and only INFO batch lines in the log, so "analyst wedged" and
|
|
||||||
# "analyst idle" looked identical from every signal the cluster had.
|
|
||||||
#
|
|
||||||
# The app has no /metrics endpoint (POST /metrics -> 404 on osint-app), so this
|
|
||||||
# is a tiny read-only exporter that answers the only question that matters:
|
|
||||||
# *when* did each side last write a row? It reads two timestamps from
|
|
||||||
# osint_data and serves them on :9187/metrics:
|
|
||||||
#
|
|
||||||
# osint_analyst_last_success_timestamp_seconds max(article_summaries.batch_timestamp)
|
|
||||||
# osint_ingest_last_article_timestamp_seconds max(articles.timestamp)
|
|
||||||
# osint_analyst_exporter_up 1 when the last DB read succeeded
|
|
||||||
#
|
|
||||||
# PromQL rules live in monitoring/controllers/home/osint-analyst.yaml
|
|
||||||
# (OsintAnalystStale, OsintIngestAliveButNoBrief).
|
|
||||||
#
|
|
||||||
# Why the summarizer image: it is the only image in this namespace that already
|
|
||||||
# ships psycopg2 and a python3, and it is pinned by tag (no floating base). The
|
|
||||||
# script uses the stdlib HTTP server, so nothing is installed at runtime and no
|
|
||||||
# new image build is needed. It tracks the summarizer's own pin (currently
|
|
||||||
# amd64-fb5285df7f38) — bump BOTH together; two different tags for one image in
|
|
||||||
# one namespace reads as drift in an audit, and the exporter only needs the
|
|
||||||
# interpreter + psycopg2, which every summarizer build carries.
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: osint-analyst-exporter
|
|
||||||
namespace: osint
|
|
||||||
data:
|
|
||||||
exporter.py: |
|
|
||||||
#!/usr/bin/env python3
|
|
||||||
"""Read-only freshness exporter for the osint analyst.
|
|
||||||
|
|
||||||
Serves /metrics on :9187. Two timestamps, nothing else:
|
|
||||||
|
|
||||||
osint_analyst_last_success_timestamp_seconds
|
|
||||||
epoch of max(article_summaries.batch_timestamp) -- when the analyst
|
|
||||||
last wrote a brief. 0 means the table is empty (stale by definition).
|
|
||||||
osint_ingest_last_article_timestamp_seconds
|
|
||||||
epoch of max(articles.timestamp) -- when the scraper last ingested.
|
|
||||||
osint_analyst_exporter_up
|
|
||||||
1 when the last database read succeeded, 0 otherwise.
|
|
||||||
|
|
||||||
On a database error the last good values are kept and `up` drops to 0, so
|
|
||||||
the timestamps keep ageing and a broken exporter escalates through the same
|
|
||||||
OsintAnalystStale alert instead of hiding behind missing series.
|
|
||||||
"""
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import threading
|
|
||||||
import time
|
|
||||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
||||||
|
|
||||||
import psycopg2
|
|
||||||
|
|
||||||
LOG = logging.getLogger("osint-analyst-exporter")
|
|
||||||
logging.basicConfig(
|
|
||||||
level=os.getenv("LOG_LEVEL", "INFO"),
|
|
||||||
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
|
||||||
)
|
|
||||||
|
|
||||||
PORT = int(os.getenv("EXPORTER_PORT", "9187"))
|
|
||||||
# One scrape interval (30 s) of cache: Prometheus + probes hitting the
|
|
||||||
# endpoint together must not each open a database connection.
|
|
||||||
CACHE_TTL = float(os.getenv("CACHE_TTL_SECONDS", "10"))
|
|
||||||
|
|
||||||
DB_CONFIG = {
|
|
||||||
"host": os.getenv("DB_HOST", "osint-db"),
|
|
||||||
"port": int(os.getenv("DB_PORT", "5432")),
|
|
||||||
"dbname": os.getenv("DB_NAME", "osint_data"),
|
|
||||||
"user": os.getenv("DB_USER", "osint"),
|
|
||||||
"password": os.getenv("DB_PASSWORD", ""),
|
|
||||||
"connect_timeout": 5,
|
|
||||||
}
|
|
||||||
|
|
||||||
ANALYST_SQL = (
|
|
||||||
"SELECT COALESCE(EXTRACT(EPOCH FROM max(batch_timestamp))::bigint, 0) "
|
|
||||||
"FROM article_summaries"
|
|
||||||
)
|
|
||||||
INGEST_SQL = (
|
|
||||||
"SELECT COALESCE(EXTRACT(EPOCH FROM max(timestamp))::bigint, 0) "
|
|
||||||
"FROM articles"
|
|
||||||
)
|
|
||||||
|
|
||||||
_lock = threading.Lock()
|
|
||||||
_state = {"analyst": 0, "ingest": 0, "up": 0, "last_attempt": 0.0}
|
|
||||||
|
|
||||||
|
|
||||||
def collect() -> tuple[int, int]:
|
|
||||||
conn = psycopg2.connect(**DB_CONFIG)
|
|
||||||
try:
|
|
||||||
conn.autocommit = True
|
|
||||||
with conn.cursor() as cur:
|
|
||||||
cur.execute("SET statement_timeout = 5000")
|
|
||||||
cur.execute(ANALYST_SQL)
|
|
||||||
analyst = int(cur.fetchone()[0] or 0)
|
|
||||||
cur.execute(INGEST_SQL)
|
|
||||||
ingest = int(cur.fetchone()[0] or 0)
|
|
||||||
finally:
|
|
||||||
conn.close()
|
|
||||||
return analyst, ingest
|
|
||||||
|
|
||||||
|
|
||||||
def ensure_fresh() -> None:
|
|
||||||
now = time.time()
|
|
||||||
with _lock:
|
|
||||||
if now - _state["last_attempt"] < CACHE_TTL:
|
|
||||||
return
|
|
||||||
_state["last_attempt"] = now
|
|
||||||
try:
|
|
||||||
analyst, ingest = collect()
|
|
||||||
except Exception as exc: # noqa: BLE001 - never kill the endpoint
|
|
||||||
with _lock:
|
|
||||||
_state["up"] = 0
|
|
||||||
LOG.warning("collect failed: %s", exc)
|
|
||||||
return
|
|
||||||
with _lock:
|
|
||||||
_state.update(analyst=analyst, ingest=ingest, up=1)
|
|
||||||
|
|
||||||
|
|
||||||
def render() -> str:
|
|
||||||
with _lock:
|
|
||||||
analyst = _state["analyst"]
|
|
||||||
ingest = _state["ingest"]
|
|
||||||
up = _state["up"]
|
|
||||||
return (
|
|
||||||
"# HELP osint_analyst_last_success_timestamp_seconds "
|
|
||||||
"Epoch of the newest article_summaries.batch_timestamp (last brief "
|
|
||||||
"written by the analyst); 0 = no row.\n"
|
|
||||||
"# TYPE osint_analyst_last_success_timestamp_seconds gauge\n"
|
|
||||||
f"osint_analyst_last_success_timestamp_seconds {analyst}\n"
|
|
||||||
"# HELP osint_ingest_last_article_timestamp_seconds "
|
|
||||||
"Epoch of the newest articles.timestamp (last row ingested by the "
|
|
||||||
"scraper); 0 = no row.\n"
|
|
||||||
"# TYPE osint_ingest_last_article_timestamp_seconds gauge\n"
|
|
||||||
f"osint_ingest_last_article_timestamp_seconds {ingest}\n"
|
|
||||||
"# HELP osint_analyst_exporter_up 1 when the last database read "
|
|
||||||
"succeeded.\n"
|
|
||||||
"# TYPE osint_analyst_exporter_up gauge\n"
|
|
||||||
f"osint_analyst_exporter_up {up}\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Handler(BaseHTTPRequestHandler):
|
|
||||||
server_version = "osint-analyst-exporter/1.0"
|
|
||||||
|
|
||||||
def do_GET(self): # noqa: N802 - BaseHTTPRequestHandler API
|
|
||||||
path = self.path.split("?", 1)[0]
|
|
||||||
if path not in ("/metrics", "/healthz"):
|
|
||||||
self.send_error(404)
|
|
||||||
return
|
|
||||||
ensure_fresh()
|
|
||||||
body = render().encode()
|
|
||||||
self.send_response(200)
|
|
||||||
self.send_header("Content-Type", "text/plain; version=0.0.4; charset=utf-8")
|
|
||||||
self.send_header("Content-Length", str(len(body)))
|
|
||||||
self.end_headers()
|
|
||||||
self.wfile.write(body)
|
|
||||||
|
|
||||||
def log_message(self, fmt, *args): # noqa: A003 - stdlib hook
|
|
||||||
LOG.debug("%s - %s", self.address_string(), fmt % args)
|
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
|
||||||
# Prime the cache so the first scrape has data, but never refuse to
|
|
||||||
# start on a database blip.
|
|
||||||
ensure_fresh()
|
|
||||||
server = ThreadingHTTPServer(("0.0.0.0", PORT), Handler)
|
|
||||||
LOG.info("listening on 0.0.0.0:%s (db=%s/%s)", PORT, DB_CONFIG["host"], DB_CONFIG["dbname"])
|
|
||||||
server.serve_forever()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: osint-analyst-exporter
|
|
||||||
namespace: osint
|
|
||||||
labels:
|
|
||||||
app: osint-analyst-exporter
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: osint-analyst-exporter
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: osint-analyst-exporter
|
|
||||||
spec:
|
|
||||||
imagePullSecrets:
|
|
||||||
- name: forgejo-pull
|
|
||||||
# Same placement policy as the other stateless amd64 loops here: prefer
|
|
||||||
# linode (where osint-db runs) but do not strand if it is absent.
|
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/arch: amd64
|
|
||||||
affinity:
|
|
||||||
nodeAffinity:
|
|
||||||
preferredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
- weight: 100
|
|
||||||
preference:
|
|
||||||
matchExpressions:
|
|
||||||
- key: kubernetes.io/hostname
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- linode
|
|
||||||
securityContext:
|
|
||||||
runAsNonRoot: true
|
|
||||||
runAsUser: 1000
|
|
||||||
runAsGroup: 1000
|
|
||||||
seccompProfile:
|
|
||||||
type: RuntimeDefault
|
|
||||||
containers:
|
|
||||||
- name: exporter
|
|
||||||
# Pinned summarizer image: python3 + psycopg2, see header comment.
|
|
||||||
# Kept equal to the summarizer pin in news-summarizer-deployment.yaml.
|
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-fb5285df7f38
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
command: ["python", "/opt/exporter/exporter.py"]
|
|
||||||
env:
|
|
||||||
- name: PYTHONDONTWRITEBYTECODE
|
|
||||||
value: "1"
|
|
||||||
- name: EXPORTER_PORT
|
|
||||||
value: "9187"
|
|
||||||
- name: DB_HOST
|
|
||||||
valueFrom:
|
|
||||||
configMapKeyRef:
|
|
||||||
name: osint-env
|
|
||||||
key: DB_HOST
|
|
||||||
- name: DB_PORT
|
|
||||||
valueFrom:
|
|
||||||
configMapKeyRef:
|
|
||||||
name: osint-env
|
|
||||||
key: DB_PORT
|
|
||||||
- name: DB_NAME
|
|
||||||
valueFrom:
|
|
||||||
configMapKeyRef:
|
|
||||||
name: osint-env
|
|
||||||
key: DB_NAME
|
|
||||||
- name: DB_USER
|
|
||||||
valueFrom:
|
|
||||||
configMapKeyRef:
|
|
||||||
name: osint-env
|
|
||||||
key: DB_USER
|
|
||||||
- name: DB_PASSWORD
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: osint-db
|
|
||||||
key: password
|
|
||||||
ports:
|
|
||||||
- name: metrics
|
|
||||||
containerPort: 9187
|
|
||||||
protocol: TCP
|
|
||||||
readinessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /healthz
|
|
||||||
port: metrics
|
|
||||||
periodSeconds: 10
|
|
||||||
livenessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /healthz
|
|
||||||
port: metrics
|
|
||||||
initialDelaySeconds: 10
|
|
||||||
periodSeconds: 30
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 10m
|
|
||||||
memory: 64Mi
|
|
||||||
limits:
|
|
||||||
cpu: 100m
|
|
||||||
memory: 128Mi
|
|
||||||
securityContext:
|
|
||||||
allowPrivilegeEscalation: false
|
|
||||||
readOnlyRootFilesystem: true
|
|
||||||
capabilities:
|
|
||||||
drop:
|
|
||||||
- ALL
|
|
||||||
volumeMounts:
|
|
||||||
- name: script
|
|
||||||
mountPath: /opt/exporter
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: script
|
|
||||||
configMap:
|
|
||||||
name: osint-analyst-exporter
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: osint-analyst-exporter
|
|
||||||
namespace: osint
|
|
||||||
labels:
|
|
||||||
app: osint-analyst-exporter
|
|
||||||
spec:
|
|
||||||
type: ClusterIP
|
|
||||||
selector:
|
|
||||||
app: osint-analyst-exporter
|
|
||||||
ports:
|
|
||||||
- name: metrics
|
|
||||||
port: 9187
|
|
||||||
targetPort: metrics
|
|
||||||
protocol: TCP
|
|
||||||
---
|
|
||||||
# Prometheus (monitoring ns) scrapes this; the ServiceMonitor selector is
|
|
||||||
# namespace-wide (spec.serviceMonitorNamespaceSelector = {}), so the label is
|
|
||||||
# what matters. Ingress from monitoring to :9187 is opened in networkpolicy.yaml.
|
|
||||||
apiVersion: monitoring.coreos.com/v1
|
|
||||||
kind: ServiceMonitor
|
|
||||||
metadata:
|
|
||||||
name: osint-analyst-exporter
|
|
||||||
namespace: osint
|
|
||||||
labels:
|
|
||||||
release: kube-prometheus-stack
|
|
||||||
spec:
|
|
||||||
namespaceSelector:
|
|
||||||
matchNames:
|
|
||||||
- osint
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: osint-analyst-exporter
|
|
||||||
endpoints:
|
|
||||||
- port: metrics
|
|
||||||
path: /metrics
|
|
||||||
interval: 30s
|
|
||||||
scrapeTimeout: 10s
|
|
||||||
|
|
@ -66,25 +66,14 @@ data:
|
||||||
# never see https here: this flag is what puts `Secure` on the session cookie.
|
# never see https here: this flag is what puts `Secure` on the session cookie.
|
||||||
ADMIN_COOKIE_SECURE: "1"
|
ADMIN_COOKIE_SECURE: "1"
|
||||||
|
|
||||||
# ── news summarizer (analyst) — Nous Portal ─────────────────────────────
|
# ── news summarizer (analyst) — Nous Portal, free tier model ────────────
|
||||||
NOUS_BASE_URL: https://inference-api.nousresearch.com/v1
|
NOUS_BASE_URL: https://inference-api.nousresearch.com/v1
|
||||||
# Meituan LongCat was retired from the portal (every call 404'd from 11/25
|
SUMMARY_MODEL: meituan/longcat-2.5:free
|
||||||
# onward, silently producing no briefs). The :free ids now require a user
|
|
||||||
# tag and 503 anyway; pin the cheapest model that answers normally and
|
|
||||||
# honours response_format: json_object (~$0.03/$0.12 per Mtok).
|
|
||||||
SUMMARY_MODEL: deepseek/deepseek-v4.1-flash-1017
|
|
||||||
# 4, not the upstream default 50: the map phase runs with a hard 60 s httpx
|
# 4, not the upstream default 50: the map phase runs with a hard 60 s httpx
|
||||||
# timeout (news/summerizer/nous_client.py, json_mode=False), so bigger
|
# timeout (news/summerizer/nous_client.py, json_mode=False), and this free
|
||||||
# batches risk timing out and silently contributing nothing to the reduce
|
# model needs ~30 s for 8 articles, so bigger batches time out and silently
|
||||||
# phase.
|
# contribute nothing to the reduce phase.
|
||||||
BATCH_SIZE: "4"
|
BATCH_SIZE: "4"
|
||||||
# Map-phase fan-out (PR #72). Each map call is a ~20 s wall clock, so the
|
|
||||||
# phase is latency-bound, not CPU-bound: the 746-batch recap measured 951 s
|
|
||||||
# end-to-end at 16 in flight, where 8 is projected at ~98 min. 16 is also the
|
|
||||||
# summarizer's DEFAULT_SUMMARY_MAP_CONCURRENCY; it is pinned here so a future
|
|
||||||
# code default change cannot silently stretch the 15-min interval past its
|
|
||||||
# window.
|
|
||||||
SUMMARY_MAP_CONCURRENCY: "16"
|
|
||||||
# Map-phase grading (PR #53): the map call scores every article 0-100 against
|
# Map-phase grading (PR #53): the map call scores every article 0-100 against
|
||||||
# a rubric and only blocks >= SUMMARY_MIN_SCORE reach the brief. When nothing
|
# a rubric and only blocks >= SUMMARY_MIN_SCORE reach the brief. When nothing
|
||||||
# clears the bar the top SUMMARY_FALLBACK_TOP are used so the HUD is not blank
|
# clears the bar the top SUMMARY_FALLBACK_TOP are used so the HUD is not blank
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,6 @@ resources:
|
||||||
- titiler-service.yaml
|
- titiler-service.yaml
|
||||||
- news-scraper-deployment.yaml
|
- news-scraper-deployment.yaml
|
||||||
- news-summarizer-deployment.yaml
|
- news-summarizer-deployment.yaml
|
||||||
# Freshness exporter for the analyst (max(article_summaries.batch_timestamp)
|
|
||||||
# and max(articles.timestamp) -> :9187/metrics) + its ServiceMonitor. The
|
|
||||||
# summarizer has no /metrics and a wedged analyst is invisible otherwise
|
|
||||||
# (card t_22334588).
|
|
||||||
- analyst-exporter.yaml
|
|
||||||
- httproute.yaml
|
- httproute.yaml
|
||||||
# Default-deny ingress+egress + the namespace allow list (audit F3 / t_fed52919).
|
# Default-deny ingress+egress + the namespace allow list (audit F3 / t_fed52919).
|
||||||
- networkpolicy.yaml
|
- networkpolicy.yaml
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,7 @@
|
||||||
# * kube-apiserver egress — no workload here calls the API; the audit's
|
# * kube-apiserver egress — no workload here calls the API; the audit's
|
||||||
# `SA token mounted` observation is a separate finding and denying the path
|
# `SA token mounted` observation is a separate finding and denying the path
|
||||||
# does not depend on removing the token.
|
# does not depend on removing the token.
|
||||||
# * monitoring ingress — apart from the one port-scoped rule for the analyst
|
# * monitoring ingress — no PodMonitor/ServiceMonitor selects osint pods.
|
||||||
# freshness exporter below (Prometheus -> osint-analyst-exporter:9187),
|
|
||||||
# nothing in `monitoring` reaches this namespace.
|
|
||||||
apiVersion: networking.k8s.io/v1
|
apiVersion: networking.k8s.io/v1
|
||||||
kind: NetworkPolicy
|
kind: NetworkPolicy
|
||||||
metadata:
|
metadata:
|
||||||
|
|
@ -58,16 +56,6 @@ spec:
|
||||||
- fromEndpoints:
|
- fromEndpoints:
|
||||||
- matchLabels:
|
- matchLabels:
|
||||||
io.kubernetes.pod.namespace: osint
|
io.kubernetes.pod.namespace: osint
|
||||||
# Prometheus (namespace `monitoring`) scrapes the analyst freshness exporter
|
|
||||||
# on 9187 (apps/base/osint/analyst-exporter.yaml). Port-scoped: no other
|
|
||||||
# monitoring -> osint traffic is opened.
|
|
||||||
- fromEndpoints:
|
|
||||||
- matchLabels:
|
|
||||||
io.kubernetes.pod.namespace: monitoring
|
|
||||||
toPorts:
|
|
||||||
- ports:
|
|
||||||
- port: "9187"
|
|
||||||
protocol: TCP
|
|
||||||
egress:
|
egress:
|
||||||
- toEndpoints:
|
- toEndpoints:
|
||||||
- matchLabels:
|
- matchLabels:
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,7 @@ spec:
|
||||||
kubernetes.io/arch: amd64
|
kubernetes.io/arch: amd64
|
||||||
containers:
|
containers:
|
||||||
- name: news-summarizer
|
- name: news-summarizer
|
||||||
# amd64-fb5285df7f38 = sirius/osint-dashboard@fb5285d (PR #72, merged):
|
image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-fe2b5df369d0
|
||||||
# the map phase runs concurrently (SUMMARY_MAP_CONCURRENCY) and a
|
|
||||||
# non-retryable Nous rejection raises NousAPIError instead of being
|
|
||||||
# swallowed, so a wedged analyst fails loudly instead of idling for
|
|
||||||
# nine days on silent empty completions (card t_22334588 / t_2ae9f0c0).
|
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-fb5285df7f38
|
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
# Loop: batch the last window, call Nous Portal, write summaries.
|
# Loop: batch the last window, call Nous Portal, write summaries.
|
||||||
command: ["python", "run_news_summarizer.py"]
|
command: ["python", "run_news_summarizer.py"]
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,6 @@ resources:
|
||||||
- httproute.yaml
|
- httproute.yaml
|
||||||
# Default-deny ingress+egress + the namespace allow list (audit F3 / t_fed52919).
|
# Default-deny ingress+egress + the namespace allow list (audit F3 / t_fed52919).
|
||||||
- networkpolicy.yaml
|
- networkpolicy.yaml
|
||||||
# Egress lockdown for the leadgen-backup pod: DNS + 10.10.0.5:22 only. The
|
|
||||||
# allow list above cannot be narrowed per pod, so the deny for `world` in
|
|
||||||
# this policy is what applies to the job (card t_9d0428d8).
|
|
||||||
- networkpolicy-backup.yaml
|
|
||||||
# The WAL archive store must exist before the Cluster references it.
|
# The WAL archive store must exist before the Cluster references it.
|
||||||
- objectstore-portal-wal.yaml
|
- objectstore-portal-wal.yaml
|
||||||
- cluster.yaml
|
- cluster.yaml
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@ data:
|
||||||
# Snapshot mirror of /src -> $BACKUP_DIR/leadgen-data/<stamp>/ + `latest`.
|
# Snapshot mirror of /src -> $BACKUP_DIR/leadgen-data/<stamp>/ + `latest`.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# No package install here on purpose: rsync/openssh-client/bash are baked
|
if ! command -v rsync >/dev/null || ! command -v ssh >/dev/null; then
|
||||||
# into the pinned image (images/backup/Dockerfile) and this pod's egress
|
echo "== installing rsync + openssh-client"
|
||||||
# policy admits DNS + 10.10.0.5:22 only, so a runtime fetch would fail
|
apk add --no-cache rsync openssh-client >/dev/null
|
||||||
# rather than silently dial the Alpine CDN (card t_9d0428d8).
|
fi
|
||||||
|
|
||||||
BACKUP_HOST=${BACKUP_HOST:[email protected]}
|
BACKUP_HOST=${BACKUP_HOST:[email protected]}
|
||||||
BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup}
|
BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup}
|
||||||
|
|
@ -102,18 +102,12 @@ spec:
|
||||||
app: leadgen-backup
|
app: leadgen-backup
|
||||||
spec:
|
spec:
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
# Pulled from the in-cluster Forgejo registry (which requires auth).
|
|
||||||
imagePullSecrets:
|
|
||||||
- name: forgejo-pull
|
|
||||||
# The PVC is local-path on siriussec.
|
# The PVC is local-path on siriussec.
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/hostname: siriussec
|
||||||
containers:
|
containers:
|
||||||
- name: backup
|
- name: backup
|
||||||
# rsync + openssh-client + bash baked at build time, pinned by
|
image: alpine/k8s:1.36.4
|
||||||
# digest (images/backup/Dockerfile). Nothing is installed at run
|
|
||||||
# time.
|
|
||||||
image: forgejo.siriusdevops.com/sirius/backup-tools@sha256:cc8dc1645111b3a80b7c4d5168f6bce3002cae7417b3725683c057976f6e379a
|
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
command: ["/bin/bash", "/scripts/backup.sh"]
|
command: ["/bin/bash", "/scripts/backup.sh"]
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
# Egress lockdown for the nightly leadgen-backup CronJob (card t_9d0428d8).
|
|
||||||
#
|
|
||||||
# Why: the job used to `apk add --no-cache rsync openssh-client` at container
|
|
||||||
# start, so each run depended on the Alpine CDN (Fastly 151.101.x.132:443).
|
|
||||||
# rsync/ssh/bash (+kubectl, unused here) are baked into
|
|
||||||
# images/backup/Dockerfile now.
|
|
||||||
#
|
|
||||||
# `sirius-growth-allow` (networkpolicy.yaml) selects every pod in this
|
|
||||||
# namespace and allows `world` (Telegram Bot API, the leadgen crawlers), so a
|
|
||||||
# pod-scoped allow list alone would NOT restrict this job — Cilium unions
|
|
||||||
# policies. The `egressDeny` for `world` closes it for this pod only; the app
|
|
||||||
# pods keep their internet access.
|
|
||||||
#
|
|
||||||
# Allow list, and nothing else: cluster DNS, and [email protected]:22 (the Linode
|
|
||||||
# node's InternalIP — `remote-node`, not `world`) for the rsync mirror.
|
|
||||||
apiVersion: cilium.io/v2
|
|
||||||
kind: CiliumNetworkPolicy
|
|
||||||
metadata:
|
|
||||||
name: leadgen-backup-egress
|
|
||||||
namespace: sirius-growth
|
|
||||||
labels:
|
|
||||||
app: leadgen-backup
|
|
||||||
spec:
|
|
||||||
description: >-
|
|
||||||
leadgen-backup pod: cluster DNS + SSH to the backup host (10.10.0.5:22)
|
|
||||||
only; no internet egress at run time.
|
|
||||||
endpointSelector:
|
|
||||||
matchLabels:
|
|
||||||
app: leadgen-backup
|
|
||||||
egress:
|
|
||||||
- toEndpoints:
|
|
||||||
- matchLabels:
|
|
||||||
io.kubernetes.pod.namespace: kube-system
|
|
||||||
k8s-app: kube-dns
|
|
||||||
toPorts:
|
|
||||||
- ports:
|
|
||||||
- port: "53"
|
|
||||||
protocol: UDP
|
|
||||||
- port: "53"
|
|
||||||
protocol: TCP
|
|
||||||
- toEntities:
|
|
||||||
- remote-node
|
|
||||||
toPorts:
|
|
||||||
- ports:
|
|
||||||
- port: "22"
|
|
||||||
protocol: TCP
|
|
||||||
egressDeny:
|
|
||||||
- toEntities:
|
|
||||||
- world
|
|
||||||
|
|
@ -6,11 +6,8 @@
|
||||||
# ingress: Cilium Gateway proxy (`reserved:ingress`) for
|
# ingress: Cilium Gateway proxy (`reserved:ingress`) for
|
||||||
# siriusgrowthsolutions.com -> site:80 / contact:8090 /
|
# siriusgrowthsolutions.com -> site:80 / contact:8090 /
|
||||||
# portal-gate:8080 / portal:8091 / blog:8092, node entities for
|
# portal-gate:8080 / portal:8091 / blog:8092, node entities for
|
||||||
# kubelet probes, Prometheus in `monitoring` on 9187 only (the
|
# kubelet probes, and Prometheus in `monitoring` on 9187 only (the
|
||||||
# `cnpg-portal` PodMonitor scrapes the CNPG instance manager), and
|
# `cnpg-portal` PodMonitor scrapes the CNPG instance manager).
|
||||||
# the CNPG operator in `cnpg-system` on 8000 only — the instance
|
|
||||||
# manager's HTTPS status endpoint the operator reads to derive the
|
|
||||||
# system ID and drive failover (card t_4210edec).
|
|
||||||
# egress: cluster DNS; its own pods (blog/portal -> portal-1:5432,
|
# egress: cluster DNS; its own pods (blog/portal -> portal-1:5432,
|
||||||
# portal-gate -> portal:8091); `world` for the Telegram Bot API
|
# portal-gate -> portal:8091); `world` for the Telegram Bot API
|
||||||
# (contact + portal) and the leadgen crawlers; the node IPs on 3900
|
# (contact + portal) and the leadgen crawlers; the node IPs on 3900
|
||||||
|
|
@ -56,19 +53,6 @@ spec:
|
||||||
- fromEndpoints:
|
- fromEndpoints:
|
||||||
- matchLabels:
|
- matchLabels:
|
||||||
io.kubernetes.pod.namespace: sirius-growth
|
io.kubernetes.pod.namespace: sirius-growth
|
||||||
# The CNPG operator (`cnpg-system`) reads the instance manager's HTTPS
|
|
||||||
# status endpoint to derive the system ID and drive switchover/promotion.
|
|
||||||
# Without it the Cluster reports `Instance Status Extraction Error` and
|
|
||||||
# Ready=False while the pods serve traffic, and automated failover is dead
|
|
||||||
# (card t_4210edec). Scoped to 8000: not 5432, not the whole namespace.
|
|
||||||
- fromEndpoints:
|
|
||||||
- matchLabels:
|
|
||||||
io.kubernetes.pod.namespace: cnpg-system
|
|
||||||
app.kubernetes.io/name: cloudnative-pg
|
|
||||||
toPorts:
|
|
||||||
- ports:
|
|
||||||
- port: "8000"
|
|
||||||
protocol: TCP
|
|
||||||
# Prometheus scrapes the CNPG `portal` instance manager on 9187.
|
# Prometheus scrapes the CNPG `portal` instance manager on 9187.
|
||||||
- fromEndpoints:
|
- fromEndpoints:
|
||||||
- matchLabels:
|
- matchLabels:
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ spec:
|
||||||
memory: 128Mi
|
memory: 128Mi
|
||||||
containers:
|
containers:
|
||||||
- name: nginx
|
- name: nginx
|
||||||
image: forgejo.siriusdevops.com/sirius/siriusdevops-site:3ac9870aa7637cffb789edcc16b9512d7567886d
|
image: forgejo.siriusdevops.com/sirius/siriusdevops-site:399c421f51a2fd74a87e810641226d58e4e22690
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
|
|
|
||||||
302
docs/pod-to-pod-encryption-decision.md
Normal file
302
docs/pod-to-pod-encryption-decision.md
Normal file
|
|
@ -0,0 +1,302 @@
|
||||||
|
# Pod-to-pod encryption: WireGuard vs mutual auth (measured)
|
||||||
|
|
||||||
|
Decision record for the question "how does pod-to-pod traffic get encrypted, and should we
|
||||||
|
turn it on?" Written 2026-12-03 as a spike: **no cluster changes were made**, and every
|
||||||
|
number below came from a read-only probe or a throwaway pod that was deleted afterwards.
|
||||||
|
|
||||||
|
Cluster at time of writing: Cilium **1.20.1** (`quay.io/cilium/cilium:v1.20.1@sha256:ae9ea21…`),
|
||||||
|
`cilium-dbg status` → `Encryption: Disabled`, `Routing: Network: Native / Host: Legacy`,
|
||||||
|
`MTU updated (1420)`. Nodes: `siriussec` (amd64, 8 threads, control-plane+gateway+worker),
|
||||||
|
`rpi` (arm64, 4 cores, hub), `linode` (amd64, 2 cores). 67 running pods: **51 on
|
||||||
|
siriussec**, 6 on rpi, 10 on linode.
|
||||||
|
|
||||||
|
## Verdict
|
||||||
|
|
||||||
|
**No-go on Cilium WireGuard _as a fix for the exposure that motivated this card_.**
|
||||||
|
Cilium's WireGuard mode does not encrypt traffic between two pods on the same node — by
|
||||||
|
design, documented, and the reason is sound (the node can read it anyway). 76% of running
|
||||||
|
pods are on `siriussec`, so the dominant pod-to-pod path in this cluster is exactly the
|
||||||
|
path Cilium WG leaves in cleartext. Enabling it would add a second crypto layer, drop pod
|
||||||
|
MTU to 1325, and buy a guarantee the cluster already has for the one path it does cover
|
||||||
|
(cross-node traffic is already WG-encrypted by `wg0`, measured below).
|
||||||
|
|
||||||
|
**No-go on Cilium mutual auth (SPIFFE/mTLS).** In the installed chart version the feature is
|
||||||
|
**deprecated as of v1.20 with removal planned for v1.21** (helm values comment +
|
||||||
|
cilium/cilium#47132), it is Beta, it needs a SPIRE deployment that does not exist here, and
|
||||||
|
it authenticates connections — it does not encrypt them without WireGuard or IPsec beneath.
|
||||||
|
|
||||||
|
**Conditional go** on `encryption.type=wireguard` if a *compliance* requirement appears that
|
||||||
|
says "pod traffic between hosts must be encrypted by the CNI" (today it is encrypted by the
|
||||||
|
host tunnel instead). The staged plan in §6 is what that would cost; §4 says the throughput
|
||||||
|
cost is ~7% and the CPU cost is affordable; §5 says the rollback is a one-commit revert plus
|
||||||
|
a DaemonSet rollout.
|
||||||
|
|
||||||
|
The single biggest risk of enabling it is **not** the encryption: it is a false sense of
|
||||||
|
security (same-node traffic is still readable at the node, and host-network/ingress traffic
|
||||||
|
stays unencrypted unless the *beta* `nodeEncryption` is also enabled) plus the 95-byte MTU
|
||||||
|
drop silently fragmenting anything that hardcodes 1500/1420 (the amd64 CI runner's dind
|
||||||
|
bridge is hardcoded at 1420 today — §5).
|
||||||
|
|
||||||
|
## 1. Current exposure, measured
|
||||||
|
|
||||||
|
Four probes, each from a vantage that matters. Test pods (`nicolaka/netshoot:v0.13`) were
|
||||||
|
created in a throwaway `encspike` namespace — two on `siriussec`, one each on `rpi`/`linode`
|
||||||
|
— and the namespace was deleted at the end (`kubectl get pods -A | grep -c iperf` = 0).
|
||||||
|
|
||||||
|
| # | Path | Vantage | Command | Result |
|
||||||
|
|---|------|---------|---------|--------|
|
||||||
|
| 1 | same-node pod→pod | receiver pod's veth on the node | `sudo tcpdump -n -A -i lxc<peer> 'tcp port 9000'` while `curl http://10.244.0.45:9000/secret.txt` | **Plaintext**: `GET /secret.txt HTTP/1.1`, `Host:`, `User-Agent:`, `HTTP/1.0 200 OK`, body marker readable |
|
||||||
|
| 2 | cross-node pod→pod | LAN wire | `sudo tcpdump -n -A -i enp0s31f6 'udp port 51820'` during the same curl to a pod on rpi | **Opaque**: only `UDP, length 1452` WG datagrams; `grep -c SPIKE` = 0, `grep -c "GET "` = 0 |
|
||||||
|
| 3 | cross-node pod→pod | node, after decapsulation | `sudo tcpdump -n -A -i wg0 'host 10.244.1.182 and tcp'` | **Plaintext again**: `GET /secret.txt HTTP/1.1`, `HTTP/1.0 200 OK` |
|
||||||
|
| 4 | pod→API | node loopback | `sudo tcpdump -n -i lo 'tcp port 6443'` while `curl -k https://10.10.0.2:6443/version` | Cilium BPF rewrites it to `127.0.0.1:<port> → 127.0.0.1:6443`; TLS content, L4 metadata visible |
|
||||||
|
| 5 | unrelated pod sniffing another pair | inside a pod with NET_RAW | `tcpdump -i eth0 -c 5 'tcp port 5201'` during `srv-siriussec → srv-linode` iperf3 (632 Mbit/s) | **0 packets captured** — pods have no L2 adjacency (`ip neigh` shows only `cilium_host`), so an unprivileged pod cannot sniff its neighbours |
|
||||||
|
|
||||||
|
What this means, precisely:
|
||||||
|
|
||||||
|
* **Same-node pod↔pod is plaintext and is readable by anything in the host network
|
||||||
|
namespace** — every host process, and therefore any pod with `hostNetwork: true` or
|
||||||
|
`privileged: true`. It is *not* sniffable by another ordinary pod (probe 5).
|
||||||
|
* **Cross-node pod↔pod is encrypted on the wire today** (probe 2) by the host `wg0`, but
|
||||||
|
decrypted at the destination node (probe 3), so the node vantage still reads it.
|
||||||
|
* **Pod→API never leaves the node** and is TLS-protected by Kubernetes itself; CNI
|
||||||
|
encryption would add nothing to its content and would not even see it (same-node).
|
||||||
|
* **Traffic to node addresses is not CNI-encryptable by default**: registry (`10.10.0.1:5000`),
|
||||||
|
Garage S3 (`10.10.0.1:3900`), kubelet, and the host-network Envoy ingress path
|
||||||
|
(`node → pod`) are not covered by `encryption.type=wireguard` unless the beta
|
||||||
|
`encryption.nodeEncryption`/`--encrypt-node` is enabled. Cilium's own coverage table
|
||||||
|
(docs, v1.20 "Which traffic is encrypted") says exactly this: `Pod→remote Pod` = default
|
||||||
|
mode; `Pod→remote Node`, `Node→remote Pod`, `Node→remote Node`, and
|
||||||
|
`Client outside cluster→pod via Service` under native routing = **node-to-node mode only**.
|
||||||
|
|
||||||
|
So the unencrypted set is: same-node pod↔pod (51/67 pods), host↔pod, pod↔node-address,
|
||||||
|
and anything with a compromised host netns. The card's premise ("two pods on siriussec
|
||||||
|
speak plaintext across the bridge") is confirmed — with the correction that there is no
|
||||||
|
bridge: pods are `/32` on `lxc*` veths and are routed through `cilium_host` (probe 1's
|
||||||
|
capture shows the veth, not a bridge).
|
||||||
|
|
||||||
|
## 2. WireGuard mode vs mutual authentication — capability of the _installed_ build
|
||||||
|
|
||||||
|
Read from the running agent and the shipped chart, not from blog posts:
|
||||||
|
|
||||||
|
```
|
||||||
|
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg status | grep -E 'Encryption|Cilium:|Routing'
|
||||||
|
Cilium: Ok 1.20.1 (v1.20.1-7d68cfb3)
|
||||||
|
Routing: Network: Native Host: Legacy
|
||||||
|
Encryption: Disabled
|
||||||
|
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-agent --help | grep -E 'enable-wireguard|encrypt-node|mesh-auth'
|
||||||
|
--enable-wireguard Enable WireGuard
|
||||||
|
--encrypt-node Enables encrypting traffic from non-Cilium pods and host networking (only supported with WireGuard, beta)
|
||||||
|
--mesh-auth-mutual-listener-port int Port on which the Cilium Agent will perform mutual authentication handshakes between other Agents
|
||||||
|
kubectl get ciliumnodes -o json | jq '.items[] | {name:.metadata.name, wg:.metadata.annotations["network.cilium.io/wg-pub-key"], enc:.spec.encryption}'
|
||||||
|
linode wg-pub-key: null encryption: {}
|
||||||
|
rpi wg-pub-key: null encryption: {}
|
||||||
|
siriussec wg-pub-key: null encryption: {}
|
||||||
|
ip link show cilium_wg0 # on siriussec
|
||||||
|
Device "cilium_wg0" does not exist.
|
||||||
|
```
|
||||||
|
|
||||||
|
Support status in **v1.20.1**, from the pinned docs and chart of that version:
|
||||||
|
|
||||||
|
| Mode | Status here | Evidence |
|
||||||
|
|------|-------------|----------|
|
||||||
|
| `encryption.type=wireguard` | GA/stable (`encryption.enabled` + `type` are ordinary chart values; only `nodeEncryption` and `encryption.strictMode.*` are marked beta) | `install/kubernetes/cilium/values.yaml` @ v1.20.1; agent flag `--enable-wireguard`; docs page "WireGuard Transparent Encryption" carries no beta banner |
|
||||||
|
| `encryption.nodeEncryption` / `--encrypt-node` | **beta** | agent `--help` text; docs section "Node-to-Node Encryption (beta)" |
|
||||||
|
| Mutual auth (`authentication.mutual.spire`) | **beta + deprecated**; removal planned v1.21 | chart comment: "Deprecated as of Cilium v1.20, this feature will be removed in Cilium v1.21"; cilium/cilium#47132 (open, 2026-07-13); no `cilium-spire` namespace or SPIRE pods in this cluster |
|
||||||
|
| CNP `authentication.mode: required` | CRD field exists (`authentication` present in `ciliumnetworkpolicies.cilium.io` schema, mode enum includes `required`), but policy enforcement is only meaningful with `authentication.enabled`/SPIRE; 6 CNPs exist today, none use it | `kubectl get crd ciliumnetworkpolicies.cilium.io -o json`; `kubectl get cnp -A` |
|
||||||
|
| `encryption.type=ztunnel` (Istio ztunnel, the mTLS-shaped option) | **beta**, new in 1.20, CA `internal` or `spire`, own DaemonSet + 200m/512Mi per node | chart `encryption.ztunnel` block; agent flag `--enable-ztunnel` |
|
||||||
|
|
||||||
|
Comparison on the axes that decide this:
|
||||||
|
|
||||||
|
| Axis | Cilium WG | Mutual auth (SPIFFE/SPIRE) | ztunnel |
|
||||||
|
|------|-----------|----------------------------|---------|
|
||||||
|
| What it closes | Reads of cross-node pod traffic **on the wire** (already closed by `wg0`). **Not** same-node, not host↔pod, not pod↔node unless `nodeEncryption` (beta). | *Authentication* of L4 connections by source identity, per CNP rule; encryption only as a side effect of WG/IPsec underneath | mTLS between pods via per-node proxy, identity from SPIFFE |
|
||||||
|
| Key distribution | Per-node keypair generated by the agent, written to its state dir (`cilium_wg0.key`), published in the `network.cilium.io/wg-pub-key` annotation on `CiliumNode`; peers read it from the API | SPIRE server issues SVIDs; SPIRE stack must be deployed and maintained | CA (`internal` or SPIRE) issues workload certs |
|
||||||
|
| Rotation | No operator-facing interval; a new keypair is generated when the agent's key file is missing (node reboot / state loss) and every peer re-reads the annotation. **No PSK, no post-quantum**: Rosenpass covers `wg0` only, `cilium_wg0` is a separate classical-X25519 tunnel — the PQ work from t_fb8bc782 does **not** extend to it | SVID rotation by SPIRE (short TTLs) | cert rotation by CA |
|
||||||
|
| CPU | Measured §3: 2nd layer ≈ +0 CPU observably at 1 GbE; the T480 carries ~1.4 cores for 1 Gbit/s of double-sided crypto in the same kernel | + handshake/agent per connection; SPIRE server + agent pods | + proxy hop per connection (200m/512Mi per node before any traffic) |
|
||||||
|
| MTU | pod MTU 1420 → **1325** (`WireguardOverhead = 95` in `pkg/mtu/mtu.go` @ v1.20.1); measured 60-byte IPv4 per-packet cost and the 95-byte worst case | inherits WG/IPsec MTU | proxy MTU accounting, plus 1 extra user-space hop |
|
||||||
|
| Debugging | `cilium-dbg status`, `cilium-dbg debuginfo \| jq .encryption`, `tcpdump -i cilium_wg0`; a LAN capture now shows only UDP/51871 so "is the app broken or the tunnel" costs a hop | failed auth is a policy verdict (Hubble shows it) — a different, noisier failure surface | ztunnel logs/metrics, new component to learn |
|
||||||
|
| Failure modes | Documented known issue: packets can be dropped while the WG device is reconfigured on endpoint add/remove → connection resets during pod churn; MTU mis-sizing fragments (measured, §3); a node whose key is stale/unpublished silently falls back to **plaintext** | SPIRE outage breaks new connections cluster-wide; policy mistakes deny traffic rather than encrypt it | beta maturity, single proxy per node is a new SPOF |
|
||||||
|
| Node reboot | keypair regenerated, republished; peers converge when annotations propagate — a window of plaintext/unreachable per node | SVID re-attestation per node; SPIRE datastore is the recovery dependency | cert re-issue |
|
||||||
|
|
||||||
|
## 3. The nesting problem — measured
|
||||||
|
|
||||||
|
Node transport is already WireGuard (`wg0`, MTU 1420). Cilium's `cilium_wg0` would ride
|
||||||
|
inside it on every cross-node path, so each pod packet is encrypted twice.
|
||||||
|
|
||||||
|
All runs: `iperf3 -t 10 -O 2`, MTU 1420 pod path, `siriussec` → `rpi` (1 LAN hop) unless noted.
|
||||||
|
|
||||||
|
| Run | Shape | P1 | P4 | Notes |
|
||||||
|
|-----|-------|----|----|-------|
|
||||||
|
| T1 | same-node pod→pod (baseline, no tunnel) | 16.2 Gb/s | 40.3 Gb/s | loopback; 1 GbE is not involved |
|
||||||
|
| T2 | cross-node, host `wg0` only (current production) | 895 Mb/s | 896 Mb/s | link-bound (1 GbE); T480 CPU 17%→25% peak, Pi 1% avg / 5% peak |
|
||||||
|
| T3 | cross-node 2 host hops (`siriussec`→Pi→`linode`) | 787 Mb/s | 743 Mb/s | Pi forwards (decrypt+encrypt) and still sits at ~1–5% |
|
||||||
|
| T4 | **nested**: pod-WG device MTU 1420 over the 1420 path | 536 Mb/s | 525 Mb/s | every outer packet fragmented (`flags [+]`, first fragment 1420 B of a 1480 B datagram); no P-scaling |
|
||||||
|
| T5 | one pod-WG layer, same node, MTU 1360 (correctly sized) | 1.06 Gb/s | 1.04 Gb/s | double-sided crypto in one kernel — not the production shape |
|
||||||
|
| T6 | **nested**: pod-WG MTU 1360 over host `wg0`, cross-node (production shape) | **809 Mb/s** | **831 Mb/s** | 7–9% below T2; both layers' counters incremented; Pi 1% avg / 5% peak |
|
||||||
|
|
||||||
|
Commands (T6; the rest are the same shape):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# in the server pod: create a WG device and serve on it
|
||||||
|
ip link add wgout type wireguard
|
||||||
|
ip addr add 10.98.0.1/24 dev wgout
|
||||||
|
wg set wgout listen-port 51999 private-key /tmp/wg/priv \
|
||||||
|
peer <client-pub> allowed-ips 10.98.0.2/32 endpoint 10.244.0.134:51999 persistent-keepalive 5
|
||||||
|
ip link set mtu 1360 up dev wgout
|
||||||
|
iperf3 -s -B 10.98.0.1 -p 5202
|
||||||
|
|
||||||
|
# in the client pod: peer it to the pod on rpi, so its outer packets ride host wg0
|
||||||
|
wg set wgout peer <rpi-pod-pub> allowed-ips 10.98.0.1/32 endpoint 10.244.1.182:51999
|
||||||
|
iperf3 -c 10.98.0.1 -p 5202 -t 10 -O 2 -P1
|
||||||
|
|
||||||
|
# CPU: 1 s /proc/stat sampler on both nodes while it runs
|
||||||
|
ssh siriussec 'bash /tmp/cpusamp2.sh 24' # per-core util, prints agg%/maxcore%
|
||||||
|
```
|
||||||
|
|
||||||
|
Reading: the second layer costs ~7% throughput at 1 GbE — the link is the ceiling, not the
|
||||||
|
crypto — but it doubles the crypto work on the two endpoint nodes and the Pi stays cheap
|
||||||
|
because it only carries one layer. Nothing here argues against WG on performance grounds.
|
||||||
|
The fragmentation row (T4) is the cautionary one: an inner device at 1420 on a 1420 path
|
||||||
|
does not fail loudly, it halves throughput.
|
||||||
|
|
||||||
|
## 4. MTU fallout
|
||||||
|
|
||||||
|
* Today: **pod MTU 1420**, because Cilium derives it from the route MTU of `wg0`
|
||||||
|
(`cilium-dbg status --verbose` → `job-mtu-updater [OK] MTU updated (1420)`; verified in
|
||||||
|
three pods with `cat /sys/class/net/eth0/mtu`).
|
||||||
|
* With `encryption.type=wireguard`, v1.20.1 subtracts `WireguardOverhead = 95`
|
||||||
|
(`pkg/mtu/mtu.go`), and the agent sets `cilium_wg0` MTU to `deviceMTU - 95`
|
||||||
|
(`pkg/wireguard/agent/agent.go`). So **pod MTU becomes 1325 and max inner payload 1297**.
|
||||||
|
Measured check of the arithmetic: one tunnel layer at MTU 1360 accepted `ping -M do -s 1332`
|
||||||
|
and dropped `-s 1333` (60 B WG + 28 B ICMP); the outer datagram for a 1392-byte payload was
|
||||||
|
1452 B of UDP (1480 B on the wire) and arrived fragmented.
|
||||||
|
* Workloads that must be checked after such a change (all currently at 1420 or 1500):
|
||||||
|
|
||||||
|
| Workload | Why | Check |
|
||||||
|
|----------|-----|-------|
|
||||||
|
| `ci-runners/forgejo-runner-amd64` (dind) | `dockerd --mtu=1420` is hardcoded in the Deployment args; containers inside dind would be 95 B over the pod path | set dind MTU to the new pod MTU (1325) and re-run an android/rust job; `docker network inspect` MTU |
|
||||||
|
| Forgejo CI → registry `10.10.0.1:5000` | node address, **not** encrypted by WG without `nodeEncryption`; unchanged MTU either way, but a "pod traffic is encrypted now" assumption is wrong here | `curl -I http://10.10.0.1:5000/v2/` inside a pod |
|
||||||
|
| CNPG `pg` (forgejo, metabase, customer1) | single instance each, all on siriussec → same-node, unaffected; replication (if a replica is ever added) would be cross-node | `psql -c 'show max_wal_senders'`; `kubectl cnpg status` after |
|
||||||
|
| Cilium native routing (`autoDirectNodeRoutes`) | the MTU updater will rewrite existing endpoint MTUs, but established TCP sessions keep their old MSS | restart/reconnect workloads; `ss -ti` on a pod |
|
||||||
|
| coredns (on siriussec, used by pods on rpi/linode) | DNS is cross-node → newly encrypted; small packets, low risk | `dig @10.96.0.10 kubernetes.default` from a pod on rpi |
|
||||||
|
| host-network Envoy gateway | `node → pod` ingress is **not** encrypted without the beta `nodeEncryption`; MTU unchanged | `curl -H 'Host: <site>' http://10.10.0.2:8080/` after |
|
||||||
|
| Loki/Alloy, Prometheus scraping | same-node, unaffected | `kubectl -n logging logs ds/alloy --tail=20` |
|
||||||
|
| osint pipeline (nats, titiler, app) | same-node; only its S3/Garage (`10.10.0.1:3900`) and outbound egress are node/LAN paths | check ingest watermark after |
|
||||||
|
|
||||||
|
## 5. Rollback (and why it is cheap)
|
||||||
|
|
||||||
|
Cilium is a Flux `HelmRelease` (`kube-system/cilium`, chart 1.20.1, values rendered from
|
||||||
|
`infrastructure/networking/cilium/values.yaml` into ConfigMap `cilium-values-66dk8gtmt9`).
|
||||||
|
Rollback is a git revert, not a CLI dance:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. revert the value in git (encryption.enabled: false / drop encryption.type)
|
||||||
|
git revert --no-edit <enable-commit> && git push forgejo master
|
||||||
|
# 2. make Flux act now instead of waiting for the poll
|
||||||
|
kubectl -n flux-system annotate gitrepository flux-system reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite
|
||||||
|
kubectl -n flux-system annotate kustomization infrastructure reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite
|
||||||
|
# 3. watch the agents roll and confirm the device is gone
|
||||||
|
kubectl -n kube-system rollout status ds/cilium --timeout=10m
|
||||||
|
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg status | grep Encryption # -> Disabled
|
||||||
|
ip link show cilium_wg0 # -> does not exist
|
||||||
|
```
|
||||||
|
|
||||||
|
Stop-the-bleeding while git lags (Flux `force: false` for `infrastructure`, so a live patch
|
||||||
|
survives until the next revision — close the drift afterwards):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl -n flux-system patch kustomization infrastructure --type merge -p '{"spec":{"suspend":true}}'
|
||||||
|
kubectl -n kube-system patch cm cilium-config --type merge -p '{"data":{"enable-wireguard":"false"}}'
|
||||||
|
kubectl -n kube-system rollout restart ds/cilium
|
||||||
|
# then revert the commit in git and resume the Kustomization
|
||||||
|
```
|
||||||
|
|
||||||
|
Recovery time: one agent restart per node is ~10–30 s; the whole DaemonSet is expected to
|
||||||
|
settle in **1–3 minutes**, after which pod networking is plaintext `wg0`-only again (the
|
||||||
|
state we are in today, which is known-good). **Not measured** — measuring it needs the
|
||||||
|
rollout, which this spike did not perform.
|
||||||
|
|
||||||
|
**Per-node staged enable: no at the config level, yes in effect.** All agents read one
|
||||||
|
ConfigMap/DS arg, so the switch is cluster-wide; but WireGuard is *opportunistic per peer* —
|
||||||
|
a node that has not restarted has no `wg-pub-key` annotation, so traffic to it stays
|
||||||
|
plaintext instead of breaking. That makes a chunked DaemonSet rollout (`maxUnavailable`) a
|
||||||
|
safe staged enable: no mixed-mode outage, only a temporary mixed-encryption window. That is
|
||||||
|
the behaviour the docs imply and the design of `UpdatePeer`; it is **not** verified here.
|
||||||
|
|
||||||
|
## 6. Staged rollout plan (if the compliance case appears)
|
||||||
|
|
||||||
|
Pre-checks, in this order, all currently failing/pending:
|
||||||
|
|
||||||
|
1. **Firewall: UDP 51871 is closed.** Pi ufw default-deny with per-port allows only
|
||||||
|
(`ufw status verbose` → `Default: deny (incoming)`; 36 ALLOW rules, none for 51871), same
|
||||||
|
on `linode`. Nothing is bound on 51871 anywhere yet (`ss -lnu | grep 51871` → 0).
|
||||||
|
Required: `ufw allow from 10.10.0.0/24 to any port 51871 proto udp` on rpi and linode
|
||||||
|
(Cilium peers over node InternalIPs, i.e. the mesh), and the same source class on
|
||||||
|
siriussec if its nft table grows a default-deny policy.
|
||||||
|
2. **MTU decision first, not after**: set the dind runner's `dockerd --mtu` to 1325 in the
|
||||||
|
same commit, or its builds will fragment.
|
||||||
|
3. Pin Cilium version in the HelmRelease (already pinned at 1.20.1) and record
|
||||||
|
`cilium-dbg status` as the before-state.
|
||||||
|
4. Enable `encryption.enabled: true` + `encryption.type: wireguard` in
|
||||||
|
`infrastructure/networking/cilium/values.yaml`; **do not** enable `nodeEncryption` in the
|
||||||
|
first pass (beta, and it changes the ingress path).
|
||||||
|
5. Push, annotate `gitrepository` + `kustomization infrastructure`, watch
|
||||||
|
`kubectl -n kube-system rollout status ds/cilium` node by node; after each node verify:
|
||||||
|
`cilium-dbg status | grep Encryption` → `Wireguard [cilium_wg0 … Peers: 2]`,
|
||||||
|
`cilium-dbg debuginfo | jq .encryption`, `ip -d link show cilium_wg0` (MTU 1325),
|
||||||
|
pod `eth0` MTU 1325, `ping -M do -s 1297` OK / `-s 1298` FAIL, and a cross-node
|
||||||
|
`iperf3` ≥ 800 Mb/s.
|
||||||
|
6. Regression matrix: every public hostname (`curl -H 'Host: …' http://10.10.0.2:8080/`),
|
||||||
|
Grafana :8081 / Hubble :8084 / Metabase :8085 / customer1 :8086,:8087 by bare IP, a
|
||||||
|
registry pull into a test pod, one Forgejo CI job, `kubectl get nodes` Ready, coredns from
|
||||||
|
a pod on rpi.
|
||||||
|
7. Keep the rollback commit ready (§5) and expect it, because the *documented* known issue is
|
||||||
|
packet loss while the WG device is reconfigured on endpoint churn — i.e. during exactly
|
||||||
|
the Flux-driven rollouts that happen several times a week.
|
||||||
|
|
||||||
|
## 7. Blast radius
|
||||||
|
|
||||||
|
Every public hostname and the API terminate on `siriussec` (Envoy is hostNetwork, label
|
||||||
|
`gateway=true`, API `10.10.0.2:6443`). 51 of 67 running pods live there:
|
||||||
|
|
||||||
|
| Namespace | Pods | Public/internal surface |
|
||||||
|
|-----------|------|------------------------|
|
||||||
|
| sirius-growth | 6 | 3 public hostnames + contact API |
|
||||||
|
| siriusdevops, piedmont | 2+2 | public sites + contact APIs |
|
||||||
|
| forgejo (+ pg) | 2 | `forgejo.siriusdevops.com`, CI runners' registry |
|
||||||
|
| monitoring | 7 | Grafana :8081, Alertmanager → Telegram, Prometheus |
|
||||||
|
| metabase, customer1 | 2+3 | :8085, :8086, :8087 |
|
||||||
|
| osint | 3 | osint site |
|
||||||
|
| flux-system, cert-manager, cnpg-system, logging, netsec, node-io, local-path, ci-runners | 12 | platform plumbing |
|
||||||
|
|
||||||
|
A pod-networking fault during the change takes all of that down at once. The mitigating
|
||||||
|
fact: enabling WG only touches **cross-node** paths, and same-node pod↔pod keeps working, so
|
||||||
|
the failure would surface as "coredns/pods on rpi+linode can't reach siriussec" rather than
|
||||||
|
"everything 503s". The registry pulls and the `siriussec ↔ rpi/linode` control traffic are
|
||||||
|
the canaries.
|
||||||
|
|
||||||
|
## 8. Explicitly not verified
|
||||||
|
|
||||||
|
* Cilium WG throughput/CPU **on this cluster** — that needs the change; §3 numbers are a
|
||||||
|
pod-level WG device nested inside `wg0`, i.e. the same packet shape, not the Cilium code path.
|
||||||
|
* DaemonSet rollout time and the mixed-encryption window.
|
||||||
|
* Whether any listed workload actually breaks at MTU 1325 (dind is the one that definitely
|
||||||
|
needs the change; the rest are reasoned, not exercised).
|
||||||
|
* `nodeEncryption` (beta) with the hostNetwork Envoy gateway — untested; the ingress
|
||||||
|
`node → pod` path therefore remains unencrypted in every plan here.
|
||||||
|
* Key-rotation-after-reboot behaviour: read from source (`pkg/wireguard/agent/agent.go` writes
|
||||||
|
`cilium_wg0.key` if absent), not exercised on a node.
|
||||||
|
* ztunnel (`encryption.type=ztunnel`) — not deployed, not tested; it is the only future
|
||||||
|
mTLS-shaped option in this CNI and it is beta.
|
||||||
|
* The `wg0`/Rosenpass PQ layer was not touched; it applies to `wg0` only and would **not**
|
||||||
|
cover `cilium_wg0`.
|
||||||
|
* The documented WG known issue (packet drops during device reconfiguration) was not
|
||||||
|
reproduced; the linked GitHub issue (#33159) is closed and unrelated.
|
||||||
|
|
||||||
|
## Appendix — probe inventory
|
||||||
|
|
||||||
|
Everything below was created and deleted inside this spike (`encspike` namespace, 4
|
||||||
|
`nicolaka/netshoot:v0.13` pods, `apk add wireguard-tools`, two pod-local WG devices on port
|
||||||
|
51999). Final state check: `kubectl get pods -A | grep -c iperf` = 0,
|
||||||
|
`kubectl get all,ns -A | grep -c encspike` = 0. No Cilium/HelmRelease/WireGuard/Rosenpass
|
||||||
|
object was modified.
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
# 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"]
|
|
||||||
|
|
@ -44,8 +44,6 @@ Arch (siriussec).
|
||||||
rosenpass_unit_active{node="rpi|siriussec"} 0|1
|
rosenpass_unit_active{node="rpi|siriussec"} 0|1
|
||||||
rosenpass_psk_rotation_age_seconds{node=...,interface="wg0|wg-remote"}
|
rosenpass_psk_rotation_age_seconds{node=...,interface="wg0|wg-remote"}
|
||||||
rosenpass_psk_rotation_last_change_timestamp_seconds{node=...,interface="wg0|wg-remote"}
|
rosenpass_psk_rotation_last_change_timestamp_seconds{node=...,interface="wg0|wg-remote"}
|
||||||
rosenpass_upnp_mapping_present{node="rpi"} 0|1
|
|
||||||
rosenpass_upnp_last_check_timestamp_seconds{node="rpi"}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
One series set per interface: `wg0` is Link A and `wg-remote` is Link B, and an
|
One series set per interface: `wg0` is Link A and `wg-remote` is Link B, and an
|
||||||
|
|
@ -53,17 +51,7 @@ interface absent on that host (wg-remote on siriussec, where it does not exist)
|
||||||
is skipped. `RosenpassPskRotationStalled` is interface-agnostic
|
is skipped. `RosenpassPskRotationStalled` is interface-agnostic
|
||||||
(`max by (node, interface) ... > 900`), so a stalled Link B pages as soon as the
|
(`max by (node, interface) ... > 900`), so a stalled Link B pages as soon as the
|
||||||
`wg-remote` series exists — which is why hashing only `wg0` left Link B
|
`wg-remote` series exists — which is why hashing only `wg0` left Link B
|
||||||
unobserved. Its `absent()` arms name `rpi/wg0`, `rpi/wg-remote` and
|
unobserved.
|
||||||
`siriussec/wg0`, so a vanished Link B series pages too while siriussec never
|
|
||||||
claims a `wg-remote` it does not have.
|
|
||||||
|
|
||||||
`rosenpass_upnp_mapping_present` is the state `rosenpass-upnp.sh` stamped on its
|
|
||||||
last 15-minute run (`/run/rosenpass-upnp.present`, `1`/`0`), and
|
|
||||||
`rosenpass_upnp_last_check_timestamp_seconds` is that file's mtime — so a
|
|
||||||
stopped timer reads as stale rather than as a flat healthy `1`. The 60-second
|
|
||||||
metrics timer only reads the file; it never calls `upnpc`, which would poll the
|
|
||||||
router's IGD 1440 times a day. Where the state file does not exist (siriussec)
|
|
||||||
neither series is emitted.
|
|
||||||
|
|
||||||
The script hashes the output of `wg show <interface> preshared-keys` and stores
|
The script hashes the output of `wg show <interface> preshared-keys` and stores
|
||||||
only the SHA-256 digest plus the last-change timestamp in
|
only the SHA-256 digest plus the last-change timestamp in
|
||||||
|
|
@ -93,62 +81,7 @@ it after the `values.yaml` change is reconciled).
|
||||||
|
|
||||||
`RosenpassDown` (unit inactive for 5 m) and `RosenpassPskRotationStalled`
|
`RosenpassDown` (unit inactive for 5 m) and `RosenpassPskRotationStalled`
|
||||||
(age > 900 s for 10 m), both `severity: warning`, both with `absent()` guards
|
(age > 900 s for 10 m), both `severity: warning`, both with `absent()` guards
|
||||||
so a missing series alerts instead of reading as healthy. Both cover **Link A
|
so a missing series alerts instead of reading as healthy.
|
||||||
and Link B**: the rotation rule keys on `(node, interface)`, and its `absent()`
|
|
||||||
arms name `rpi/wg0`, `rpi/wg-remote` and `siriussec/wg0`.
|
|
||||||
|
|
||||||
A third rule, `RosenpassUpnpMappingLost` (`severity: warning`, 10 m), covers
|
|
||||||
Link B's single inbound path: it fires when
|
|
||||||
`rosenpass_upnp_mapping_present == 0`, when no `rosenpass-upnp` run has stamped
|
|
||||||
the state for over 30 minutes (stopped timer, hung IGD), or when the series is
|
|
||||||
absent altogether.
|
|
||||||
|
|
||||||
## Link B (rpi wg-remote ↔ linode wg0)
|
|
||||||
|
|
||||||
Link B is the second transport link: rpi `wg-remote` `10.20.0.2` ↔ linode `wg0`
|
|
||||||
`10.20.0.1`, the exchange on UDP 9999 across the public internet. Two facts make
|
|
||||||
it fragile in ways Link A is not:
|
|
||||||
|
|
||||||
- **The Pi's inbound path is a UPnP mapping**, because the home router has no
|
|
||||||
accessible admin panel. `rosenpass-upnp.sh` re-asserts
|
|
||||||
`UDP 9999 -> 192.168.1.125:9999 'rosenpass-pq'` with a permanent lease every
|
|
||||||
15 minutes, logs to `logger -t rosenpass-upnp` and exits non-zero when the
|
|
||||||
mapping cannot be restored. Install:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
install -m 0755 rosenpass-upnp.sh /usr/local/sbin/
|
|
||||||
install -m 0644 rosenpass-upnp.service rosenpass-upnp.timer /etc/systemd/system/
|
|
||||||
systemctl daemon-reload && systemctl enable --now rosenpass-upnp.timer
|
|
||||||
upnpc -l | grep 9999 # 9999->192.168.1.125:9999, lease 0
|
|
||||||
```
|
|
||||||
|
|
||||||
- **The linode's peer block needs the Pi's public address, which is residential
|
|
||||||
DHCP.** Chosen strategy: a **documented static endpoint, no sync timer** —
|
|
||||||
proved from the router itself: `upnpc -s` reports the WAN connection
|
|
||||||
`Connected, uptime=…` with `Time started : Thu Sep 10 16:38:13 2026` and
|
|
||||||
`ExternalIPAddress = 137.118.156.124`, i.e. ~83 days on the address that is
|
|
||||||
configured, and three independent echo services agreed (2026-12-03). If the
|
|
||||||
address moves the exchange stops and the link keeps its last PSK — which is
|
|
||||||
what `rosenpass_psk_rotation_age_seconds{interface="wg-remote"}` catches.
|
|
||||||
Re-point by editing `endpoint = "<new-ip>:9999"` in the linode's
|
|
||||||
`/etc/rosenpass/config.toml` and `systemctl restart rosenpass` there (both
|
|
||||||
ends do not need restarting; the Pi dials `50.116.38.217:9999`).
|
|
||||||
|
|
||||||
Rollout order that cannot strand the far end: this link carries the only SSH path
|
|
||||||
to the linode, so `/root/rosenpass-linkb-rollback.sh`
|
|
||||||
(`linkb-rollback-rpi.sh`, `linkb-rollback-linode.sh`) is staged on **both** hosts
|
|
||||||
and armed as a transient `systemd-run --on-active=420s` timer *before* the
|
|
||||||
linode's unit starts, self-cancelling via `/run/rosenpass-linkb-ok`. It restores
|
|
||||||
the Pi's Link A-only `/etc/rosenpass/config.toml.pre-linkb` and the static
|
|
||||||
`PresharedKey`s from the untouched `/etc/wireguard/*.conf` with `wg syncconf`.
|
|
||||||
The Linode end is restored by `wg syncconf wg0` from its own conf, so the hub's
|
|
||||||
client peers keep working.
|
|
||||||
|
|
||||||
Verify both ends agree and the key rotates, without printing key material (run
|
|
||||||
as root on the Pi): `linkb-verify.sh` — it hashes each end's PSK, compares them,
|
|
||||||
and prints the Link A sentinel so a scoped rotation is distinguishable from an
|
|
||||||
interface-wide one. Expect a changed digest 180 s apart with `agree` on both
|
|
||||||
samples.
|
|
||||||
|
|
||||||
## Testing the rules without merging
|
## Testing the rules without merging
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Self-cancelling rollback for the Link B rollout, Linode end (wg0 hub).
|
|
||||||
#
|
|
||||||
# Armed as a transient `systemd-run --on-active=420s` timer on the Linode before
|
|
||||||
# rosenpass is started there. It acts locally, because the only SSH path to this
|
|
||||||
# host runs over the tunnel a PSK mismatch would break.
|
|
||||||
#
|
|
||||||
# Cancelled by touching /run/rosenpass-linkb-ok on this host once rotation and
|
|
||||||
# the cluster are verified.
|
|
||||||
#
|
|
||||||
# What it restores: the static PresharedKeys of every peer in
|
|
||||||
# /etc/wireguard/wg0.conf, and stops/disables the rosenpass unit. It never
|
|
||||||
# brings the interface down.
|
|
||||||
set -u
|
|
||||||
|
|
||||||
log() { logger -t rosenpass-linkb "$*"; echo "$*"; }
|
|
||||||
|
|
||||||
# Self-cancel: the operator touches this flag after verification, so this script
|
|
||||||
# is a no-op if the run actually succeeded.
|
|
||||||
if [ -f /run/rosenpass-linkb-ok ]; then
|
|
||||||
log "watchdog fired but /run/rosenpass-linkb-ok exists - no action taken"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
log "ROLLBACK triggered: Link B did not verify within the watchdog window"
|
|
||||||
|
|
||||||
systemctl disable --now rosenpass.service || log "warn: disable --now rosenpass failed"
|
|
||||||
|
|
||||||
if wg-quick strip wg0 > /run/wg0.rollback.stripped 2>/dev/null; then
|
|
||||||
if wg syncconf wg0 /run/wg0.rollback.stripped; then
|
|
||||||
log "wg0 synced from conf: static PresharedKeys restored for all peers"
|
|
||||||
else
|
|
||||||
log "ERROR: wg syncconf wg0 failed; live PSKs unchanged"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log "ERROR: wg-quick strip wg0 failed; live PSKs unchanged"
|
|
||||||
fi
|
|
||||||
rm -f /run/wg0.rollback.stripped
|
|
||||||
|
|
||||||
log "ROLLBACK done - verify: wg show wg0 latest-handshakes (rpi peer < 180 s)"
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Self-cancelling rollback for the Link B rollout (rpi wg-remote <-> linode wg0).
|
|
||||||
#
|
|
||||||
# Armed as a transient `systemd-run --on-active=420s` timer before rosenpass is
|
|
||||||
# started on the Linode. It must live on THIS host and act locally: a PSK
|
|
||||||
# mismatch on Link B kills the WireGuard tunnel, and that tunnel is the only SSH
|
|
||||||
# path to the far end, so no remote rollback can be delivered over it.
|
|
||||||
#
|
|
||||||
# Cancelled by touching /run/rosenpass-linkb-ok (checked by the timer unit's
|
|
||||||
# command, not here) once rotation and the cluster are verified.
|
|
||||||
#
|
|
||||||
# What it restores:
|
|
||||||
# 1. the pre-rollout rosenpass config (Link A peer only - Link A keeps working)
|
|
||||||
# 2. the static PresharedKey on the wg-remote peer, from /etc/wireguard/wg-remote.conf
|
|
||||||
#
|
|
||||||
# Never touches wg0 (Link A) or any client peer.
|
|
||||||
set -u
|
|
||||||
|
|
||||||
log() { logger -t rosenpass-linkb "$*"; echo "$*"; }
|
|
||||||
|
|
||||||
# Self-cancel: the operator touches this flag after verification, so this script
|
|
||||||
# is a no-op if the run actually succeeded.
|
|
||||||
if [ -f /run/rosenpass-linkb-ok ]; then
|
|
||||||
log "watchdog fired but /run/rosenpass-linkb-ok exists - no action taken"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
log "ROLLBACK triggered: Link B did not verify within the watchdog window"
|
|
||||||
|
|
||||||
# 1. Stop rosenpass first, so it cannot re-inject a rotating PSK mid-restore.
|
|
||||||
systemctl disable --now rosenpass.service || log "warn: disable --now rosenpass failed"
|
|
||||||
|
|
||||||
# 2. Put the Link A-only config back and bring Link A's rotation back up.
|
|
||||||
if [ -f /etc/rosenpass/config.toml.pre-linkb ]; then
|
|
||||||
cp -a /etc/rosenpass/config.toml.pre-linkb /etc/rosenpass/config.toml
|
|
||||||
log "restored /etc/rosenpass/config.toml from config.toml.pre-linkb"
|
|
||||||
else
|
|
||||||
log "warn: /etc/rosenpass/config.toml.pre-linkb missing; config left as-is"
|
|
||||||
fi
|
|
||||||
systemctl enable --now rosenpass.service || log "warn: restarting rosenpass failed"
|
|
||||||
|
|
||||||
# 3. Restore the static PSK on wg-remote from the conf (the rollback floor).
|
|
||||||
if wg-quick strip wg-remote > /run/wg-remote.rollback.stripped 2>/dev/null; then
|
|
||||||
if wg syncconf wg-remote /run/wg-remote.rollback.stripped; then
|
|
||||||
log "wg-remote synced from conf: static PresharedKey restored"
|
|
||||||
else
|
|
||||||
log "ERROR: wg syncconf wg-remote failed; live PSK unchanged"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log "ERROR: wg-quick strip wg-remote failed; live PSK unchanged"
|
|
||||||
fi
|
|
||||||
rm -f /run/wg-remote.rollback.stripped
|
|
||||||
|
|
||||||
log "ROLLBACK done - verify: wg show wg-remote latest-handshakes (expect < 180 s)"
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Sample Link B PSK hashes on both ends. Prints no key material: the preshared
|
|
||||||
# key line is filtered on each host and only its SHA-256 (first 16 hex) leaves.
|
|
||||||
set -u
|
|
||||||
LINKB_LINODE='/2Y0XpJYd9Vl9Al6zNAlQimEYA+xY9Y5PO6nUDkfKEA=' # linode wg0 pub (peer on the Pi)
|
|
||||||
LINKB_RPI='h1v1Rhrnq2N2kt454xQamL1Y1x0TaICa1zoKgyZHpkM=' # rpi wg-remote pub (peer on the linode)
|
|
||||||
LINKA='+e50qTPdZiyxMtYHRSdGILIrh06JflFQq5+TZRjVyic=' # siriussec (Link A sentinel)
|
|
||||||
|
|
||||||
h() { tr -d '\n' | sha256sum | cut -c1-16; }
|
|
||||||
|
|
||||||
ts=$(date -u +%FT%TZ)
|
|
||||||
|
|
||||||
pi_linkb=$(wg show wg-remote preshared-keys 2>/dev/null | grep -F "$LINKB_LINODE" | awk '{print $2}' | h)
|
|
||||||
pi_linka=$(wg show wg0 preshared-keys 2>/dev/null | grep -F "$LINKA" | awk '{print $2}' | h)
|
|
||||||
|
|
||||||
ln_linkb=$(ssh -n -i /home/sirius/.ssh/linode_admin -o BatchMode=yes -o ConnectTimeout=10 [email protected] \
|
|
||||||
"wg show wg0 preshared-keys | grep -F '$LINKB_RPI' | awk '{print \$2}'" | h)
|
|
||||||
|
|
||||||
pi_hs=$(wg show wg-remote latest-handshakes 2>/dev/null | grep -F "$LINKB_LINODE" | awk '{print $2}')
|
|
||||||
ln_hs=$(ssh -n -i /home/sirius/.ssh/linode_admin -o BatchMode=yes -o ConnectTimeout=10 [email protected] \
|
|
||||||
"wg show wg0 latest-handshakes | grep -F '$LINKB_RPI' | awk '{print \$2}'")
|
|
||||||
|
|
||||||
agree="MISMATCH"
|
|
||||||
[ "$pi_linkb" = "$ln_linkb" ] && agree="agree"
|
|
||||||
printf '%s linkB pi=%s linode=%s %s | linkA(pi)=%s | hs pi=%s linode=%s\n' \
|
|
||||||
"$ts" "$pi_linkb" "$ln_linkb" "$agree" "$pi_linka" "$pi_hs" "$ln_hs"
|
|
||||||
|
|
@ -21,15 +21,6 @@
|
||||||
# last changed. Rotation runs about every two minutes.
|
# last changed. Rotation runs about every two minutes.
|
||||||
# rosenpass_psk_rotation_last_change_timestamp_seconds{node,interface}
|
# rosenpass_psk_rotation_last_change_timestamp_seconds{node,interface}
|
||||||
# unix timestamp of that last observed change.
|
# unix timestamp of that last observed change.
|
||||||
# rosenpass_upnp_mapping_present{node}
|
|
||||||
# 1/0 state that rosenpass-upnp.sh stamped on its
|
|
||||||
# last run (Link B's only inbound path on the Pi).
|
|
||||||
# Only emitted where that unit runs: no state file,
|
|
||||||
# no series, so siriussec does not advertise it.
|
|
||||||
# rosenpass_upnp_last_check_timestamp_seconds{node}
|
|
||||||
# unix mtime of that state file, so a stopped
|
|
||||||
# rosenpass-upnp.timer reads as stale rather than as
|
|
||||||
# a flat healthy 1.
|
|
||||||
#
|
#
|
||||||
# Interfaces are emitted independently: wg0 is Link A (rpi <-> siriussec) and
|
# Interfaces are emitted independently: wg0 is Link A (rpi <-> siriussec) and
|
||||||
# wg-remote is Link B (rpi <-> linode, through a permanent UPnP mapping on a
|
# wg-remote is Link B (rpi <-> linode, through a permanent UPnP mapping on a
|
||||||
|
|
@ -68,23 +59,7 @@ if [ "$(systemctl is-active "$UNIT" 2>/dev/null || true)" = "active" ]; then
|
||||||
active=1
|
active=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- 2. UPnP mapping state (Link B inbound path) -----------------------------
|
# --- 2. PSK rotation, per interface -----------------------------------------
|
||||||
# rosenpass-upnp.sh stamps 1/0 into /run on each of its 15-min runs. This timer
|
|
||||||
# must NOT call upnpc itself: that would poll the IGD 1440x/day and put the
|
|
||||||
# fragile component in the hot path. No state file means this host does not run
|
|
||||||
# that unit (siriussec), so emit nothing there.
|
|
||||||
UPNP_STATE=/run/rosenpass-upnp.present
|
|
||||||
upnp=""
|
|
||||||
upnp_ts=""
|
|
||||||
if [ -r "$UPNP_STATE" ]; then
|
|
||||||
upnp=$(head -n 1 "$UPNP_STATE" 2>/dev/null | tr -d '[:space:]')
|
|
||||||
case "$upnp" in
|
|
||||||
0 | 1) upnp_ts=$(stat -c %Y "$UPNP_STATE" 2>/dev/null || echo "$now") ;;
|
|
||||||
*) upnp="" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --- 3. PSK rotation, per interface -----------------------------------------
|
|
||||||
# `wg show ... preshared-keys` fails (and prints nothing) when the interface is
|
# `wg show ... preshared-keys` fails (and prints nothing) when the interface is
|
||||||
# absent; command substitution would otherwise hash an empty string, which looks
|
# absent; command substitution would otherwise hash an empty string, which looks
|
||||||
# like a change on the first poll after the interface returns. Only hash real
|
# like a change on the first poll after the interface returns. Only hash real
|
||||||
|
|
@ -96,15 +71,6 @@ tmp="$OUT_FILE.$$"
|
||||||
printf '# TYPE rosenpass_unit_active gauge\n'
|
printf '# TYPE rosenpass_unit_active gauge\n'
|
||||||
printf 'rosenpass_unit_active{node="%s"} %s\n' "$NODE" "$active"
|
printf 'rosenpass_unit_active{node="%s"} %s\n' "$NODE" "$active"
|
||||||
|
|
||||||
if [ -n "$upnp" ]; then
|
|
||||||
printf '# HELP rosenpass_upnp_mapping_present The Link B UPnP mapping (UDP 9999 -> rpi) is present (1) or missing (0), as of the last rosenpass-upnp.sh run.\n'
|
|
||||||
printf '# TYPE rosenpass_upnp_mapping_present gauge\n'
|
|
||||||
printf 'rosenpass_upnp_mapping_present{node="%s"} %s\n' "$NODE" "$upnp"
|
|
||||||
printf '# HELP rosenpass_upnp_last_check_timestamp_seconds Unix timestamp of the last rosenpass-upnp.sh run that wrote the state file.\n'
|
|
||||||
printf '# TYPE rosenpass_upnp_last_check_timestamp_seconds gauge\n'
|
|
||||||
printf 'rosenpass_upnp_last_check_timestamp_seconds{node="%s"} %s\n' "$NODE" "$upnp_ts"
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf '# HELP rosenpass_psk_rotation_age_seconds Seconds since that interface preshared-key set last changed.\n'
|
printf '# HELP rosenpass_psk_rotation_age_seconds Seconds since that interface preshared-key set last changed.\n'
|
||||||
printf '# TYPE rosenpass_psk_rotation_age_seconds gauge\n'
|
printf '# TYPE rosenpass_psk_rotation_age_seconds gauge\n'
|
||||||
printf '# HELP rosenpass_psk_rotation_last_change_timestamp_seconds Unix timestamp of the last observed preshared-key change on that interface.\n'
|
printf '# HELP rosenpass_psk_rotation_last_change_timestamp_seconds Unix timestamp of the last observed preshared-key change on that interface.\n'
|
||||||
|
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=Re-assert UPnP mapping for Rosenpass Link B (UDP 9999 -> rpi)
|
|
||||||
Documentation=https://github.com/rosenpass/rosenpass
|
|
||||||
After=network-online.target
|
|
||||||
Wants=network-online.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStart=/usr/local/sbin/rosenpass-upnp.sh
|
|
||||||
# A router reboot drops the mapping; retry a few times before giving up so a
|
|
||||||
# transient WAN/IGD hiccup does not page anyone.
|
|
||||||
Restart=on-failure
|
|
||||||
RestartSec=30s
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# rosenpass-upnp.sh - re-assert the permanent UPnP mapping that gives the
|
|
||||||
# Linode a way back to Rosenpass on the Pi (UDP 9999 -> 192.168.1.125:9999).
|
|
||||||
#
|
|
||||||
# The home router's admin panel is inaccessible, so this mapping is the ONLY
|
|
||||||
# inbound path for the Rosenpass exchange on Link B (rpi wg-remote <->
|
|
||||||
# linode wg0). It is runtime state: a router reboot, a factory reset or a UPnP
|
|
||||||
# daemon hiccup drops it, and the failure is silent - the link keeps its last
|
|
||||||
# PSK and simply stops being post-quantum. Hence this timer.
|
|
||||||
#
|
|
||||||
# Idempotent: re-adding an identical permanent-lease mapping is a no-op, so it
|
|
||||||
# is safe to run on a schedule. Never prints key material (it handles none).
|
|
||||||
set -uo pipefail
|
|
||||||
|
|
||||||
LAN_IP=192.168.1.125
|
|
||||||
PORT=9999
|
|
||||||
DESC=rosenpass-pq
|
|
||||||
# Result of this run, read by rosenpass-metrics.sh (60 s textfile collector) so
|
|
||||||
# the mapping is observable without polling the IGD from that timer. /run is
|
|
||||||
# tmpfs: on a reboot the file is gone and the metric is absent until this unit
|
|
||||||
# runs again (OnBootSec=2min), which the alert treats as "unknown", not "lost".
|
|
||||||
STATE=/run/rosenpass-upnp.present
|
|
||||||
|
|
||||||
set_present() {
|
|
||||||
printf '%s\n' "$1" > "$STATE.tmp" && mv "$STATE.tmp" "$STATE"
|
|
||||||
}
|
|
||||||
|
|
||||||
out=$(upnpc -e "$DESC" -a "$LAN_IP" "$PORT" "$PORT" UDP 0 2>&1) || true
|
|
||||||
|
|
||||||
# upnpc prints the mapping as " 0 UDP 9999->192.168.1.125:9999 'rosenpass-pq'"
|
|
||||||
if ! upnpc -l 2>/dev/null | grep -q "${PORT}->${LAN_IP}:${PORT}"; then
|
|
||||||
set_present 0
|
|
||||||
logger -t rosenpass-upnp "mapping missing after re-assert: ${out}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
set_present 1
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=Re-assert the Rosenpass Link B UPnP mapping every 15 minutes
|
|
||||||
|
|
||||||
[Timer]
|
|
||||||
OnBootSec=2min
|
|
||||||
OnUnitActiveSec=15min
|
|
||||||
AccuracySec=30s
|
|
||||||
Unit=rosenpass-upnp.service
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=timers.target
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
# Egress lockdown for the nightly Grafana sqlite snapshot (card t_9d0428d8).
|
|
||||||
#
|
|
||||||
# Why: grafana-backup used to run `apk add --no-cache rsync openssh-client` at
|
|
||||||
# container start, so every night it dialled the Alpine CDN
|
|
||||||
# (dl-cdn.alpinelinux.org -> Fastly 151.101.x.132:443) and kept firing the
|
|
||||||
# `egress-new-dst` flow alert whenever that anycast address rotated. The
|
|
||||||
# toolchain is now baked into the image (images/backup/Dockerfile) and this
|
|
||||||
# policy makes any future runtime fetch fail loudly instead of silently
|
|
||||||
# reaching the internet.
|
|
||||||
#
|
|
||||||
# `monitoring` has no namespace-wide default-deny, so selecting the backup pod
|
|
||||||
# here isolates it on its own: the rules below are the complete egress allow
|
|
||||||
# list and everything else (including `world`) is dropped. `egressDeny` is
|
|
||||||
# stated explicitly so the intent survives a future namespace-wide allow being
|
|
||||||
# added — Cilium deny always beats allow.
|
|
||||||
#
|
|
||||||
# Needs: cluster DNS (the script resolves nothing itself, but the image and any
|
|
||||||
# `ssh` target lookup would), and [email protected]:22 — that is the Linode node's
|
|
||||||
# InternalIP, so Cilium classifies it `remote-node`, not `world`. The registry
|
|
||||||
# pull and the Grafana PVC access are not pod traffic and are unaffected.
|
|
||||||
apiVersion: cilium.io/v2
|
|
||||||
kind: CiliumNetworkPolicy
|
|
||||||
metadata:
|
|
||||||
name: grafana-backup-egress
|
|
||||||
namespace: monitoring
|
|
||||||
labels:
|
|
||||||
app: grafana-backup
|
|
||||||
spec:
|
|
||||||
description: >-
|
|
||||||
grafana-backup pod: cluster DNS + SSH to the backup host (10.10.0.5:22)
|
|
||||||
only; no internet egress at run time.
|
|
||||||
endpointSelector:
|
|
||||||
matchLabels:
|
|
||||||
app: grafana-backup
|
|
||||||
egress:
|
|
||||||
- toEndpoints:
|
|
||||||
- matchLabels:
|
|
||||||
io.kubernetes.pod.namespace: kube-system
|
|
||||||
k8s-app: kube-dns
|
|
||||||
toPorts:
|
|
||||||
- ports:
|
|
||||||
- port: "53"
|
|
||||||
protocol: UDP
|
|
||||||
- port: "53"
|
|
||||||
protocol: TCP
|
|
||||||
- toEntities:
|
|
||||||
- remote-node
|
|
||||||
toPorts:
|
|
||||||
- ports:
|
|
||||||
- port: "22"
|
|
||||||
protocol: TCP
|
|
||||||
egressDeny:
|
|
||||||
- toEntities:
|
|
||||||
- world
|
|
||||||
|
|
@ -27,10 +27,10 @@ data:
|
||||||
# T480's root filesystem, the only local file is a ~3 MB copy in /tmp.
|
# T480's root filesystem, the only local file is a ~3 MB copy in /tmp.
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# No package install here on purpose: rsync/openssh-client/python3 are
|
if ! command -v rsync >/dev/null || ! command -v ssh >/dev/null; then
|
||||||
# baked into the pinned image (images/backup/Dockerfile) and this pod's
|
echo "== installing rsync + openssh-client"
|
||||||
# egress policy admits DNS + 10.10.0.5:22 only, so a runtime fetch would
|
apk add --no-cache rsync openssh-client >/dev/null
|
||||||
# fail rather than silently dial the Alpine CDN (card t_9d0428d8).
|
fi
|
||||||
|
|
||||||
BACKUP_HOST=${BACKUP_HOST:[email protected]}
|
BACKUP_HOST=${BACKUP_HOST:[email protected]}
|
||||||
BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup}
|
BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup}
|
||||||
|
|
@ -128,22 +128,15 @@ spec:
|
||||||
app: grafana-backup
|
app: grafana-backup
|
||||||
spec:
|
spec:
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
# Pulled from the in-cluster Forgejo registry (which requires auth);
|
|
||||||
# monitoring had no registry pull secret before this job needed one.
|
|
||||||
imagePullSecrets:
|
|
||||||
- name: forgejo-pull
|
|
||||||
# The grafana PVC is local-path on siriussec; RWO still allows a
|
# The grafana PVC is local-path on siriussec; RWO still allows a
|
||||||
# second pod on the same node.
|
# second pod on the same node.
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/hostname: siriussec
|
||||||
containers:
|
containers:
|
||||||
- name: backup
|
- name: backup
|
||||||
# python3.12-alpine + rsync + openssh-client, baked at build time
|
# python3 alpine: the sqlite backup API is the only consistent
|
||||||
# and pinned by digest (images/backup/Dockerfile, CI workflow
|
# way to copy a live database without a shell inside Grafana.
|
||||||
# .forgejo/workflows/backup-image.yml). The sqlite backup API is
|
image: python:3.12-alpine
|
||||||
# the only consistent way to copy a live database without a shell
|
|
||||||
# inside Grafana. Nothing is installed at run time.
|
|
||||||
image: forgejo.siriusdevops.com/sirius/backup-tools@sha256:cc8dc1645111b3a80b7c4d5168f6bce3002cae7417b3725683c057976f6e379a
|
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
command: ["/bin/sh", "/scripts/backup.sh"]
|
command: ["/bin/sh", "/scripts/backup.sh"]
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,8 @@ resources:
|
||||||
# Series come from a host textfile exporter (infrastructure/networking/rosenpass/),
|
# Series come from a host textfile exporter (infrastructure/networking/rosenpass/),
|
||||||
# so silently missing data is itself an alert.
|
# so silently missing data is itself an alert.
|
||||||
- rosenpass.yaml
|
- rosenpass.yaml
|
||||||
# Analyst freshness: OsintAnalystStale + OsintIngestAliveButNoBrief, built on
|
|
||||||
# the osint-analyst-exporter timestamps (card t_22334588).
|
|
||||||
- osint-analyst.yaml
|
|
||||||
# Nightly consistent sqlite snapshot of Grafana's dashboards/alerts/users.
|
# Nightly consistent sqlite snapshot of Grafana's dashboards/alerts/users.
|
||||||
- grafana-backup.yaml
|
- grafana-backup.yaml
|
||||||
# Egress lockdown for that backup pod: DNS + the backup host only, so no
|
|
||||||
# run-time package fetch (card t_9d0428d8).
|
|
||||||
- grafana-backup-networkpolicy.yaml
|
|
||||||
- dashboards
|
- dashboards
|
||||||
# Secrets, SOPS/age-encrypted in git (decrypted by the `monitoring`
|
# Secrets, SOPS/age-encrypted in git (decrypted by the `monitoring`
|
||||||
# Kustomization; key = flux-system/sops-age). See docs/secrets-sops.md.
|
# Kustomization; key = flux-system/sops-age). See docs/secrets-sops.md.
|
||||||
|
|
@ -30,10 +24,6 @@ resources:
|
||||||
- secret-grafana-secret-key.sops.yaml
|
- secret-grafana-secret-key.sops.yaml
|
||||||
- secret-alertmanager-telegram.sops.yaml
|
- secret-alertmanager-telegram.sops.yaml
|
||||||
- secret-cluster-backup-ssh.sops.yaml
|
- secret-cluster-backup-ssh.sops.yaml
|
||||||
# Registry pull credential for this namespace. Added because grafana-backup
|
|
||||||
# now runs an image from the in-cluster Forgejo registry instead of
|
|
||||||
# python:3.12-alpine from Docker Hub (card t_9d0428d8).
|
|
||||||
- secret-forgejo-pull.sops.yaml
|
|
||||||
|
|
||||||
configMapGenerator:
|
configMapGenerator:
|
||||||
- name: kube-prometheus-stack-values
|
- name: kube-prometheus-stack-values
|
||||||
|
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
||||||
# osint analyst freshness -> Prometheus (card t_22334588)
|
|
||||||
#
|
|
||||||
# On 2026-11-25 the analyst (deploy/osint-news-summarizer) silently stopped
|
|
||||||
# writing article_summaries and stayed dead for nine days. The scraper kept
|
|
||||||
# ingesting normally (61.5k rows in articles, newest within minutes), the pod
|
|
||||||
# stayed Running with restarts 0, and the log carried nothing but INFO batch
|
|
||||||
# lines and 404s at INFO level -- so every signal the cluster already had said
|
|
||||||
# "healthy". These two rules are built on the timestamps the exporter in
|
|
||||||
# apps/base/osint/analyst-exporter.yaml reads straight out of Postgres
|
|
||||||
# (SeriesMonitor osint-analyst-exporter, ns osint, :9187/metrics):
|
|
||||||
#
|
|
||||||
# osint_analyst_last_success_timestamp_seconds max(article_summaries.batch_timestamp)
|
|
||||||
# osint_ingest_last_article_timestamp_seconds max(articles.timestamp)
|
|
||||||
# osint_analyst_exporter_up 1 when the last DB read worked
|
|
||||||
#
|
|
||||||
# OsintAnalystStale is the general "no brief in over an hour" gate; the
|
|
||||||
# summarizer loops every 15 min, so an hour of silence cannot be a slow batch.
|
|
||||||
# OsintIngestAliveButNoBrief is the sharper one: a fresh article row plus a
|
|
||||||
# summary table frozen for two hours names the exact failure -- ingest fine,
|
|
||||||
# analyst dark -- without waiting for the read path or the API to be down.
|
|
||||||
#
|
|
||||||
# The absent() arm on OsintAnalystStale is deliberate: if the exporter, its
|
|
||||||
# ServiceMonitor or its scrape disappears, the series vanishes and "no data"
|
|
||||||
# would otherwise read as "no problem", which is the same invisible-failure
|
|
||||||
# shape this card exists to kill. Routes through the default Alertmanager
|
|
||||||
# receiver (Telegram @Siriusdevops_alert_bot).
|
|
||||||
apiVersion: monitoring.coreos.com/v1
|
|
||||||
kind: PrometheusRule
|
|
||||||
metadata:
|
|
||||||
name: osint-analyst
|
|
||||||
namespace: monitoring
|
|
||||||
labels:
|
|
||||||
release: kube-prometheus-stack
|
|
||||||
spec:
|
|
||||||
groups:
|
|
||||||
- name: osint-analyst
|
|
||||||
rules:
|
|
||||||
- alert: OsintAnalystStale
|
|
||||||
expr: |
|
|
||||||
(
|
|
||||||
time() - osint_analyst_last_success_timestamp_seconds > 3600
|
|
||||||
)
|
|
||||||
or
|
|
||||||
absent(osint_analyst_last_success_timestamp_seconds)
|
|
||||||
for: 30m
|
|
||||||
labels:
|
|
||||||
severity: warning
|
|
||||||
annotations:
|
|
||||||
summary: >-
|
|
||||||
osint analyst has written no brief for over an hour
|
|
||||||
description: >-
|
|
||||||
The newest article_summaries.batch_timestamp is more than an hour
|
|
||||||
old (the summarizer loops every 15 minutes), or the freshness
|
|
||||||
series is missing entirely. The container can still be Running
|
|
||||||
with restarts 0: a wedged analyst looks exactly like an idle one.
|
|
||||||
Check `kubectl -n osint logs deploy/osint-news-summarizer --tail=50`
|
|
||||||
for the interval rc, confirm the exporter target is UP in
|
|
||||||
Prometheus (job osint-analyst-exporter), and test the analyst
|
|
||||||
query directly:
|
|
||||||
`kubectl -n osint exec deploy/osint-db -- psql -U osint -d osint_data -c "select max(batch_timestamp), count(*) from article_summaries"`.
|
|
||||||
A silently dead model/API key is the usual cause.
|
|
||||||
- alert: OsintIngestAliveButNoBrief
|
|
||||||
expr: |
|
|
||||||
(
|
|
||||||
time() - osint_analyst_last_success_timestamp_seconds > 7200
|
|
||||||
)
|
|
||||||
and
|
|
||||||
(
|
|
||||||
time() - osint_ingest_last_article_timestamp_seconds < 7200
|
|
||||||
)
|
|
||||||
for: 10m
|
|
||||||
labels:
|
|
||||||
severity: warning
|
|
||||||
annotations:
|
|
||||||
summary: >-
|
|
||||||
osint scraper is ingesting but the analyst has written no brief for 2h
|
|
||||||
description: >-
|
|
||||||
`articles` has a row younger than two hours while
|
|
||||||
`article_summaries` has nothing newer than two hours. Ingest fine
|
|
||||||
+ analyst dark is the shape of the 2026-11-25..12-04 outage, where
|
|
||||||
the pipeline looked healthy for nine days because only the ingest
|
|
||||||
side was moving. Confirm the scraper is genuinely alive
|
|
||||||
(`kubectl -n osint logs deploy/osint-news-scraper --tail=20`) and
|
|
||||||
then debug the analyst side: summarizer logs, NEWS_SUMMARIZE_*
|
|
||||||
env, the resolved SUMMARY_MODEL and the Nous API key/inference
|
|
||||||
endpoint (a dead model or a 404 on every map call writes zero
|
|
||||||
rows while the loop keeps logging rc=0).
|
|
||||||
|
|
@ -19,25 +19,14 @@
|
||||||
# Series, emitted per host, never containing key material (the PSK set is only
|
# Series, emitted per host, never containing key material (the PSK set is only
|
||||||
# SHA-256 hashed, in a root-only state file):
|
# SHA-256 hashed, in a root-only state file):
|
||||||
# rosenpass_unit_active{node="rpi|siriussec"} 0|1
|
# rosenpass_unit_active{node="rpi|siriussec"} 0|1
|
||||||
# rosenpass_psk_rotation_age_seconds{node=...,interface="wg0|wg-remote"}
|
# rosenpass_psk_rotation_age_seconds{node=...,interface="wg0"}
|
||||||
# rosenpass_psk_rotation_last_change_timestamp_seconds{node=...,interface="wg0|wg-remote"}
|
# rosenpass_psk_rotation_last_change_timestamp_seconds{node=...,interface="wg0"}
|
||||||
# rosenpass_upnp_mapping_present{node="rpi"} 0|1
|
|
||||||
# rosenpass_upnp_last_check_timestamp_seconds{node="rpi"}
|
|
||||||
#
|
#
|
||||||
# Both rotation rules carry an absent() arm deliberately: a metric that simply
|
# Both rules carry an absent() arm deliberately: a metric that simply stops
|
||||||
# stops arriving (timer disabled, script broken, node-exporter down, scrape lost)
|
# arriving (timer disabled, script broken, node-exporter down, scrape lost)
|
||||||
# must alert, because "nothing happened" is exactly what a healthy rotation
|
# must alert, because "nothing happened" is exactly what a healthy rotation
|
||||||
# looks like from Prometheus' side. The absent arms name the hosts and
|
# looks like from Prometheus' side. The absent arms name the two hosts that run
|
||||||
# interfaces that actually run the timer — rpi wg0 + wg-remote (Link A + Link B),
|
# the timer so linode — which has node-exporter but no rosenpass — does not page.
|
||||||
# siriussec wg0 (Link A only; it has no wg-remote) — so linode, which has
|
|
||||||
# node-exporter but no rosenpass, and an interface absent from a host do not
|
|
||||||
# page.
|
|
||||||
#
|
|
||||||
# Link B's inbound path is a permanent UPnP mapping on the Pi's router (which
|
|
||||||
# has no accessible admin panel). rosenpass-upnp.sh re-asserts it every 15 min
|
|
||||||
# and stamps 1/0 into /run, which rosenpass-metrics.sh turns into the series
|
|
||||||
# below. Without that mapping the exchange cannot be dialled, the link keeps its
|
|
||||||
# last PSK and silently stops being post-quantum.
|
|
||||||
apiVersion: monitoring.coreos.com/v1
|
apiVersion: monitoring.coreos.com/v1
|
||||||
kind: PrometheusRule
|
kind: PrometheusRule
|
||||||
metadata:
|
metadata:
|
||||||
|
|
@ -85,8 +74,6 @@ spec:
|
||||||
(
|
(
|
||||||
absent(rosenpass_psk_rotation_age_seconds{node="rpi", interface="wg0"})
|
absent(rosenpass_psk_rotation_age_seconds{node="rpi", interface="wg0"})
|
||||||
or
|
or
|
||||||
absent(rosenpass_psk_rotation_age_seconds{node="rpi", interface="wg-remote"})
|
|
||||||
or
|
|
||||||
absent(rosenpass_psk_rotation_age_seconds{node="siriussec", interface="wg0"})
|
absent(rosenpass_psk_rotation_age_seconds{node="siriussec", interface="wg0"})
|
||||||
)
|
)
|
||||||
for: 10m
|
for: 10m
|
||||||
|
|
@ -105,35 +92,3 @@ spec:
|
||||||
`journalctl -u rosenpass -n 30` on both rpi and siriussec, and
|
`journalctl -u rosenpass -n 30` on both rpi and siriussec, and
|
||||||
confirm the Pi still admits 9999/udp from 192.168.1.179
|
confirm the Pi still admits 9999/udp from 192.168.1.179
|
||||||
(`sudo ufw status | grep 9999`).
|
(`sudo ufw status | grep 9999`).
|
||||||
- alert: RosenpassUpnpMappingLost
|
|
||||||
expr: |
|
|
||||||
(
|
|
||||||
max by (node) (rosenpass_upnp_mapping_present) == 0
|
|
||||||
)
|
|
||||||
or
|
|
||||||
(
|
|
||||||
time() - max by (node) (rosenpass_upnp_last_check_timestamp_seconds) > 1800
|
|
||||||
)
|
|
||||||
or
|
|
||||||
absent(rosenpass_upnp_mapping_present{node="rpi"})
|
|
||||||
for: 10m
|
|
||||||
labels:
|
|
||||||
severity: warning
|
|
||||||
annotations:
|
|
||||||
summary: >-
|
|
||||||
Link B UPnP mapping missing or unverified on {{ $labels.node }}
|
|
||||||
description: >-
|
|
||||||
Link B (rpi wg-remote 10.20.0.2 <-> linode wg0 10.20.0.1) can only
|
|
||||||
be dialled inbound through a permanent UPnP mapping
|
|
||||||
UDP 9999 -> 192.168.1.125:9999 on the Pi's router, and
|
|
||||||
rosenpass-upnp.timer re-asserts it every 15 minutes. Either the
|
|
||||||
last run reported the mapping missing (value 0), no run has
|
|
||||||
updated the state for over 30 minutes (timer or router IGD gone),
|
|
||||||
or the series is absent entirely (state file cleared by a reboot,
|
|
||||||
metrics timer dead). The link keeps passing traffic on its last
|
|
||||||
preshared key, so this is invisible from the tunnel. On rpi check
|
|
||||||
`systemctl status rosenpass-upnp.timer`,
|
|
||||||
`journalctl -t rosenpass-upnp -n 20` and `upnpc -l | grep 9999`;
|
|
||||||
re-assert by hand with
|
|
||||||
`sudo systemctl start rosenpass-upnp.service`. If the router
|
|
||||||
rebooted, the mapping comes back on the next timer run.
|
|
||||||
|
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
data:
|
|
||||||
.dockerconfigjson: ENC[AES256_GCM,data:c7NwYAKS00RAzkEW3z1IA2XP24cdIJgQAaBjg7+WcsxLMEs2h42cg/fdtW6UYrrsQtq7X/T4wgfpzUjHq8aMI2lyiVhJa9vxHknpK32i2mP63YQ7o2axI2p5eGPQpB+uuLPr3e1A6I939co6LQCBrY1ueK9+9atCcSEflv/wJyXwrwvlV5EL20PTLTM/y8gGN9cXXfgk6aYV7F5mowQCcUIUDvCbj7cHIonumMfCANQgGjQHrACf0+2ko853nBwLQK1AtIP+U/NS1wDSbFmxqyO6OstF10Sq5t+8dY8baIt73RWN0BqB/7i08TsMpnNUXH4XJcP6WhP0FM+X3M5goJr80DNy2uG3fxTHwRSAeWGzIo2GuuK9qlMtIjjnU97K,iv:xPgSzx6+EEJRnTGYG+QZWJ7G3MUf6Ajd+CXpl8+XIxs=,tag:alsSmEFhXW46SeoVzdqyFA==,type:str]
|
|
||||||
kind: Secret
|
|
||||||
metadata:
|
|
||||||
name: forgejo-pull
|
|
||||||
namespace: monitoring
|
|
||||||
type: kubernetes.io/dockerconfigjson
|
|
||||||
sops:
|
|
||||||
age:
|
|
||||||
- enc: |
|
|
||||||
-----BEGIN AGE ENCRYPTED FILE-----
|
|
||||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA1eU8ydkR5SmF2UG9ZQWNY
|
|
||||||
TWdKTFJkdjFlWWtBSW4wdmFDWXA0akNSSFI4CmVpL3dMKy91b1JTUTRyV1QyRXlI
|
|
||||||
YnlQZVJhL0hNRENNdlM1cDZKZmRUN0kKLS0tIEZOVHBLOUsvbFp6VjJXbW1tVmhK
|
|
||||||
Y1M4a2VyL0Z2MDhLeGJZUCtHRnQ2cmMKU9Q4m7ZuZDYbNQgsvOXEAKBE1hW1pa7m
|
|
||||||
7/pmRAP43OjXfsjWUbnPmORcHSrVDtRrBxQZ2d1svVdwd6vMUPPjqw==
|
|
||||||
-----END AGE ENCRYPTED FILE-----
|
|
||||||
recipient: age12zdn7x72zrgu9cdv8wdj7xfx42nz09nrwpc2g09cwx5fwdm0ry6qp5h4jp
|
|
||||||
encrypted_regex: ^(data|stringData)$
|
|
||||||
lastmodified: "2026-12-04T05:16:30Z"
|
|
||||||
mac: ENC[AES256_GCM,data:yYt1AWNi+Ts4c/p3OwrknVVPMPf9PEeYvgz/LckFqsJweSq36b6gzinMcLxJGnenmCokftUA4RvMMF2f0Lcpo3+RqmpPGnCzpAVQ0ypuS2+n+bET7tF/tu9icuwZaTu0sNW+/j8VK5T5nlrrw+aLf3O9yIuP7XVLXyjodJqbH7c=,iv:jSMmP96DHN6qLmpHoisVQu1DYlMVehxdXNWkzh5GZwk=,tag:b98z963bBjpM5gGZnKHqBg==,type:str]
|
|
||||||
version: 3.13.3
|
|
||||||
Loading…
Reference in a new issue