The collector wrote 150 MiB plaintext files into a directory capped at 960 MiB, which bought only ~4-5 h of retention at the measured 4.5-6.2 GB/day (3380-4280 kB/min) of filtered Hubble JSONL — the cap was sized for a forensic window, not for hours. Compress on rotate; no schema change, no filter change, no DS argument change: * the file being appended stays plain `flows-<ts>-<n>.jsonl` (one file for a reader to tail); * on rotation the closed file is gzip'd to `.jsonl.gz` through a temp name + atomic rename, in the background, so a reader never sees a partial archive and the flow reader never stalls (stalling it makes the agent drop events); * prune bounds the WHOLE directory at MAX_TOTAL_BYTES = 960 MiB — archives and in-flight `.gz.tmp` included — deleting oldest first, and never reaps the live file nor a file whose gzip is still running (that would discard the archive and lose the entire file); * MAX_FILES now bounds plain files only. Applying it to the archives is exactly what would keep retention at a few hours. Measured on this node's live data 2026-11-27: 18.53x ratio at gzip -9 (17.85x at -6), i.e. 960 MiB holds 72.6 h at the 6.16 GB/day burst sample, 92 h at 4.87 GB/day and ~100 h at the 4.48 GB/day 55-minute average. Verified offline against a replaying fake `hubble` (rotation->archive parity, gzip -t on every archive, atomicity, oldest-first prune, live-file and in-flight protection) and inside the real cilium image under dash (23 rotations -> 23 valid archives, no loss).
102 lines
3.9 KiB
YAML
102 lines
3.9 KiB
YAML
apiVersion: apps/v1
|
|
kind: DaemonSet
|
|
metadata:
|
|
name: hubble-flow-collector
|
|
namespace: netsec
|
|
labels:
|
|
app.kubernetes.io/name: hubble-flow-collector
|
|
app.kubernetes.io/part-of: netsec
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: hubble-flow-collector
|
|
updateStrategy:
|
|
type: RollingUpdate
|
|
rollingUpdate:
|
|
maxUnavailable: 1
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: hubble-flow-collector
|
|
app.kubernetes.io/part-of: netsec
|
|
spec:
|
|
# Phase 1: siriussec only. It is the node that runs every public
|
|
# workload and the one whose egress/extrusion signal matters; rpi and
|
|
# the volatile linode node must not be load-bearing for this. Widening
|
|
# is a one-line change once the consumer (the netsec sensor) needs it.
|
|
nodeSelector:
|
|
kubernetes.io/hostname: siriussec
|
|
# Nothing here talks to the API server.
|
|
automountServiceAccountToken: false
|
|
terminationGracePeriodSeconds: 10
|
|
containers:
|
|
- name: collector
|
|
# Exactly the image the Cilium agent on this node runs: same hubble
|
|
# binary, same protobuf, no version skew with the flow API. Never
|
|
# :latest, never a different minor.
|
|
image: quay.io/cilium/cilium:v1.20.1@sha256:ae9ea21f7427fe24bc6ea7247eb552157a1b0a431744045d3f641545ca71d11b
|
|
imagePullPolicy: IfNotPresent
|
|
command: ["/bin/sh", "/scripts/collect.sh"]
|
|
# hubble.sock on the host is `srw-rw---- root root` (0660, root-owned),
|
|
# so the container MUST run as uid 0 to connect to it. That is the only
|
|
# reason for root here: the mount set is one read-only unix socket plus
|
|
# one writable log directory, no capabilities, no API token, not
|
|
# privileged.
|
|
securityContext:
|
|
runAsUser: 0
|
|
runAsGroup: 0
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop: ["ALL"]
|
|
seccompProfile:
|
|
type: RuntimeDefault
|
|
env:
|
|
- name: DATA_DIR
|
|
value: /data
|
|
- name: SOCK
|
|
value: /var/run/cilium/hubble.sock
|
|
# MAX_FILES bounds PLAIN .jsonl files (the live one plus leftovers
|
|
# from a restart). Rotated files are gzip'd (~17.9x measured) and
|
|
# bounded by MAX_TOTAL_BYTES, the whole-directory ceiling (archives
|
|
# included) that stays inside the 1 GiB spec cap.
|
|
- name: MAX_FILE_BYTES
|
|
value: "157286400"
|
|
- name: MAX_FILES
|
|
value: "6"
|
|
- name: MAX_TOTAL_BYTES
|
|
value: "1006632960"
|
|
resources:
|
|
# Honest and small: a `hubble observe --follow` client plus mawk at
|
|
# ~20 kept events/s. Requests keep it off the top of the eviction
|
|
# list on a node that has hit DiskPressure before; no CPU limit so
|
|
# a burst cannot throttle the writer, a memory limit so a leak
|
|
# cannot hurt etcd's neighbour.
|
|
requests:
|
|
cpu: 50m
|
|
memory: 64Mi
|
|
limits:
|
|
memory: 192Mi
|
|
volumeMounts:
|
|
# SINGLE FILE, never /var/run/cilium: that directory also holds
|
|
# cilium.sock, which is full datapath admin for the whole cluster.
|
|
- name: hubble-sock
|
|
mountPath: /var/run/cilium/hubble.sock
|
|
readOnly: true
|
|
- name: flow-log
|
|
mountPath: /data
|
|
- name: scripts
|
|
mountPath: /scripts
|
|
readOnly: true
|
|
volumes:
|
|
- name: hubble-sock
|
|
hostPath:
|
|
path: /var/run/cilium/hubble.sock
|
|
type: Socket
|
|
- name: flow-log
|
|
hostPath:
|
|
path: /var/log/netsec
|
|
type: DirectoryOrCreate
|
|
- name: scripts
|
|
configMap:
|
|
name: hubble-flow-collector-scripts
|
|
defaultMode: 0555
|