|
| 1 | +# Retina - eBPF Network Observability Platform |
| 2 | + |
| 3 | +Retina is a cloud-agnostic, open-source Kubernetes network observability platform that provides centralized monitoring for application health, network health, and security. Built with Go, eBPF, and container technologies for Linux and Windows environments. |
| 4 | + |
| 5 | +Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here. |
| 6 | + |
| 7 | +## Working Effectively |
| 8 | + |
| 9 | +### Environment Setup |
| 10 | +- Install required dependencies: |
| 11 | + - `sudo apt update && sudo apt install -y clang llvm-strip-18 jq` |
| 12 | + - `sudo ln -sf /usr/bin/llvm-strip-18 /usr/bin/llvm-strip` (if needed) |
| 13 | +- Go 1.24.6+ required (check with `go version`) |
| 14 | +- Docker and Helm required for container operations |
| 15 | +- `clang` and `llvm-strip` are CRITICAL for eBPF compilation |
| 16 | + |
| 17 | +### Core Build Commands |
| 18 | +- `make retina` -- builds retina binary -- takes ~1 minute (includes eBPF generation). NEVER CANCEL. Set timeout to 10+ minutes. |
| 19 | +- `make retina-capture-workload` -- builds capture workload binary -- takes ~2 seconds |
| 20 | +- CLI: `cd cli && go build -o ../output/linux_amd64/retina/kubectl-retina .` -- takes ~6 seconds |
| 21 | +- `make clean` -- clean build artifacts -- takes < 1 second |
| 22 | + |
| 23 | +### Testing and Validation |
| 24 | +- `make test` -- runs full test suite -- takes 10+ minutes. NEVER CANCEL. Set timeout to 20+ minutes. |
| 25 | +- Basic package tests: `go test -timeout 10m -tags=unit ./pkg/...` -- takes ~6 minutes with some expected failures in cross-platform code |
| 26 | +- `make fmt` -- format code -- takes ~1 second |
| 27 | +- `make lint` -- runs linting -- takes ~2-3 minutes. May show some issues in generated mock files that can be ignored. |
| 28 | + |
| 29 | +### BPF Generation and Plugins |
| 30 | +- BPF generation for current architecture works: generates `.o` and `.go` files for eBPF programs |
| 31 | +- Cross-compilation (ARM64) may fail in development environment - this is expected |
| 32 | +- Plugin test example: `cd test/plugin && make test-packetforward` -- builds and runs plugin tests with sudo |
| 33 | +- Individual plugins can be tested but require network traffic to show meaningful data |
| 34 | + |
| 35 | +## Validation Scenarios |
| 36 | + |
| 37 | +### Basic Functionality Validation |
| 38 | +Always test these core workflows after making changes: |
| 39 | + |
| 40 | +1. **Build and run agent**: |
| 41 | + ```bash |
| 42 | + make retina |
| 43 | + ./output/linux_amd64/retina/retina --help |
| 44 | + ``` |
| 45 | + |
| 46 | +2. **Build and test CLI**: |
| 47 | + ```bash |
| 48 | + cd cli && go build -o ../output/linux_amd64/retina/kubectl-retina . |
| 49 | + ./output/linux_amd64/retina/kubectl-retina --help |
| 50 | + ./output/linux_amd64/retina/kubectl-retina version |
| 51 | + ``` |
| 52 | + |
| 53 | +3. **Test plugin functionality**: |
| 54 | + ```bash |
| 55 | + cd test/plugin && make test-packetforward |
| 56 | + # This will run until Ctrl+C - expect to see "Start collecting packet forward metrics" |
| 57 | + ``` |
| 58 | + |
| 59 | +## Critical Build Timing and Warnings |
| 60 | + |
| 61 | +### NEVER CANCEL - Build Time Expectations |
| 62 | +- **Main binary build (`make retina`)**: Takes 1-2 minutes including eBPF generation. NEVER CANCEL. Use timeout 10+ minutes. |
| 63 | +- **Full test suite (`make test`)**: Takes 10-15 minutes. NEVER CANCEL. Use timeout 20+ minutes. |
| 64 | +- **Linting (`make lint`)**: Takes 2-3 minutes. NEVER CANCEL. Use timeout 5+ minutes. |
| 65 | +- **Plugin tests**: Can run indefinitely waiting for network traffic - this is expected behavior. |
| 66 | + |
| 67 | +### Expected Build Issues |
| 68 | +- Cross-compilation for ARM64 may fail with "exec format error" - this is expected in development environment |
| 69 | +- Some unit tests fail due to missing kubebuilder/etcd dependencies - this is expected |
| 70 | +- Lint warnings about generated mock files are expected and can be ignored |
| 71 | +- BPF compilation warnings about operator precedence are expected and harmless |
| 72 | + |
| 73 | +## Project Structure |
| 74 | + |
| 75 | +### Key Directories |
| 76 | +- `/pkg/plugin/` - eBPF plugins for network observability (conntrack, dropreason, packetforward, etc.) |
| 77 | +- `/controller/` - Main retina agent controller code |
| 78 | +- `/cli/` - kubectl-retina CLI implementation |
| 79 | +- `/captureworkload/` - Network capture workload implementation |
| 80 | +- `/operator/` - Kubernetes operator code |
| 81 | +- `/test/plugin/` - Individual plugin test utilities |
| 82 | +- `/docs/08-Contributing/02-development.md` - Detailed development guide |
| 83 | + |
| 84 | +### Important Files |
| 85 | +- `Makefile` - Primary build system with comprehensive targets |
| 86 | +- `go.mod` - Go 1.24.6, extensive Kubernetes and eBPF dependencies |
| 87 | +- `.devcontainer/` - GitHub Codespaces configuration with required tools |
| 88 | +- `.github/workflows/` - CI/CD pipelines for testing and building |
| 89 | + |
| 90 | +## Common Development Tasks |
| 91 | + |
| 92 | +### Before Committing Changes |
| 93 | +Always run these commands before pushing: |
| 94 | +1. `make fmt` - Format code (required for CI) |
| 95 | +2. `make lint` - Check code quality (may show expected warnings) |
| 96 | +3. `make retina` - Ensure main binary builds correctly |
| 97 | +4. Test CLI: `cd cli && go build .` - Ensure CLI builds |
| 98 | + |
| 99 | +### Working with eBPF Code |
| 100 | +- eBPF source files are in `pkg/plugin/*/\_cprog/` directories |
| 101 | +- Generated files: `*_bpfel_x86.o` and `*_bpfel_x86.go` |
| 102 | +- BPF generation happens automatically during build |
| 103 | +- Some compiler warnings about operator precedence are expected and harmless |
| 104 | + |
| 105 | +### Container and Helm Operations |
| 106 | +- `make retina-image` - Build container image (requires registry access) |
| 107 | +- Images are published to GHCR (GitHub Container Registry) |
| 108 | +- Helm charts are available in the repository for deployment |
| 109 | +- Full deployment requires Kubernetes cluster with appropriate permissions |
| 110 | + |
| 111 | +## Debugging and Troubleshooting |
| 112 | + |
| 113 | +### Common Issues |
| 114 | +- **"exec format error"**: Usually cross-compilation issue, rebuild for current arch |
| 115 | +- **Missing kubebuilder**: Some tests require Kubernetes test environment |
| 116 | +- **Plugin tests hanging**: Normal behavior - plugins wait for network traffic |
| 117 | +- **Lint failures**: Check if they're in generated mock files (can be ignored) |
| 118 | +- **BPF compilation warnings**: Expected and generally harmless |
| 119 | + |
| 120 | +### Log Analysis |
| 121 | +- Agent logs provide detailed eBPF and networking information |
| 122 | +- CLI operations are verbose and show capture job creation details |
| 123 | +- Plugin tests show real-time network metrics when traffic is available |
| 124 | + |
| 125 | +This is a complex, enterprise-grade networking platform. Take time to understand the eBPF integration and Kubernetes-native architecture before making changes. |
0 commit comments