ebpf-server

SRodi/ebpf-server

3.4

If you are the rightful owner of ebpf-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A Model Context Protocol (MCP) server that uses eBPF to monitor network connections and provide real-time network analytics.

eBPF Network Monitor

CI API Documentation Go Version

A modular eBPF monitoring system with HTTP API server for real-time network and system event monitoring. Supports both VM and Kubernetes deployments with automatic metadata enrichment.

πŸš€ Deployment Options

Kubernetes Deployment (Recommended)

Deploy across your entire Kubernetes cluster with automatic node metadata enrichment:

# Quick deployment with built-in script
./scripts/deploy.sh all --registry your-registry.com

# Or step by step
make docker-build
make docker-push REGISTRY=your-registry.com
make k8s-deploy

πŸ“– - Detailed setup and configuration

Local Testing with Kind

Test the full Kubernetes deployment locally:

# Full automated test
make kind-full-test

# Or step by step:
make kind-cluster-create    # Create local cluster
make kind-deploy           # Deploy to kind cluster  
make kind-integration-test # Run comprehensive tests

To get detailed API documentation for the aggregator, available only in Kubernetes mode see API Aggregator Documentation

VM Deployment (Traditional)

For single-server deployments:

# Install dependencies (Ubuntu/Debian)
sudo apt install -y golang-go clang libbpf-dev linux-headers-$(uname -r)

# Build and run
make build
sudo ./bin/ebpf-server

# Test the API
curl http://localhost:8080/health
curl "http://localhost:8080/api/events?type=connection&limit=10"

πŸ“š Interactive API Documentation - Test APIs in your browser

✨ Key Features

πŸ”„ Dual Deployment Support

  • Kubernetes Mode: DaemonSet + Aggregator architecture for cluster-wide monitoring
  • VM Mode: Traditional single-server deployment
  • Automatic Detection: Seamlessly detects environment and adapts behavior

🏷️ Kubernetes Metadata Enrichment

Events in Kubernetes include rich metadata:

{
  "id": "abc123",
  "type": "connection",
  "k8s_node_name": "worker-node-1",
  "k8s_pod_name": "ebpf-monitor-xyz",
  "k8s_namespace": "ebpf-system",
  ...
}

πŸ—οΈ Scalable Architecture

Kubernetes Mode: Distributed monitoring with centralized aggregation

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Kubernetes Cluster                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚    Node 1   β”‚  β”‚    Node 2   β”‚  β”‚        Node N   β”‚  β”‚
β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚  β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚  β”‚
β”‚  β”‚ β”‚ eBPF    β”‚ β”‚  β”‚ β”‚ eBPF    β”‚ β”‚  β”‚   β”‚ eBPF    β”‚   β”‚  β”‚
β”‚  β”‚ β”‚ Agent   β”‚ β”‚  β”‚ β”‚ Agent   β”‚ β”‚  β”‚   β”‚ Agent   β”‚   β”‚  β”‚
β”‚  β”‚ β”‚+K8s Metaβ”‚ β”‚  β”‚ β”‚+K8s Metaβ”‚ β”‚  β”‚   β”‚+K8s Metaβ”‚   β”‚  β”‚
β”‚  β”‚ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β”‚  β”‚ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β”‚  β”‚   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚         β”‚                β”‚                  β”‚           β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
β”‚                          β”‚                              β”‚
β”‚                    β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”                        β”‚
β”‚                    β”‚   eBPF    β”‚                        β”‚
β”‚                    β”‚ Aggregator│◄─── Unified API        β”‚
β”‚                    β”‚           β”‚                        β”‚
β”‚                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

VM Mode: Modular, interface-based monitoring system

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     eBPF Programs                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Connection  β”‚  β”‚ Packet Drop β”‚  β”‚   Custom    β”‚  β”‚
β”‚  β”‚ Monitor     β”‚  β”‚ Monitor     β”‚  β”‚   Monitors  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”˜  β”‚
└─────────┼─────────────────┼──────────────────┼-β”€β”€β”€β”€β”€β”˜
          β”‚                 β”‚                  β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β–Ό
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β”‚    Event Processing     β”‚
               β”‚   (Manager + Storage)   β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β–Ό
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β”‚       HTTP API          β”‚
               β”‚    (/api/events)        β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“Š Unified Monitoring

  • Cross-Node Correlation: View events across entire Kubernetes cluster
  • Node-Specific Filtering: Query events by specific nodes or pods
  • Aggregated Statistics: Cluster-wide event statistics and metrics
  • Backward Compatible: Existing VM deployments continue unchanged

πŸ“‘ API Features

  • Unified Event API: Single /api/events endpoint for all monitoring data
  • Flexible Filtering: Filter by event type, PID, command, and time windows
  • Kubernetes Filtering: Filter by node name, pod name, or namespace
  • Program Status: View program status and metrics via /api/programs
  • Auto-Generated Documentation: OpenAPI 3.0 spec from code annotations
  • Interactive Testing: Built-in Swagger UI for API exploration

Core Endpoints

  • GET /health - System health and status
  • GET /api/events - Query events with filtering support
  • GET /api/programs - List all programs and their status

Query Examples

# Get all connection events from the last hour
curl "http://localhost:8080/api/events?type=connection&since=2023-01-01T00:00:00Z"

# Get events for a specific process
curl "http://localhost:8080/api/events?pid=1234&limit=50"

# Kubernetes: Get events from specific node
curl "http://localhost:8080/api/events?k8s_node_name=worker-1"

Query Parameters

  • type: Event type filter (e.g., "connection", "packet_drop")
  • pid: Process ID filter
  • command: Command name filter
  • k8s_node_name, k8s_pod_name, k8s_namespace: Kubernetes filters
  • since, until: RFC3339 timestamp filters
  • limit: Maximum results (default: 100)

πŸ› οΈ Development

# Development build with debug logging
make build-dev && sudo ./bin/ebpf-server-dev

# Generate API docs
make docs

# Run tests
make test

# Build eBPF programs
make build-bpf

πŸ“š - Detailed guide for creating new eBPF monitoring programs

πŸ“ Project Structure

β”œβ”€β”€ cmd/                 # Application entry points
β”‚   β”œβ”€β”€ server/         # eBPF monitoring server
β”‚   └── aggregator/     # Kubernetes aggregator
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ core/          # Core interfaces and types
β”‚   β”œβ”€β”€ events/        # Event system (BaseEvent, streams)
β”‚   β”œβ”€β”€ programs/      # eBPF program implementations
β”‚   β”œβ”€β”€ storage/       # Event storage and querying
β”‚   β”œβ”€β”€ api/          # HTTP API handlers
β”‚   β”œβ”€β”€ kubernetes/   # Kubernetes metadata integration
β”‚   └── system/       # System initialization
β”œβ”€β”€ bpf/              # eBPF C programs and headers
β”œβ”€β”€ kubernetes/       # Kubernetes manifests
β”œβ”€β”€ scripts/          # Deployment and testing scripts
└── docs/            # Documentation and API specs

πŸ”§ Requirements

  • Linux kernel 4.18+ with eBPF support
  • Root privileges for eBPF program loading
  • Dependencies: Go 1.23+, Clang, libbpf-dev, kernel headers
  • Kubernetes: 1.20+ (for K8s deployment)

πŸ“– Setup Guide:

πŸ“„ License

MIT License - see file.