Self-Hosted eBPF Runtime Security with Tetragon and Cilium: A Practical Guide
Quick Summary (TL;DR)
- eBPF runtime security lets you observe and block malicious activity at the kernel level—without sidecars, agents in every pod, or ptrace overhead.
- Cilium provides the eBPF dataplane for networking and network policy; Tetragon adds deep process, file, and network observability plus in-kernel enforcement (kill/block) driven by declarative
TracingPolicyCRDs.- Install Tetragon as a Cilium sub-chart (or standalone DaemonSet), author policies, then ship events to your SIEM via stdout → Fluent Bit → Loki/Elastic.
- Expect ~1–2% CPU overhead for typical workloads; tune with event filtering,
matchNamespaces, and selective hooks.- Enforcement is powerful but blunt—start in observe mode, baseline your workloads, then flip to enforcement for high-confidence rules only.
Runtime security used to mean one of two things: an agent burning CPU on every node to trace syscalls, or a static scanner that told you what was wrong last week. eBPF changed the calculus. By attaching small, verified programs directly to kernel hooks, you can watch every execve, open, and socket connect in real time—and, crucially, stop them before they complete—with overhead measured in single-digit percentages.
This guide walks through deploying Tetragon and Cilium on a self-hosted Kubernetes cluster, authoring real policies, wiring up an alerting pipeline, and tuning for production.
Introduction to eBPF Runtime Security
eBPF (extended Berkeley Packet Filter) is a Linux kernel subsystem that runs sandboxed programs in response to events—system calls, tracepoints, kprobes, network packets. The verifier guarantees programs can’t crash the kernel, and the JIT compiler makes them fast.
For security, this means three capabilities that traditional agents struggle to match:
- Kernel-level visibility — see process execution, file access, and network connections regardless of container runtime or language.
- Low overhead — no ptrace, no per-syscall userspace round-trips for filtering.
- In-kernel enforcement — block or kill a process inside the kernel hook, before the syscall returns. This is the differentiator: a malicious binary never gets a chance to run.
Why Tetragon and Cilium?
Cilium is the CNI and eBPF dataplane—load balancing, network policy, and Hubble observability. Tetragon is the security layer: it hooks process, file, and network events and applies enforcement. They share the same eBPF foundation, and Tetragon ships as a first-class Cilium component.
| Capability | Cilium alone | Tetragon (standalone) | Cilium + Tetragon |
|---|---|---|---|
| L3/L4/L7 network policy | ✅ | ❌ | ✅ |
| Process exec observability | ❌ | ✅ | ✅ |
| File access monitoring | ❌ | ✅ | ✅ |
| In-kernel kill/block enforcement | ❌ | ✅ | ✅ |
| Network flow visibility (Hubble) | ✅ | Partial | ✅ |
| Single agent per node | ✅ | ❌ (separate DS) | ✅ (integrated) |
Tetragon vs. Falco: Falco is a mature, rule-rich runtime detector built on syscall streams; it detects well but doesn’t enforce in-kernel. Tetragon enforces natively and integrates tightly with Cilium, but its rule ecosystem is younger. Many teams run both—Tetragon for enforcement, Falco for breadth.
Prerequisites and Cluster Setup
Before installing, verify the foundation:
- Linux kernel 4.18+ with BTF enabled (
/sys/kernel/btf/vmlinuxmust exist). Kernel 5.4+ is strongly recommended for full enforcement and CO-RE support. - Kubernetes 1.24+ (any conformant distribution: kubeadm, k3s, RKE2, Talos).
- Helm 3.x and
kubectlwith cluster-admin. - If replacing an existing CNI, plan a maintenance window—Cilium takes over pod networking.
Check BTF and kernel version on a node:
uname -r
ls -l /sys/kernel/btf/vmlinux # must exist
If BTF is missing, install kernel-devel/linux-headers matching your kernel, or upgrade.
Installing Cilium with Tetragon
The cleanest production path is the integrated install: Cilium as CNI with Tetragon enabled as a sub-chart.
helm repo add cilium https://helm.cilium.io/
helm repo update
helm install cilium cilium/cilium \
--namespace kube-system \
--set kubeProxyReplacement=true \
--set hubble.relay.enabled=true \
--set hubble.ui.enabled=true \
--set tetragon.enabled=true \
--set tetragon.exportStdout=true
Verify both layers are healthy:
kubectl -n kube-system rollout status ds/cilium
kubectl -n kube-system rollout status ds/tetragon
kubectl -n kube-system get pods -l app.kubernetes.io/name=tetragon
You should see one tetragon pod per node. Stream live events to confirm visibility:
kubectl -n kube-system exec -it ds/tetragon -c tetragon -- \
tetra getevents -o compact
Run kubectl run nginx --image=nginx in another terminal and watch the process_exec event appear.
Understanding Tetragon Policies
Tetragon policies are TracingPolicy custom resources. Each defines:
kprobes/tracepoints/uprobes— which kernel hooks to attach.selectors— filters on process name, namespace, binary path, arguments.matchActions— what to do:Post(log),Sigkill,Override,NoPost.
flowchart TD
A[Kernel event: execve / open / connect] --> B{eBPF hook fires}
B --> C{Selector match?}
C -- No --> D[Drop silently, zero userspace cost]
C -- Yes --> E{Action type}
E -- Post --> F[Emit event to userspace / SIEM]
E -- Sigkill --> G[Kill process in-kernel]
E -- Override --> H[Return EPERM to caller]
F --> I[Fluent Bit → Loki / Elastic / SIEM]
The critical design point: filtering happens in the kernel. Events that don’t match a selector never cross into userspace, which is why overhead stays low.
Authoring Process Execution Policies
Start with a high-value rule: detect (and optionally kill) shell execution inside application pods—a classic post-exploitation signal.
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
name: block-shell-in-app
spec:
kprobes:
- call: "security_bprm_check"
syscall: false
args:
- index: 0
type: "string"
selectors:
- matchNamespaces:
- namespace: production
operator: In
matchArgs:
- index: 0
operator: "In"
values:
- "/bin/sh"
- "/bin/bash"
- "/bin/dash"
matchActions:
- action: Sigkill
- action: Post
Apply and test in a staging namespace first:
kubectl apply -f block-shell-in-app.yaml
kubectl -n production exec deploy/myapp -- /bin/sh -c "id"
# Expected: command killed, event logged
Rollout discipline: ship every policy in observe mode first (comment out Sigkill, keep Post), run for 48–72 hours, review the events, then enable enforcement. Blind enforcement breaks legitimate workloads—build scripts, init containers, and debuggers all spawn shells.
Network and File Access Policies
File access: watch for reads of sensitive paths like /etc/shadow or the service account token mount.
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
name: monitor-sensitive-files
spec:
kprobes:
- call: "security_file_permission"
syscall: false
args:
- index: 0
type: "file"
- index: 1
type: "int"
selectors:
- matchArgs:
- index: 0
operator: "Prefix"
values:
- "/var/run/secrets/kubernetes.io/serviceaccount"
matchActions:
- action: Post
Network: detect connections to unexpected destinations, or combine with Cilium CiliumNetworkPolicy for L3/L4 egress restriction. Tetragon’s kprobe on tcp_connect captures the destination address and process identity, letting you alert on egress to non-allowlisted CIDRs—useful for catching C2 callbacks that slip past DNS allowlists.
Pair enforcement with least-privilege: use Cilium network policy to restrict egress, and Tetragon to detect and kill processes attempting forbidden connections.
Alerting and Observability Pipeline
Tetragon exports events via stdout (JSON) or gRPC. The lowest-friction production pipeline is stdout → Fluent Bit DaemonSet → log backend.
graph LR
A[Tetragon eBPF] -->|stdout JSON| B[Fluent Bit DaemonSet]
B -->|filter + enrich| C{Backend}
C --> D[Loki]
C --> E[Elasticsearch]
C --> F[SIEM / Splunk]
D --> G[Grafana alerts]
E --> H[Kibana dashboards]
A minimal Fluent Bit config shipper:
[INPUT]
Name tail
Path /var/log/pods/kube-system_tetragon-*/tetragon/*.log
Parser json
Tag tetragon.*
[FILTER]
Name grep
Match tetragon.*
Regex process_exec|process_kprobe
[OUTPUT]
Name loki
Match tetragon.*
Host loki.monitoring.svc
Port 3100
Labels job=tetragon,node=$NODE_NAME
Then alert in Grafana on high-signal patterns (shell in production, writes to /etc, exec from /tmp). For richer routing, use the gRPC export to a collector that enriches events with pod labels and forwards to PagerDuty or Slack.
Performance Trade-offs and Tuning
Tetragon’s overhead is driven by event volume, not node size. A cluster running thousands of execs per minute with broad Post selectors can generate meaningful CPU and log-ingest cost. Measure before you tune.
| Factor | Low overhead | High overhead | Mitigation |
|---|---|---|---|
| Policy breadth | Narrow selectors | Match-all Post | Scope by namespace/process |
| Event rate | <1k/min/node | >100k/min/node | Filter in-kernel via matchArgs |
| Enforcement | Sigkill on rare paths | Kill on every exec | Reserve for high-confidence rules |
| Export | stdout batched | gRPC per-event | Batch + sample in Fluent Bit |
| Hooks | 2–3 kprobes | Dozens of tracepoints | Attach only what you alert on |
Tuning checklist:
- Use
matchNamespacesto excludekube-systemand monitoring namespaces from noisy policies. - Prefer
security_bprm_checkover generic syscall tracepoints—fewer events. - Set Fluent Bit
Mem_Buf_Limitand enablestorage.type filesystemto survive backpressure. - Benchmark with
tetra topand node-levelpidstatbefore and after enabling each policy.
Realistic expectation: 1–2% CPU per node for a well-scoped policy set; poorly scoped rules can hit 5%+ and flood your log pipeline.
Conclusion and Best Practices
eBPF runtime security with Tetragon and Cilium gives you something rare: kernel-level detection and enforcement with production-grade overhead. The winning pattern is disciplined—observe, baseline, enforce narrowly, and iterate.
Best practices:
- Observe before you enforce. Never ship
Sigkillon day one. - Scope every selector. Namespace and process filters keep overhead and noise down.
- Enforce only high-confidence rules (shell in prod, writes to sensitive paths). Detect the rest.
- Version-control your
TracingPolicyCRDs alongside app manifests. - Pair with network policy. Tetragon detects; Cilium restricts. Together they close the loop.
- Monitor the monitor. Alert if the Tetragon DaemonSet loses pods—a silent agent is a blind spot.
FAQ
What is the difference between Tetragon and Cilium? Cilium is the eBPF networking, security, and observability platform (load balancing, network policy, Hubble). Tetragon is the security observability and runtime enforcement tool providing deep kernel visibility and in-kernel enforcement. Tetragon can run standalone or as part of Cilium.
Do I need to replace my existing CNI to use Tetragon? No. Tetragon runs independently as a standalone DaemonSet. Integrating with Cilium adds network policy enforcement and unified observability, but it’s not required.
What kernel version is required for Tetragon? Linux 4.18+ with BTF enabled. Kernel 5.4+ is recommended for full functionality and reliable CO-RE support.
How does Tetragon enforce policies?
eBPF programs attached to kernel hooks (kprobes, tracepoints) evaluate selectors in-kernel. Matching events can trigger Sigkill (kill the process), Override (return EPERM), or Post (log only)—enforcement happens before the syscall completes.
Can Tetragon generate alerts to external systems? Yes. Events export via stdout (JSON) or gRPC. Ship them through Fluent Bit to Loki, Elastic, or a SIEM, and alert in Grafana or your existing detection stack.
What are the performance implications?
Typically under 1–2% CPU for well-scoped policies, thanks to in-kernel filtering. Broad Post selectors on high-event-rate workloads can push higher—tune with namespace filters and targeted hooks.