|
| 1 | +--- |
| 2 | +title: "Hubble Functionality Guide" |
| 3 | +date: 2025-10-27T15:48:47+08:00 |
| 4 | +draft: false |
| 5 | +description: "" |
| 6 | +tags: ["Cilium", "Hubble", "Architecture"] |
| 7 | +categories: ["Observability", "Service Mesh"] |
| 8 | +author: "Shawn Zhang" |
| 9 | +showToc: true |
| 10 | +TocOpen: false |
| 11 | +hidemeta: false |
| 12 | +comments: false |
| 13 | +disableHLJS: false |
| 14 | +disableShare: false |
| 15 | +searchHidden: false |
| 16 | +cover: |
| 17 | + image: "https://github.com/cilium/hubble/blob/main/Documentation/images/hubble_logo.png?raw=true" |
| 18 | + alt: "" |
| 19 | + caption: "" |
| 20 | + relative: false |
| 21 | + hidden: true |
| 22 | +--- |
| 23 | + |
| 24 | +Hubble is Cilium's **observability platform** built on top of eBPF for network visibility and monitoring. |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +## Components Overview |
| 29 | + |
| 30 | +### 1. Hubble (in Cilium Agent) |
| 31 | + |
| 32 | +**Location:** Runs inside each Cilium pod (DaemonSet on every node) |
| 33 | + |
| 34 | +**Functionality:** |
| 35 | +- **Captures network flows** using eBPF at the kernel level |
| 36 | +- **Monitors all pod-to-pod traffic** on that node |
| 37 | +- **Collects metadata**: source/dest IPs, ports, protocols, HTTP methods, DNS queries |
| 38 | +- **Stores flows in memory** (ring buffer) |
| 39 | +- **Exposes gRPC API** on port 4244 for querying flows |
| 40 | + |
| 41 | +**What it sees:** |
| 42 | +``` |
| 43 | +Pod A → Pod B (HTTP GET /api) |
| 44 | +Pod C → External IP (TCP SYN) |
| 45 | +Pod D ← DNS response |
| 46 | +Network policy DROPPED packets |
| 47 | +``` |
| 48 | + |
| 49 | +### 2. Hubble Relay |
| 50 | + |
| 51 | +**Deployment:** Single pod aggregating cluster-wide data |
| 52 | + |
| 53 | +**Functionality:** |
| 54 | +- **Aggregates flows** from all Cilium agents across all nodes |
| 55 | +- **Single query endpoint** - you query Relay, it queries all nodes |
| 56 | +- **Provides cluster-wide view** of network traffic |
| 57 | +- **Handles TLS** between itself and Cilium agents |
| 58 | +- **Exposes gRPC API** on port 4245 |
| 59 | + |
| 60 | +**Architecture:** |
| 61 | +``` |
| 62 | +hubble CLI/UI |
| 63 | + ↓ |
| 64 | +Hubble Relay (port 80/4245) |
| 65 | + ↓ |
| 66 | + ┌──┴──┬──────┬──────┐ |
| 67 | + ↓ ↓ ↓ ↓ |
| 68 | +Node1 Node2 Node3 Node4 |
| 69 | +(Cilium agents with Hubble on port 4244) |
| 70 | +``` |
| 71 | + |
| 72 | +**Why it's needed:** |
| 73 | +- Without Relay: You'd need to query each node individually |
| 74 | +- With Relay: Single query gets flows from entire cluster |
| 75 | + |
| 76 | +### 3. Hubble UI |
| 77 | + |
| 78 | +**Deployment:** Single pod with 2 containers |
| 79 | + |
| 80 | +**Containers:** |
| 81 | +- **Frontend:** Web UI (React app) |
| 82 | +- **Backend:** API server that talks to Hubble Relay |
| 83 | + |
| 84 | +**Functionality:** |
| 85 | +- **Visual service map** - Shows pods/services as nodes, traffic as edges |
| 86 | +- **Real-time flow visualization** - Green (allowed), red (denied) |
| 87 | +- **Filtering** - By namespace, pod, verdict, protocol |
| 88 | +- **Flow details** - Click on connections to see packet details |
| 89 | +- **Network policy visualization** - See what's allowed/blocked |
| 90 | + |
| 91 | +**What you see:** |
| 92 | +``` |
| 93 | +Service Map: |
| 94 | + frontend ──(green)──> backend |
| 95 | + backend ──(green)──> database |
| 96 | + attacker ──(red X)──> backend (policy denied) |
| 97 | +``` |
| 98 | + |
| 99 | +### 4. Hubble Services |
| 100 | + |
| 101 | +**hubble-peer (ClusterIP:443)** |
| 102 | +- Used by Hubble Relay to discover Cilium agents |
| 103 | +- Peer service for node-to-node communication |
| 104 | + |
| 105 | +**hubble-relay (ClusterIP:80)** |
| 106 | +- Entry point for Hubble CLI and UI |
| 107 | +- Aggregates data from all nodes |
| 108 | + |
| 109 | +**hubble-ui (ClusterIP:80)** |
| 110 | +- Web interface access point |
| 111 | +- Serves the UI frontend |
| 112 | + |
| 113 | +## Data Flow |
| 114 | + |
| 115 | +``` |
| 116 | +1. Network packet arrives at node |
| 117 | + ↓ |
| 118 | +2. eBPF captures packet metadata (Cilium agent) |
| 119 | + ↓ |
| 120 | +3. Hubble (in Cilium) stores flow in memory |
| 121 | + ↓ |
| 122 | +4. Hubble Relay queries all Cilium agents |
| 123 | + ↓ |
| 124 | +5. Hubble UI/CLI queries Relay |
| 125 | + ↓ |
| 126 | +6. You see network flows! |
| 127 | +``` |
| 128 | + |
| 129 | +## What Hubble Captures |
| 130 | + |
| 131 | +### Layer 3/4 |
| 132 | +- Source/destination IPs and ports |
| 133 | +- Protocols (TCP, UDP, ICMP) |
| 134 | +- Packet verdicts (forwarded, dropped, denied) |
| 135 | + |
| 136 | +### Layer 7 (Application) |
| 137 | +- **HTTP:** methods, paths, status codes |
| 138 | +- **DNS:** queries and responses |
| 139 | +- **Kafka:** topics and messages |
| 140 | +- **gRPC:** methods and status |
| 141 | + |
| 142 | +### Security |
| 143 | +- Network policy enforcement |
| 144 | +- Identity-based access control |
| 145 | +- Dropped/denied connections |
| 146 | + |
| 147 | +### Performance |
| 148 | +- Latency metrics |
| 149 | +- Connection tracking |
| 150 | +- Flow rates |
| 151 | + |
| 152 | +## Use Cases |
| 153 | + |
| 154 | +### 1. Troubleshooting |
| 155 | +```bash |
| 156 | +# Why can't Pod A reach Pod B? |
| 157 | +hubble observe --from-pod default/podA --to-pod default/podB |
| 158 | +``` |
| 159 | + |
| 160 | +### 2. Security Monitoring |
| 161 | +```bash |
| 162 | +# What's being blocked? |
| 163 | +hubble observe --verdict DROPPED |
| 164 | + |
| 165 | +# Watch denied traffic in real-time |
| 166 | +hubble observe --verdict DROPPED --follow |
| 167 | +``` |
| 168 | + |
| 169 | +### 3. Service Dependencies |
| 170 | +```bash |
| 171 | +# What does my frontend talk to? |
| 172 | +hubble observe --from-pod default/frontend |
| 173 | + |
| 174 | +# See all traffic in a namespace |
| 175 | +hubble observe --namespace default |
| 176 | +``` |
| 177 | + |
| 178 | +### 4. Compliance |
| 179 | +- Network flow logs for auditing |
| 180 | +- Policy enforcement verification |
| 181 | +- Traffic pattern analysis |
| 182 | + |
| 183 | +## Common Commands |
| 184 | + |
| 185 | +```bash |
| 186 | +# Check Hubble status |
| 187 | +hubble status |
| 188 | + |
| 189 | +# Watch all flows in real-time |
| 190 | +hubble observe --follow |
| 191 | + |
| 192 | +# Filter by namespace |
| 193 | +hubble observe --namespace kube-system |
| 194 | + |
| 195 | +# Filter by verdict |
| 196 | +hubble observe --verdict FORWARDED |
| 197 | +hubble observe --verdict DROPPED |
| 198 | + |
| 199 | +# Filter by pod |
| 200 | +hubble observe --from-pod default/frontend --to-pod default/backend |
| 201 | + |
| 202 | +# Show last N flows |
| 203 | +hubble observe --last 20 |
| 204 | + |
| 205 | +# Open Hubble UI |
| 206 | +cilium hubble ui |
| 207 | +``` |
| 208 | + |
| 209 | +## Component Summary |
| 210 | + |
| 211 | +| Component | Purpose | You Interact With | |
| 212 | +|-----------|---------|-------------------| |
| 213 | +| Hubble (in Cilium) | Captures flows on each node | No (automatic) | |
| 214 | +| Hubble Relay | Aggregates cluster-wide flows | Via CLI/UI | |
| 215 | +| Hubble UI | Visual interface | Yes (browser) | |
| 216 | +| hubble CLI | Command-line queries | Yes (terminal) | |
| 217 | + |
| 218 | +## Key Benefits |
| 219 | + |
| 220 | +✅ **No application changes** - eBPF captures at kernel level |
| 221 | +✅ **Low overhead** - Efficient eBPF programs |
| 222 | +✅ **Real-time** - See traffic as it happens |
| 223 | +✅ **Cluster-wide** - Single view across all nodes |
| 224 | +✅ **Deep visibility** - L3-L7 protocol awareness |
| 225 | +✅ **Security insights** - Policy enforcement visibility |
| 226 | +✅ **Troubleshooting** - Debug connectivity issues quickly |
| 227 | + |
| 228 | +## Configuration |
| 229 | + |
| 230 | +Current Hubble settings can be viewed with: |
| 231 | +```bash |
| 232 | +cilium config view | grep -i hubble |
| 233 | +``` |
| 234 | + |
| 235 | +Key settings: |
| 236 | +- `enable-hubble: true` - Hubble enabled |
| 237 | +- `hubble-listen-address: :4244` - gRPC API port |
| 238 | +- `hubble-disable-tls: false` - TLS enabled for security |
| 239 | + |
| 240 | +## Summary |
| 241 | + |
| 242 | +Hubble gives you **network observability superpowers** - see every connection, understand traffic patterns, debug issues, and verify security policies, all without touching your applications! 🔍 |
0 commit comments