Container Networking Observability Toolkit (CNOKit)
Overview
CNOKit is an open-source toolkit designed for comprehensive observability of containerized networking in Kubernetes clusters. It correlates three data sources for a unified view:
eBPF Flow Logs : L3/L4 packet-level flows (e.g., connections, bytes transferred, drops) with zero-overhead tracing.
Service Mesh Data : L7 metrics, traces, and logs (e.g., HTTP/gRPC latencies, error rates, retries) from meshes like Istio or Linkerd.
Policy Annotations : Kubernetes/Cilium network policies, security contexts, and custom annotations for compliance monitoring and enforcement visualization.
Goals :
End-to-end visibility from pod-to-pod, pod-to-external, and service-level traffic.
Correlation of flows, application-layer events, and policy impacts (e.g., "Why was this flow dropped?").
Real-time dashboards, alerting, and root-cause analysis.
Minimal overhead (<1% CPU) via eBPF and sampling.
Target Environments : Kubernetes 1.25+, supports multi-cluster federation.
Architecture
code Copy code
[Kubernetes Cluster(s)]
├── Pods/Services (with annotations & sidecars)
│
├── eBPF Agents (DaemonSet: Cilium/Hubble or custom)
│ ↓ Flow Logs (L3/L4: srcIP:port → dstIP:port, bytes, drops)
│
├── Service Mesh Sidecars/Proxies (Istio Envoy/Linkerd)
│ ↓ Telemetry (L7: paths, latencies, traces via Prometheus/Zipkin)
│
├── Policy Watcher (Deployment: watches CRDs/Annotations)
↓ Metadata (policies matching flows: allow/deny rules)
↓ OTLP/gRPC →
[Central Collector (Deployment/StatefulSet)]
├── Ingestion Layer (OpenTelemetry Collector + Kafka/Redis Streams)
├── Correlation Engine (Rust/Go: joins flows by 5-tuple + timestamps)
├── Enrichment (adds pod labels, service names, policy refs)
↓
[Storage Layer]
├── Metrics: Prometheus + Thanos (long-term)
├── Logs/Traces: ClickHouse (flows) + Jaeger/Elastic (L7)
├── Events: Kafka (policy changes)
↓
[Query/UI Layer]
├── Dashboards: Grafana + Loki
├── API: GraphQL (custom queries like "top dropped flows by policy")
├── Alerts: Prometheus Alertmanager + Slack/PagerDuty
Core Components
eBPF Flow Collector (ebpf-flow-agent)
Tech : Cilium eBPF (or Falco/Tetragon for generic).
Captures : TCP/UDP/ICMP flows, DNS queries, socket stats, XDP drops.
Output : Hubble Relay format (protobuf: Flow{verdict, bytes, packets, l7:{proto,command}}).
Deployment : DaemonSet per node, privileged (hostNetwork: true).
Sampling : Adaptive (100% for drops, 1-10% for high-volume).
Service Mesh Integrator (mesh-telemetry-agent)
Tech : OpenTelemetry Collector with Istio/Linkerd receivers.
Captures : Envoy stats (prometheus.scrape), access logs (stdout), traces (Zipkin/OTLP).
Enhancements : Injects mesh metadata (e.g., virtual service routes) into traces.
Deployment : As init-container or sidecar mutator webhook.
Policy Annotation Parser (policy-watcher)
Tech : K8s Informer + controller-runtime.
Watches : NetworkPolicy, CiliumNetworkPolicy, PodSecurityPolicy annotations (e.g., networking.cilium.io/policy).
Outputs : Policy graph (JSON: selectors → rules) indexed by pod labels/IP.
Features : Simulates "what-if" policy matches for flows; detects violations (e.g., unauthorized L7 paths).
Deployment : Deployment with RBAC for list/watch on policies/pods.
Correlation Engine (cnokit-processor)
Core Logic : Stateful stream processor (Apache Flink or custom Go with temporal joins).
Join Keys : 5-tuple (src/dst IP:port, proto) + timestamp window (±500ms).
Enrichments :
Flow Attr Mesh Attr Policy Attr bytes/pkts HTTP status, latency p50/p99 rule: allow/deny, selector drop reason retry count, circuit breaker violation score
Unified Event Schema (Protobuf/OTLP):
Key Features
Visual Network Topology : Grafana + Grafana Graph (nodes: pods/services, edges: flows colored by policy/mesh health).
Flow Drill-Down : Trace a flow ID across L3→L7→policy (e.g., "Dropped SYN due to NetworkPolicy X, no mesh retry").
Policy Compliance Dashboard : Heatmap of enforced vs. violated rules; auto-generated reports.
Latency Waterfall : Correlate eBPF RTT with mesh proxy delays.
Alerting : "High drop rate on policy Y" or "L7 errors without L4 drops → app issue".
Export/Integrations : Loki for logs, VictoriaMetrics for metrics, SLO computation.
Tech Stack Summary
Layer Tools Collection eBPF (Cilium 1.14+), OTEL Collector Processing Go/Rust (for engine), Kafka Streams Storage Prometheus/Thanos, ClickHouse, Jaeger Viz/Alerts Grafana 10+, Alertmanager API GraphQL (Apollo) + WebAssembly plugins
Overhead : eBPF ~0.5% CPU/node; mesh native; policy watcher <0.1%.
Deployment Guide
Helm Chart : Single helm install cnokit . --namespace observability.
yaml Copy code
# values.yaml excerpt
ebpf:
enabled: true
ciliumHubble: true
mesh:
istio: true
linkerd: false
storage:
clickhouse: {replicas: 3}
Prerequisites : Cilium CNI (for eBPF), Istio 1.20+ (optional).
RBAC : ClusterRole with get/list/watch on pods,services,policies.
Multi-Cluster : Thanos Querier + federation via Gossip.
Quickstart :
code Copy code
kubectl apply -f https://github.com/trailblazer-labs/cnokit/releases/latest/download/crd.yaml
helm repo add cnokit https://trailblazer-labs.github.io/cnokit
helm install cnokit cnokit/cnokit
Extensibility & Roadmap
Plugins : Custom eBPF programs via CO-RE; mesh adapters (Consul, AppMesh).
Future : AI-driven root-cause (e.g., LLM summaries of flow anomalies), eBPF L7 parsing.
Repo : Hypothetical github.com/trailblazer-labs/cnokit (MIT license).
This design provides production-grade observability with deep correlation, deployable in minutes. For customizations or PoC, provide cluster details!