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

Merged
sirius merged 1 commit from wt/t_34ddaa83 into master 2026-11-27 05:49:16 +00:00
Owner

Follow-up to #52/#56: ship the kube-apiserver audit log that t_104f62a6 made live.

  • New source job="kube/apiserver-audit" — read-only hostPath mount of /var/log/kubernetes/audit on siriussec (a pod-log collector cannot see a host file), live file plus rotated .gz (decompression { format = "gz" }).
  • Secret bodies are stripped at the shipper. At level: RequestResponse each get secrets record carries responseObject.data — the plaintext secret. The record is parsed and re-emitted as a packed allowlist (level, stage, verb, user, objectRef.*, responseStatus.code, sourceIPs[0], userAgent, auditID, requestURI, requestReceivedTimestamp); requestObject/responseObject never reach Loki, and unparseable lines are dropped rather than passed through.
  • The collector never writes to or prunes that directory — the apiserver's own 100 MB x 48 rotation stays the only thing pruning it. Loki's 192h retention applies to the stored copies.
  • Promoted labels: verb, resource (small, fixed). user and the object name stay in the packed body to keep the stream count flat.

Verification to be posted as a comment: a get secrets record is queryable with user/verb/resource, and {job="kube/apiserver-audit"} |= "responseObject" returns zero lines.

Follow-up to #52/#56: ship the **kube-apiserver audit log** that `t_104f62a6` made live. * New source `job="kube/apiserver-audit"` — read-only hostPath mount of `/var/log/kubernetes/audit` on `siriussec` (a pod-log collector cannot see a host file), live file plus rotated `.gz` (`decompression { format = "gz" }`). * **Secret bodies are stripped at the shipper.** At `level: RequestResponse` each `get secrets` record carries `responseObject.data` — the plaintext secret. The record is parsed and re-emitted as a packed allowlist (`level, stage, verb, user, objectRef.*, responseStatus.code, sourceIPs[0], userAgent, auditID, requestURI, requestReceivedTimestamp`); `requestObject`/`responseObject` never reach Loki, and unparseable lines are dropped rather than passed through. * The collector never writes to or prunes that directory — the apiserver's own 100 MB x 48 rotation stays the only thing pruning it. Loki's 192h retention applies to the stored copies. * Promoted labels: `verb`, `resource` (small, fixed). `user` and the object name stay in the packed body to keep the stream count flat. Verification to be posted as a comment: a `get secrets` record is queryable with `user`/`verb`/`resource`, and `{job="kube/apiserver-audit"} |= "responseObject"` returns zero lines.
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.
sirius merged commit 88f3fe1cd0 into master 2026-11-27 05:49:16 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/homek8s!59
No description provided.