For years, the gold standard for Kubernetes security and observability has relied on the sidecar pattern. By injecting a container alongside your application pod, security agents could intercept traffic, parse logs, and inspect local filesystem changes.
However, at cloud scale, the sidecar pattern introduces a significant performance tax. In high-density, multi-tenant clusters running thousands of microservices, sidecars consume massive amounts of CPU and RAM while adding multi-millisecond latency penalties due to user-space context switching and redundant network stack traversals (iptables / Netfilter).
Enter eBPF (Extended Berkeley Packet Filter). By running sandboxed, JIT-compiled programs directly within the Linux kernel, eBPF allows us to observe, filter, and trace system calls, network events, and resource allocations with near-zero overhead.
In this post, we’ll analyze why kernel-level eBPF probes surpass traditional sidecars, dive into the architecture of eBPF-driven runtime security, and build a production-ready runtime security pipeline using Cilium and Falco.
The Sidecar Tax vs. Kernel-Native Observability
To understand why eBPF is revolutionary, we must examine what happens under the hood during a traditional sidecar request cycle versus an eBPF probe execution.
The Traditional Sidecar Bottleneck
When using a traditional network or security sidecar (e.g., Envoy or standard agent proxies):
- Traversing User-to-Kernel Boundaries: Packets ingress the network interface, traverse the Linux netfilter layer (
iptables), and hit the container network namespace. - Context Switching: The kernel context-switches to the sidecar proxy in user space to execute security policies, payload inspection, or TLS termination.
- Redundant Copies: Data is copied back and forth between kernel buffers and user-space memory buffers before finally reaching the target application container.
- Resource Multiplication: Every pod requires its own set of sidecar resources. A cluster with 1,000 pods running a 50MB sidecar instantly wastes 50GB of RAM just on security/mesh control planes.
+-----------------------------------------------------------------------+
| USER SPACE |
| +--------------------+ +----------------------+ |
| | App Container | <--- (Loopback) --> | Sidecar Proxy | |
| +--------------------+ +----------------------+ |
+------------^-------------------------------------------|--------------+
| KERNEL | (Socket Copy) | (Socket Copy)|
| +---------v-------------------------------------------v-----------+ |
| | TCP/IP Stack & Netfilter / iptables Rules | |
| +-----------------------------------------------------------------+ |
+------------------------------------^----------------------------------+
| (Ingress Packet)
[ Network Device ]
The eBPF Advantage
eBPF moves the execution logic into the Linux kernel itself via event-driven hooks (kprobes, tracepoints, socket filters, LSM hooks).
+-----------------------------------------------------------------------+
| USER SPACE |
| +--------------------+ +----------------------+ |
| | App Container A | | App Container B | |
| +--------------------+ +----------------------+ |
+------------^-------------------------------------------^--------------+
| KERNEL | | |
| +---------+-------------------------------------------+-----------+ |
| | eBPF Engine (JIT Compiled Probes + Ring Buffers) | |
| | Hooks: Tracepoints | Kprobes | LSM Hooks | XDP / TC | |
| +-----------------------------------------------------------------+ |
+------------------------------------^----------------------------------+
| (Direct Ingress Routing)
[ Network Device ]
- No Pod Injection: Security agents run as a single
DaemonSetper node, operating outside the tenant pod lifecycle. - Direct Event Execution: Probes intercept execution at the kernel boundary (e.g.,
sys_enter_execve,sys_connect). Malicious actions or non-compliant packets are dropped before user-space processing ever occurs. - Shared BPF Maps: State is maintained in lockless eBPF maps in the kernel, accessible by node-level daemons asynchronously via ring buffers, eliminating synchronous user-space blocking.
High-Level Architectural Topology
To achieve comprehensive zero-overhead security, we pair Cilium (for deep network packet control and eBPF host-routing) with Falco (for behavioral kernel-syscall threat detection).
+---------------------------------------+
| Kubernetes API Server |
+------------------+--------------------+
|
(CRDs & Policy Sync)
|
+------------------------------------------------v-----------------------------------------------+
| KUBERNETES NODE |
| |
| [ User Space ] |
| +------------------------+ +-------------------------+ +-------------------------+ |
| | Cilium Agent (Daemon) | | Falco Engine (Daemon) | | FalcoSidekick | |
| +-----------+------------+ +------------+------------+ +------------+------------+ |
| | | ^ |
| (BPF Map Sync) (Ring Buffer Stream) | (Alert Events) |
| | | | |
+--------------v----------------------------v----------------------------+-----------------------+
| [ Kernel Space ] |
| +------------------------------------------------------------------------------------------+ |
| | Linux Kernel (5.15+ / 6.x) | |
| | | |
| | +---------------------+ +--------------------------+ +---------------------------+ | |
| | | XDP / TC Hooks | | Syscall Tracepoints | | Linux Security Mod (LSM) | | |
| | | (Packet Filtering & | | (execve, connect, | | (File Access, Privilege | | |
| | | Host Routing) | | ptrace, setns) | | Escalation Mitigation) | | |
| | +----------+----------+ +------------+-------------+ +-------------+-------------+ | |
| | | | | | |
| | +---------------------------+----------------------------+ | |
| | | | |
| | +---------v----------+ | |
| | | eBPF MAPS / | | |
| | | RING BUFFERS (CO-RE)| | |
| | +--------------------+ | |
| +------------------------------------------------------------------------------------------+ |
+------------------------------------------------------------------------------------------------+
Step-by-Step Implementation Guide
Prerequisites
- Kernel Requirements: Linux kernel
5.15+(preferably6.1+) compiled withCONFIG_DEBUG_INFO_BTF=yto enable BTF (BPF Type Format) for CO-RE (Compile Once – Run Everywhere) capability. - Kubernetes Cluster: v1.26+ cluster without
kube-proxy(or ready to stripkube-proxy).
Step 1: Deploy Cilium with eBPF Host Routing & Kube-Proxy Replacement
Standard Kubernetes networks process traffic using legacy iptables rules managed by kube-proxy. As cluster service counts scale, iptables linear matching rules degraded performance exponentially.
We will deploy Cilium to completely replace kube-proxy, utilizing eBPF host routing to bypass iptables and connect sockets directly at the TC (Traffic Control) and XDP (eXpress Data Path) layers.
Create a Helm override file named cilium-values.yaml:
# cilium-values.yaml
kubeProxyReplacement: true
# Enable modern BPF Host Routing to bypass netfilter iptables completely
bpf:
masquerade: true
clockProbe: true
# Enable eBPF-based socket load balancing for pod-to-pod communications
socketLB:
enabled: true
# Enable Hubble Observability Engine with eBPF probes
hubble:
enabled: true
relay:
enabled: true
ui:
enabled: true
metrics:
enabled:
- dns:query;ignore-AAA
- drop
- tcp
- flow
- icmp
- http
# Enable eBPF Kernel LSM Enforcement
lsm:
enabled: true
# High performance IPVlan or Direct Routing mode (Adjust based on cloud CNI overlay needs)
routingMode: native
autoDirectNodeRoutes: true
Install Cilium via Helm:
helm repo add cilium https://helm.cilium.io/
helm repo update
helm install cilium cilium/cilium \
--namespace kube-system \
--values cilium-values.yaml
Verify that kube-proxy is successfully bypassed and BPF maps are active:
kubectl -n kube-system exec -it ds/cilium -- cilium status --verbose | grep "Kube-Proxy Replacement"
Step 2: Deploy Falco using Modern eBPF Engine
Historically, Falco utilized a custom kernel module or a legacy BPF driver requiring explicit kernel header compilations. We will deploy Falco with the Modern eBPF Driver, which leverages kernel BTF and lockless ring buffers (BPF_MAP_TYPE_RINGBUF) for near-zero CPU footprint and guaranteed non-blocking event collection.
Create a Helm values configuration file falco-values.yaml:
# falco-values.yaml
driver:
kind: modern_ebpf
falco:
# Configure Ring Buffer sizing to handle millions of events without dropping
ebpf:
buf_size_preset: 4 # Allocates optimal ring buffer slots per CPU core
# Direct operational logs and metrics
json_output: true
file_output:
enabled: false
stdout_output:
enabled: true
# Set engine priority level
priority: debug
syslog_output:
enabled: false
# Enable Falcosidekick for async alert routing without kernel queue blocking
falcosidekick:
enabled: true
webui:
enabled: true
Deploy Falco using Helm:
helm repo add falcosecurity https://falcosecurity.github.io/charts
helm repo update
helm install falco falcosecurity/falco \
--namespace falco \
--create-namespace \
--values falco-values.yaml
Check the Falco pod logs to ensure the eBPF probe attached successfully to system call tracepoints:
kubectl logs -n falco -l app.kubernetes.io/name=falco -c falco | grep "Loaded event sources"
Step 3: Crafting Zero-Overhead Threat Detection Rules
Now that our eBPF foundation is set, let me demonstrate how kernel-level tracing catches sophisticated attacks that sidecars completely miss—such as namespace escapes, raw socket creation, and unauthorized shell executions.
Rule 1: Catching Terminal Shell Spawns Inside Production Pods
Sidecars monitor standard HTTP ingress/egress. They cannot observe if an attacker exploits a RCE vulnerability (e.g., Log4Shell) to execute /bin/bash.
Here is a Falco rule written to catch interactive execution using execve tracepoints:
# falco_rules.local.yaml (Custom Ruleset)
customRules:
rules-interactive-shell.yaml: |-
- rule: Terminal Shell In Production Pod
desc: Detects interactive shell execution inside sensitive Kubernetes containers
condition: >
spawned_process and
container and
container.profile.type != "untrusted" and
proc.name in (bash, sh, zsh, ksh, ash) and
proc.tty != 0 and
not k8s.ns.name in (kube-system, monitoring)
output: >
Interactive Shell Spawned (user=%user.name user_loginuid=%user.loginuid
process=%proc.name parent=%proc.pname command=%proc.cmdline
container_id=%container.id container_name=%container.name
image=%container.image.repository:%container.image.tag
namespace=%k8s.ns.name pod=%k8s.pod.name)
priority: CRITICAL
tags: [container, execution, mitre_execution]
Rule 2: Detecting Unauthorized Egress Bypassing Pod Network Stack
Attackers often install custom binary backdoors that attempt to connect using raw sockets. Cilium enforces network layer filtering inside eBPF TC filters.
Combine Cilium Security Policy (CiliumNetworkPolicy) to restrict network access dynamically using eBPF:
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
name: enforce-strict-zero-trust-egress
namespace: production
spec:
endpointSelector:
matchLabels:
app: payment-gateway
ingress:
- fromEndpoints:
- matchLabels:
app: api-router
toPorts:
- ports:
- port: "8443"
protocol: TCP
egress:
# Allow connection only to authorized database endpoint via FQDN
- toFQDNs:
- matchName: "db-cluster.internal.ecstaticloud.com"
toPorts:
- ports:
- port: "5432"
protocol: TCP
# Allow core DNS
- toEndpoints:
- matchLabels:
"k8s:io.kubernetes.pod.namespace": kube-system
k8s-app: kube-dns
toPorts:
- ports:
- port: "53"
protocol: UDP
rules:
dns:
- matchPattern: "*"
Because Cilium processes these rules in the kernel's network driver layer, unauthorized packets are silently dropped before consuming any socket buffer memory or triggering CPU context switches in user space.
Performance Tuning & Avoidable Pitfalls
While eBPF offers unprecedented efficiency, misconfigurations can lead to subtle performance bottlenecks or lost telemetry under extreme workloads.
1. Perf Buffers vs. Ring Buffers
- Legacy
BPF_MAP_TYPE_PERF_EVENT_ARRAY: Allocates a buffer per CPU core. If a single CPU core experiences high load, its buffer can overflow, leading to lost security events even if other core buffers are empty. - Modern
BPF_MAP_TYPE_RINGBUF: Uses a multi-writer, single-reader shared ring buffer across all CPU cores. It features lower memory consumption, atomic reservations, and eliminates lock contention.
Recommendation: Always use modern eBPF driver options (
driver.kind=modern_ebpfin Falco) available on kernel >= 5.8.
2. Resolving BTF (BPF Type Format) Compatibility
If running on custom or enterprise distributions (such as RHEL or AWS Bottlerocket), ensure the host exposes /sys/kernel/btf/vmlinux.
If missing, eBPF probes must fall back to dynamic kernel-header compilation at runtime, introducing container startup delays and CPU spikes.
# Verify BTF support on target node:
ls -la /sys/kernel/btf/vmlinux
If /sys/kernel/btf/vmlinux is missing, you can supply external BTF objects via falcoctl or upgrade your Linux distro image to a release with BTF enabled by default.
3. Tuning Ring Buffer Sizes under High I/O
For heavy workloads (e.g., high-throughput Redis nodes or database clusters), system call generation can exceed millions of calls per second. Monitor buffer drop metrics in Falco:
kubectl logs -n falco -l app.kubernetes.io/name=falco | grep "events dropped"
If event drops occur, increase the buf_size_preset in your falco-values.yaml:
falco:
ebpf:
# Options: 1 (Small), 2 (Medium), 3 (Large), 4 (Extra Large), 5 (Custom)
buf_size_preset: 5
# When preset is 5, manually scale buffer pages per CPU:
custom_buf_size_mb: 16
Conclusion
The era of paying the "sidecar tax" for container security is coming to an end. By moving observability and enforcement down to the Linux kernel using eBPF, platform architects can achieve zero-overhead, deep-packet, and process-level runtime security.
By combining Cilium for network-level host routing and zero-trust isolation with Falco for low-level kernel system call tracing, you build a multi-layered security ecosystem capable of catching container escapes, privilege escalation, and zero-day vulnerabilities in real time—all while keeping your application compute nodes running lean and fast.