How alibaba/kubeskoop works
Main Components
• BPF Programs & Kernel Probes: Represent the low‐level eBPF programs (located in the “bpf” directory) that are built to monitor and capture kernel networking events. These include various C programs (flow.c, kprobe.c, etc.) and supporting header files.
• Controller/Orchestrator: Components under “cmd/controller” and related packages in “pkg/controller” handle core orchestration tasks such as configuration, database access (with options for MySQL or SQLite), telemetry collection, and interaction with Kubernetes (as seen in the “k8s” packages).
• Collector and Exporter Modules: The “cmd/collector”, “cmd/exporter”, and related packages under “pkg/exporter” implement data collection, event streaming, metric export (including Prometheus metric API and Loki log export), and utilize various probes from the “pkg/exporter/probe” sub-folders.
• BTF Hack Utility: A specialized component (cmd/btfhack and related packages) for handling BTF (BPF Type Format) integration, used to ensure CO-RE scripts work across different kernel versions.
• Web Console/UI: The “webui” directory provides a modern, interactive web-based interface that includes a backend (Go server code under webui/internal) and a frontend (React/TypeScript in webui/src) for user-friendly diagnosis, visualization (network graphs, dashboards), and interaction.
• RPC Communication and Messaging: The presence of “rpc” directories and protobuf definitions indicates internal communication between components (e.g., controller and exporter) via gRPC or similar RPC frameworks.
• Deployment/Configuration: The “deploy” directory with Helm charts, Kubernetes YAML manifests, and Vagrant scripts shows how the system is packaged and deployed in a real Kubernetes cluster.
Relationships and Interactions
• The Web Console (UI) interacts with backend services (controller and exporter) through defined API endpoints and possibly gRPC. Users initiate diagnostic or monitoring requests via the web interface.
• The Controller communicates with the Kubernetes APIs (using “pkg/controller/k8s”) to fetch cluster state and to trigger network diagnosis/pings or even reconfigure network probes.
• The Exporter modules deploy and manage eBPF programs (from the “bpf” directory via “pkg/exporter”) to capture real-time kernel events and network metrics. These are then forwarded to external systems like Prometheus and Loki.
• The BPF-based network probes send network events and metrics to the controller and exporters, which process the data and store it (in local databases, as seen with MySQL/sqlite DDLs).
• There is also an inter-component communication layer (using RPC, as defined in “pkg/controller/rpc” and the “rpc” folder) for sharing information like IP cache and alert events.
Architectural Patterns and Design Principles
• Separation of Concerns: The project separates responsibilities into discrete components (controller, exporter, collector, probe modules, web UI) that interact via defined interfaces.
• Microservices or Modular Design: Although deployed together in Kubernetes, the distinct “cmd” components suggest a modular approach that can be updated or scaled independently.
• Use of gRPC/RPC: Encapsulates communication between backend modules.
• Integration with Cloud and Kubernetes Services: The design includes k8s informers, IaaS integrations (e.g., in “pkg/skoop/infra/aliyun”), and deployment automation with Helm.
Relevant Technologies, Frameworks, and Libraries
• Language: Go is used extensively (go.mod and go.sum files).
• eBPF & BTF: Core components in the “bpf” folder and BTF hack utilities.
• Web Stack: Modern TypeScript/React frontend (in webui/src) and standard backend server in Go.
• Kubernetes: Native integrations via Kubernetes client libraries and deployment charts.
• Monitoring & Logging: Prometheus (for metrics), Grafana/Loki for logs and dashboards.
• RPC Framework: gRPC defined via protobuf files (inside pkg/controller/rpc and rpc directories).
Elements
• Components with Clear Labels:
• “eBPF Kernel Probes” (bpf programs)
• “Controller & Orchestrator”
• “Collector/Exporter Module”
• “RPC Communication Layer”
• “Web Console/UI”
• “External Integrations” (Kubernetes API, Prometheus, Grafana/Loki)
• Data flow from eBPF probes to Exporter, from Exporter to Controller, and from Controller to the Web UI.
• Bidirectional communication between the Controller and Kubernetes API.
• Flow of diagnostic requests initiated from the Web Console to the backend.
• With Technologies:
• Next to each component, note key technologies (e.g., “Go”, “eBPF”, “gRPC”, “React/TypeScript”, “Helm/Kubernetes”).