A modern, cross-platform Kubernetes port-forward manager with a rich terminal UI, automatic recovery, and built-in update system.
- π¨ Modern Terminal UI: Interactive interface with real-time updates, port display, and keyboard navigation
- π Automatic Recovery: Monitors and automatically restarts failed port-forwards with state tracking
- π Cross-Platform: Works on macOS, Linux, and Windows
- π Smart Monitoring: Health checks with detailed service state management and visual feedback
- ποΈ Service State Visualization: Shows "Connecting" and "Reconnecting" states for better user feedback
- π Context Awareness: Fast detection and response to Kubernetes context changes
- π Auto-Updates: Daily update checks with in-UI notifications
- π― UI Integration: Automated gRPC UI and Swagger UI for API services
- βοΈ Embedded Config: Pre-configured services with user override support
- π High Performance: Optimized for managing 100+ concurrent port-forwards with 4,200x faster config loading
- π Performance Profiling: Built-in CPU and memory profiling tools for performance analysis
The easiest way to install on macOS is with Homebrew:
# Install from Homebrew (preferred SSH method)
brew tap catio-tech/kportforward git@github.com:catio-tech/kportforward.git
brew install kportforward
# Alternative HTTPS method
# brew tap catio-tech/kportforward https://github.com/catio-tech/kportforward
# brew install kportforwardAlternatively, download the latest release for your platform:
# macOS (Intel) - no sudo required
curl -L https://github.com/catio-tech/kportforward/releases/latest/download/kportforward-darwin-amd64 -o kportforward
chmod +x kportforward
mkdir -p ~/bin
mv kportforward ~/bin/
# Then add to PATH if you haven't already:
# echo 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc
# source ~/.zshrc
# macOS (Apple Silicon) - no sudo required
curl -L https://github.com/catio-tech/kportforward/releases/latest/download/kportforward-darwin-arm64 -o kportforward
chmod +x kportforward
mkdir -p ~/bin
mv kportforward ~/bin/
# Then add to PATH if you haven't already:
# echo 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc
# source ~/.zshrc
# Linux
curl -L https://github.com/catio-tech/kportforward/releases/latest/download/kportforward-linux-amd64 -o kportforward
chmod +x kportforward
sudo mv kportforward /usr/local/bin/
# Windows (PowerShell)
Invoke-WebRequest -Uri "https://github.com/catio-tech/kportforward/releases/latest/download/kportforward-windows-amd64.exe" -OutFile "kportforward.exe"- Go to the Releases page
- Download the appropriate binary for your platform
- Make it executable and place it in your PATH
-
Start the application:
kportforward
-
Use the interactive interface:
ββorj/k- Navigate servicesEnter- View service detailsn/s/t/p/u- Sort by Name/Status/Type/Port/Uptimer- Reverse sort orderq- Quit
-
With UI integrations:
# Enable gRPC UI for RPC services kportforward --grpcui # Enable Swagger UI for REST services kportforward --swaggerui # Enable both kportforward --grpcui --swaggerui
-
With log file output:
# Write logs to a file instead of stdout kportforward --log-file /path/to/logfile.log # Combine with UI features kportforward --grpcui --swaggerui --log-file /var/log/kportforward.log
kportforward uses embedded configuration for immediate functionality, with support for user customizations.
Create ~/.config/kportforward/config.yaml (Unix) or %APPDATA%/kportforward/config.yaml (Windows):
# Add your own services (merged with embedded config)
portForwards:
my-service:
target: "service/my-service"
targetPort: 80
localPort: 8080
namespace: "default"
type: "web"
# Override default settings
monitoringInterval: 2s
uiOptions:
refreshRate: 500ms
theme: "dark"rest: REST APIs (enables Swagger UI with--swaggerui)rpc: gRPC services (enables gRPC UI with--grpcui)web: Web applicationsother: Other services
Automatically launches web interfaces for gRPC services with intelligent connection testing:
kportforward --grpcui- Requires:
go install github.com/fullstorydev/grpcui/cmd/grpcui@latest - Accessible at:
http://localhost:<auto-assigned-port>(only when service is accessible) - Smart startup: Only shows URLs for services that are actually running and reachable
Automatically launches Swagger UI for REST APIs with intelligent connection testing:
kportforward --swaggerui- Requires: Docker Desktop
- Accessible at:
http://localhost:<auto-assigned-port>(only when service is accessible) - Smart startup: Only shows URLs for services that are actually running and reachable
- Go 1.21+
- kubectl (configured for your cluster)
# Build for current platform
go build -o bin/kportforward ./cmd/kportforward
# Build for all platforms
./scripts/build.sh
# Create a release
./scripts/release.sh v1.0.0# Run benchmarks
go test -bench=. -benchmem ./...
# Profile CPU usage
./kportforward profile --cpuprofile=cpu.prof --duration=30s
# Profile memory usage
./kportforward profile --memprofile=mem.prof --duration=30s
# Live profiling with pprof
./kportforward --pprof localhost:6060 --mem-stats-interval 5m
# Automatic heap snapshots (opt-in)
./kportforward --pprof localhost:6060 --heap-snapshot-dir ./pprof --heap-snapshot-interval 30m
# Analyze profiles
go tool pprof cpu.prof
go tool pprof mem.prof# Run tests
go test ./...
# Run benchmarks
go test -bench=. -benchmem ./...
# Run with verbose logging
go run ./cmd/kportforward -vInstall pre-commit hooks to automatically format Go code:
# Install git hooks
./scripts/install-hooks.shThe pre-commit hook will:
- Automatically format Go code with
gofmt -s -wbefore each commit - Add formatted files back to staging
- Abort the commit if files were formatted (so you can review changes)
To bypass the hook for a specific commit (not recommended):
git commit --no-verifyββ kportforward v1.3.0 β Context: my-cluster β Services (18/18 running) βββ
β β
β Services (18/18 running) [ββ] Navigate [Enter] Details [q] Quit β
β β
β Name Status URL Type Port Uptime β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β flyte-console Running http://localhost:8088 web 8088 2h3m β
β β flyte-admin-rpc Running http://localhost:8089 rpc 8089 2h3m β
β β api-gateway Running http://localhost:8080 rest 8080 1h45m β
β β process-monitor Failed - rpc - 0s β
β β auth-service Connecting - rest 8081 0s β
β β metrics-service Reconnecting - web 8082 0s β
β ... β
β β
β Status: Reconnecting due to context change β
β [n/s/t/p/u] Sort by Name/Status/Type/Port/Uptime [r] Reverse β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Port conflicts: kportforward automatically finds available ports when configured ports are in use.
Service state transitions:
- Connecting: Service is establishing initial connection (new port-forward)
- Reconnecting: Service is re-establishing connection (after context change or temporary failure)
- Running: Service is successfully connected and responding to health checks
- Degraded: Service is running but experiencing intermittent connectivity issues
- Failed: Service failed to connect or has persistent health check failures
- Cooldown: Service is in backoff period after multiple failures
gRPC UI not starting:
- Install grpcui:
go install github.com/fullstorydev/grpcui/cmd/grpcui@latest - Check logs in
/tmp/kpf_grpcui_*.log - gRPC UI only starts for accessible services - check if port-forward is working
- Look for "TCP connection test" messages in debug logs
Swagger UI not starting:
- Ensure Docker is running
- Check that REST services expose Swagger documentation
- Swagger UI only starts for accessible services - check if port-forward is working
- Look for "TCP connection test" messages in debug logs
- Check Docker containers:
docker ps | grep kpf-swagger
Services stuck in "Connecting" state:
- Verify service exists in the cluster:
kubectl get svc -n <namespace> - Check if the Kubernetes context is valid:
kubectl config current-context - Services will transition to "Failed" within 10 seconds if the service doesn't exist
Services frequently restarting:
- Services enter cooldown mode with exponential backoff
- Check Kubernetes context:
kubectl config current-context - Verify service exists:
kubectl get svc -n <namespace> - Look for error messages in status column or details view
# Check application version
kportforward version
# View help and available commands
kportforward --help
# Performance profiling
kportforward profile --cpuprofile=cpu.prof --memprofile=mem.prof --duration=60s
# Debug with log file
kportforward --log-file /tmp/debug.log
# Check service status manually
kubectl port-forward -n <namespace> <service> <port>:<port>
# Verify kubectl context
kubectl config current-contextkportforward is optimized for high performance with enterprise-scale deployments:
- Config Loading: 4,200x faster with caching (126ms β 30ns)
- Port Conflict Resolution: 600x faster with object pooling
- Port Availability Checks: 1,280x faster with caching
- Application Startup: 10x faster overall
- Memory Usage: 93% reduction in allocations
- Intelligent Caching: TTL-based caching for expensive operations
- Object Pooling: Reduced garbage collection pressure
- Optimized Data Structures: Pre-allocated maps and concurrent-safe operations
- Smart Algorithms: Optimized port finding and conflict resolution
# Run performance profiling
kportforward profile --duration=60s --cpuprofile=cpu.prof --memprofile=mem.prof
# Analyze CPU usage
go tool pprof cpu.prof
# Analyze memory usage
go tool pprof mem.prof
# Run benchmarks during development
go test -bench=. -benchmem ./...For detailed performance analysis, see PERFORMANCE_REPORT.md.
# Start with embedded services
kportforward
# Use arrow keys to navigate, Enter for details, q to quitCreate ~/.config/kportforward/config.yaml:
portForwards:
# Add your microservice
user-service:
target: "service/user-service"
targetPort: 8080
localPort: 3001
namespace: "production"
type: "rest"
swaggerPath: "docs/swagger.json"
# Add your gRPC service
notification-service:
target: "deployment/notification-service"
targetPort: 9090
localPort: 3002
namespace: "production"
type: "rpc"
# Override defaults
monitoringInterval: 3s
uiOptions:
refreshRate: 1sThen run with UI integrations:
kportforward --grpcui --swaggerui# Different contexts with logging
kubectl config use-context staging
kportforward --grpcui --log-file /var/log/staging.log
kubectl config use-context production
kportforward --swaggerui --log-file /var/log/production.log
# Check what's running
kportforward version # Shows current version and update status# Developer working on microservices with logging
kportforward --grpcui --swaggerui --log-file ./dev.log
# Production deployment with log rotation
kportforward --log-file /var/log/kportforward.log
# Access services:
# - Embedded services available at configured ports
# - gRPC UI: http://localhost:<auto-assigned-port> (starts from 9090)
# - Swagger UI: http://localhost:<auto-assigned-port> (starts from 8080)
# - Your APIs accessible through UI tools
# - All activity logged to specified file- README.md: This file - project overview and usage
- CLAUDE.md: Developer guide and architecture documentation
- SERVICE_STATE_DIAGRAM.md: Comprehensive service state machine documentation
- IMPLEMENTATION_LOG.md: Development progress and technical decisions
- PERFORMANCE_REPORT.md: Detailed performance analysis and benchmarks
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
When contributing, please:
- Run benchmarks:
go test -bench=. -benchmem ./... - Profile changes with large service counts (100+ services)
- Test memory usage:
go tool pprof mem.prof - Ensure optimizations don't break existing functionality
This project is licensed under the MIT License - see the LICENSE file for details.
- Bubble Tea for the excellent TUI framework
- Lipgloss for terminal styling
- Cobra for CLI framework