apps(netsec): hubble-flow-collector DaemonSet — filtered flow capture on siriussec
Phase 1a of the netsec program. A long-lived hubble observe consumer (the agent ring buffer is ~28s at 148 flows/s, so polling is lossy), server-side filtered to drop/policy-verdict/l7/trace:to-network, post-filtered so only drop, denial, L7 and to-world peers (outside 10.244.0.0/16 + 10.10.0.0/24) reach disk. Bounded at <=6 files x 150 MiB = 900 MiB under the 1 GiB cap, oldest deleted first, enforced by the writer itself. The socket is mounted as a single file (/var/run/cilium/hubble.sock); the directory would hand over cilium.sock, i.e. cluster datapath admin. Image is the agent's own digest, no version skew. No Service, no HTTPRoute, no Gateway port: node-local writer, root-owned /var/log/netsec is the only host write.
This commit is contained in:
parent
696edddcaf
commit
b36e129c7e
6 changed files with 290 additions and 0 deletions
100
apps/base/netsec/daemonset.yaml
Normal file
100
apps/base/netsec/daemonset.yaml
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
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
|
||||
# 6 files x 150 MiB = 900 MiB ceiling, inside the 1 GiB spec cap;
|
||||
# MAX_TOTAL_BYTES is the second, independent bound.
|
||||
- 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
|
||||
Loading…
Reference in a new issue