infra(logging): ship kube-apiserver audit log with secret bodies stripped

t_104f62a6 made the apiserver audit log live on siriussec:
/var/log/kubernetes/audit/audit.log, mode 600 root, ~2.2 GB/day, rotated by the
apiserver itself (100 MB x 48, compressed). A pod-log collector never sees a
host file, so Alloy gets a read-only hostPath mount for that directory.

The file MUST NOT be shipped verbatim: at level=RequestResponse every
'get secrets' record carries responseObject.data — the plaintext secret.
The shipper therefore parses each record and re-emits a packed allowlist
(level, stage, verb, user, objectRef.*, responseStatus.code, sourceIPs[0],
userAgent, auditID, requestURI, requestReceivedTimestamp). requestObject and
responseObject never reach Loki; unparseable lines are dropped by stage.json
rather than passed through.

Nothing in that directory is written or pruned by the collector: the
apiserver's own 4.8 GB / 7-day rotation stays the only thing pruning it.
This commit is contained in:
Lance Walters 2026-11-27 00:49:07 -05:00
commit fef71a280a
2 changed files with 110 additions and 0 deletions

View file

@ -83,6 +83,12 @@ spec:
- name: dockerlogs
mountPath: /var/lib/docker/containers
readOnly: true
# kube-apiserver audit log (siriussec only). Read-only: the
# apiserver owns that directory and its rotation; the collector
# never writes to or prunes it.
- name: audit
mountPath: /var/log/kubernetes/audit
readOnly: true
# NOT /var/lib/alloy/...: that path is 0770 alloy:alloy in the
# image, and this pod drops ALL capabilities (so root has no
# CAP_DAC_OVERRIDE) — traversal of the parent is denied. /var/lib
@ -114,6 +120,10 @@ spec:
hostPath:
path: /var/lib/docker/containers
type: DirectoryOrCreate
- name: audit
hostPath:
path: /var/log/kubernetes/audit
type: DirectoryOrCreate
- name: data
hostPath:
path: /var/lib/alloy-data