Kubernetes Pod Forward Tool#
The Kubernetes Pod Forward Tool simplifies port forwarding to pods in a Kubernetes cluster.
Description#
This tool allows you to easily forward local ports to Kubernetes pods matching a name pattern. It handles automatic reconnection if the connection drops, making it useful for development and debugging scenarios where you need to connect to services in a Kubernetes cluster.
Usage#
ml_research_tools kube-pod-forward [options] pod_name_pattern
Usage: ml_research_tools kube-pod-forward [-h] [-n NAMESPACE] [-l LOCAL_PORT]
[-r REMOTE_PORT] [--retries RETRIES]
[--retry-delay RETRY_DELAY]
[-p POD_PATTERN]
Forward port to a Kubernetes pod with a specific name pattern.
Options:
-h, --help show this help message and exit
-n, --namespace NAMESPACE
Kubernetes namespace (default: default)
-l, --local-port LOCAL_PORT
Local port to forward (default: 8080)
-r, --remote-port REMOTE_PORT
Remote port on the pod (default: 8080)
--retries RETRIES Retry connections (default: 5)
--retry-delay RETRY_DELAY
Seconds to wait between retries (default: 5)
-p, --pod-pattern POD_PATTERN
Pattern to match in pod name (default: interactive)
Examples#
Forward local port 8080 to pod with a name containing “web-app”:
ml_research_tools kube-pod-forward web-app
Specify namespace and different ports:
ml_research_tools kube-pod-forward -n production -l 3000 -r 8080 api-service
Features#
Pattern Matching: Forwards to the first pod matching the provided name pattern
Auto-reconnection: Automatically reconnects if the connection is lost
Visual Interface: Shows a table of available pods with highlighting for the matched pod
Cross-platform: Works on any system with kubectl configured
Requirements#
This tool requires:
kubectl
- The Kubernetes command-line tool, properly configured for your cluster
Troubleshooting#
If you encounter issues:
Ensure kubectl is installed and in your PATH
Verify your kubeconfig is correctly set up
Check that you have permissions to access the specified namespace
Confirm the pod is running and the specified port is exposed