Port Forwarding
kftray support both TCP and UDP port forwarding with automatic reconnection capabilities.
Supported Protocols
- TCP Port Forwarding
- UDP Port Forwarding
- Proxy Forwarding through Kubernetes
TCP Port Forwarding
Standard TCP port forwarding configuration:
{
"service": "web-service",
"namespace": "default",
"local_port": 8080,
"remote_port": 80,
"context": "my-cluster",
"workload_type": "service",
"protocol": "tcp",
"alias": "web"
}
Configuration Fields
service
: Target service or pod namenamespace
: Kubernetes namespacelocal_port
: Port on your local machineremote_port
: Port on the target servicecontext
: Kubernetes contextworkload_type
: Either "service" or "pod"protocol
: Set to "tcp"alias
: Friendly name for the forward
UDP Port Forwarding
UDP port forwarding configuration:
{
"service": "dns-service",
"namespace": "default",
"local_port": 53,
"remote_port": 53,
"context": "my-cluster",
"workload_type": "service",
"protocol": "udp",
"alias": "dns"
}
UDP forwarding requires the kftray-server component to be deployed in your cluster
Automatic Reconnection
kftray automatically handle:
- Pod restarts
- Network interruptions
- Context switches
- Cluster reconnections
Common Use Cases
Web Applications
{
"service": "frontend",
"local_port": 3000,
"remote_port": 80
}
Databases
{
"service": "database",
"local_port": 5432,
"remote_port": 5432
}
Microservices
{
"service": "api-gateway",
"local_port": 8080,
"remote_port": 8080
}
Best Practices
- Use meaningful aliases for easy identification
- Group related services with similar alias prefixes
- Keep local ports consistent across team configurations
- Document port forwards in your project README
Troubleshooting
Common issues and solutions:
- Port Already in Use
- Check for existing processes using the port
- Use a different local port
- Connection Refused
- Verify service is running
- Check namespace and context
- Confirm network connectivity
- Permission Denied
- Verify RBAC permissions
- Check Kubernetes context
- Ensure proper kubeconfig setup