portforward
Easy Kubernetes Port-Forward For Python
Decision gist · record as of 2026-08-14
Yes, if you need programmatic Kubernetes port-forwarding in Python. The package is actively maintained, has no known vulnerabilities, supports modern Python versions with pre-built wheels, and solves a real problem for developers and CI/CD pipelines. The MIT license is permissive. Install friction is moderate due to Rust compilation, but wheels cover most platforms. Start with the quickstart example in the documentation.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a valid kubeconfig file (defaults to ~/.kube/config) and access to a Kubernetes cluster; Rust is needed only if installing from source on an unsupported platform.
- Medium install friction due to compiled Rust components, but wheels are available for Python 3.9–3.13 across Windows, macOS, and Linux (including Alpine).
- Installation from source requires Rust toolchain.
License · maintenance · safety
MIT License (permissive) — MIT License permits commercial and private use with minimal restrictions; you may use, modify, and distribute this package freely as long as you include the license notice.
last release 2026-01-29 (197 days) · last repo commit 2026-06-08 · 25 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 275,535 downloads/mo, #8,174 on PyPI
Alternatives
Verify before relying
pip install portforward
import portforward
with portforward.forward("default", "my-pod", 9000, 80):
# Local port 9000 now forwards to port 80 on the pod
pass- Whether the package supports async/await patterns beyond the context manager interface mentioned in the description.
- Performance characteristics and limits on concurrent port forwards or sustained traffic throughput.
- Compatibility with non-standard kubeconfig formats or authentication methods beyond standard kubectl setup.
What it is and what it does
portforward is a Python library that wraps Kubernetes port-forwarding functionality, letting you programmatically tunnel local ports to pods or services in a cluster without invoking kubectl as a subprocess. It reads your kubeconfig (or a path you provide) and establishes the same kind of port-forward connection that kubectl port-forward would create, but from within Python code.
The library is built on Rust via PyO3 for performance and reliability. It supports both synchronous context-manager usage and async clients, can forward to either pods or services (trying pods first), and handles multiple forwards per target. It's useful for integration testing, local development against staging clusters, or any scenario where you need programmatic access to remote services without manual kubectl commands.
Use it for
- Integration tests that need to reach Kubernetes services from a test runner without spawning kubectl subprocesses.
- Local development workflows where you want to proxy a remote service to localhost within a Python application.
- Automated deployment or health-check scripts that need to temporarily access cluster services.
- Multi-service testing setups where you forward several pods to different local ports in a single test session.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need programmatic Kubernetes port-forwarding in Python.
The package is actively maintained, has no known vulnerabilities, supports modern Python versions with pre-built wheels, and solves a real problem for developers and CI/CD pipelines. The MIT license is permissive. Install friction is moderate due to Rust compilation, but wheels cover most platforms. Start with the quickstart example in the documentation.
Install
portforward on PyPI
Before you install
Medium install friction due to compiled Rust components, but wheels are available for Python 3.9–3.13 across Windows, macOS, and Linux (including Alpine). Installation from source requires Rust toolchain. Last release was 197 days ago; repository is active with recent commits.
Requires a valid kubeconfig file (defaults to ~/.kube/config) and access to a Kubernetes cluster; Rust is needed only if installing from source on an unsupported platform.
License in practice
MIT License permits commercial and private use with minimal restrictions; you may use, modify, and distribute this package freely as long as you include the license notice.
Quickstart
pip install portforward
import portforward
with portforward.forward("default", "my-pod", 9000, 80):
# Local port 9000 now forwards to port 80 on the pod
pass
Verify before relying
- Whether the package supports async/await patterns beyond the context manager interface mentioned in the description.
- Performance characteristics and limits on concurrent port forwards or sustained traffic throughput.
- Compatibility with non-standard kubeconfig formats or authentication methods beyond standard kubectl setup.
Package facts
| License | MIT License permissive |
| Python support | Supports the current Python release >=3.7 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 197 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 275,535 / month, #8,174 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyProgramming Language :: Rust |
Evidence: portforward-0.7.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; portforward-0.7.6-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl; portforward-0.7.6-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl; portforward-0.7.6-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl; portforward-0.7.6-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl; portforward-0.7.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; portforward-0.7.6-cp310-cp310-musllinux_1_2_aarch64.whl; portforward-0.7.6-cp310-cp310-musllinux_1_2_armv7l.whl; portforward-0.7.6-cp310-cp310-musllinux_1_2_i686.whl; portforward-0.7.6-cp310-cp310-musllinux_1_2_x86_64.whl; portforward-0.7.6-cp310-cp310-win_amd64.whl; portforward-0.7.6-cp311-cp311-macosx_10_12_x86_64.whl; portforward-0.7.6-cp311-cp311-macosx_11_0_arm64.whl; portforward-0.7.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; portforward-0.7.6-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl; portforward-0.7.6-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl; portforward-0.7.6-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl; portforward-0.7.6-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl; portforward-0.7.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; portforward-0.7.6-cp311-cp311-musllinux_1_2_aarch64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “kubernetes port forward python”
- portforwardProvides Python bindings for Kubernetes port-forwarding, allowing you…
- kr8sA Python client library for Kubernetes that mirrors kubectl's command…
- sshtunnelEstablishes SSH tunnels to forward local ports to remote services,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Networking packages
h11 is a pure-Python HTTP/1.1 protocol implementation that handles parsing and serializing HTTP messages without any built-in I/O, letting you integrate it with any network layer you choose.
psutil retrieves real-time information about running processes and system resources (CPU, memory, disks, network, sensors) across multiple operating systems, enabling system monitoring, process profiling, and resource management.
pyOpenSSL wraps OpenSSL's SSL/TLS functionality for Python, providing high-level connection objects and certificate handling through a Python-friendly interface around OpenSSL's cryptographic operations.
uvloop is a drop-in replacement for Python's built-in asyncio event loop, implemented in Cython and using libuv, that accelerates async I/O operations.
execnet lets you spawn and communicate with Python interpreters across local processes, remote hosts, and different platforms, using a simple API for task distribution and inter-process messaging.
However, the aging maintenance status (275 days since last release) means you should verify it meets your concurrency and performance needs before committing to a…
PyZMQ provides Python bindings for ZeroMQ (ØMQ), a lightweight messaging library that enables fast, asynchronous communication between distributed processes and applications.
See also kr8s · pykube-ng · kubernetes · k8s-agent-sandbox · kubernetes-asyncio · kopf · kfp-kubernetes · pulumi-kubernetes · ngrok · foxglove-sdk