service/hubble/README.md
A high-performance monitoring data collection and caching service for Sealos, designed to aggregate and serve network flow metrics from Cilium Hubble with Redis-based caching for optimal performance.
Hubble Service acts as an intermediary layer between Cilium Hubble and frontend applications, providing:
┌─────────────────┐ ┌──────────────┐ ┌─────────────┐
│ Cilium Hubble │────▶│ Hubble │────▶│ Redis │
│ Relay │ │ Service │ │ Cache │
└─────────────────┘ └──────────────┘ └─────────────┘
│
▼
┌──────────────┐
│ Frontend │
│ Applications │
└──────────────┘
git clone https://github.com/labring/sealos.git
cd sealos/service/hubble
Edit config.yml to match your environment:
auth:
whiteList: ["allowed-namespace-1", "allowed-namespace-2"]
http:
addr: ":8080"
hubble:
addr: "hubble-relay.kube-system.svc.cluster.local:80"
redis:
addr: "redis.default.svc.cluster.local:6379"
username: "default"
password: "your-redis-password"
db: 10
Using Docker:
# Build the Docker image
make docker-build IMG=your-registry/hubble-service:latest
# Push to registry
make docker-push IMG=your-registry/hubble-service:latest
# Deploy to Kubernetes
kubectl apply -f deploy/manifests/
Edit deploy/manifests/deploy.yaml with your image and configuration:
spec:
containers:
- name: hubble-service
image: your-registry/hubble-service:latest
env:
- name: HUBBLE_RELAY_ADDR
value: "hubble-relay.kube-system.svc.cluster.local:80"
- name: REDIS_ADDR
value: "redis.default.svc.cluster.local:6379"
kubectl apply -f deploy/manifests/
kubectl get pods -l app=hubble-service
kubectl logs -l app=hubble-service
| Variable | Description | Default |
|---|---|---|
CONFIG_PATH | Path to configuration file | ./config.yml |
HUBBLE_RELAY_ADDR | Hubble Relay service address | hubble-relay.kube-system.svc.cluster.local:80 |
REDIS_ADDR | Redis server address | Required |
REDIS_PASSWORD | Redis authentication password | Optional |
HTTP_PORT | HTTP server listening port | :8080 |
AUTH_WHITELIST | Comma-separated list of allowed namespaces | Optional |
The service can be configured via a YAML file:
auth:
whiteList: [] # List of allowed namespaces
http:
addr: ":8080" # HTTP server address
hubble:
addr: "hubble-relay.kube-system.svc.cluster.local:80"
redis:
addr: "localhost:6379"
username: "default"
password: ""
db: 10
GET /health
Returns service health status
GET /api/v1/flows
Returns cached network flow data
GET /api/v1/metrics/namespace/{namespace}
Returns metrics for a specific namespace
go mod download
# Start Redis locally
docker run -d -p 6379:6379 redis
# Run the service
go run cmd/main.go -config=config.yml
go test ./...
# Build binary
go build -o hubble-service cmd/main.go
# Build with specific version
go build -ldflags="-X main.version=v1.0.0" -o hubble-service cmd/main.go
The service exposes internal metrics that can be scraped by Prometheus:
hubble_collector_flows_total - Total number of flows collectedhubble_cache_hits_total - Cache hit ratehubble_cache_misses_total - Cache miss ratehubble_api_requests_total - API request counthubble_api_request_duration_seconds - API request latencyCannot connect to Hubble Relay
kubectl get svc -n kube-system hubble-relayRedis connection errors
No data returned from API
Enable debug logging by setting the environment variable:
LOG_LEVEL=debug
We welcome contributions! Please see CONTRIBUTING.md for details.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)Copyright 2023 Sealos Contributors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
For issues and questions: