Kubernetes Port-Forward Go-Edition For Python
Project description
portforward
Kubernetes Port-Forward Go-Edition For Python
Free software: MIT license
Documentation: https://portforward.readthedocs.io.
Installation
Wheels are available for:
Windows
MacOS X
Linux
with Python versions:
3.6
3.7
3.8
3.9
3.10
3.11
and architectures:
x84_64
arm64 (known as M1/Apple Chip - MacOS only)
Requirements for installation from source
The following things are required when there is no wheel available for the target system.
Go installed and available in the path (at least v1.16 / https://go.dev)
Python (at least v3.6 - below was never tested but might work)
gcc (for Windows available via MinGW)
Pip knows how to install portforward.
pip install portforward
Quickstart
import requests
import portforward
def main():
namespace = "test"
pod_name = "web" # You can also use a service name instead
local_port = 9000 # from port
pod_port = 80 # to port
# No path to kube config provided - will use default from $HOME/.kube/config
with portforward.forward(namespace, pod_name, local_port, pod_port):
response = requests.get("http://localhost:9000")
print(f"Done: \n'{response.status_code}'\n'{response.text[:20]}...'")
if __name__ == "__main__":
main()
Features
Go native Kubernetes port-forwarding with the .kube/config from the home dir or any other path to config.
Portforward for pods and services - the lib will first look for a pod with matching name then for a service
Waiting for a pod to become ready
Development
In case you want to develop on this library itself please take a look at the CONTRIBUTING page.
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
This project is enabled by setuptools-golang.
History
unreleased
Move pytogo Go code into portforward
0.4.5 (2023-03-06)
Fix panic when logging an error
Change default log level to INFO
0.4.4 (2023-02-28)
Fix endless waiting
0.4.3 (2023-02-27)
Throw error instead of panic when port is in usage
0.4.2 (2023-02-06)
Use in-cluster-config when no kube config file is available
0.4.1 (2023-02-01)
Bump pytogo/portforward version
0.4.0 (2023-01-31)
Respect environment variable KUBECONFIG
Wait if a pod is not ready yet
Be able to use service as targets
0.3.1 (2022-12-26)
Allow selecting kubernetes target context
0.3.0 (2022-10-08)
Introduction of logging level as replacement for verbose mode
0.2.8 (2022-08-22)
Added verbose mode
0.2.7 (2021-10-05)
Added missing import
Added type hint
0.2.6 (2021-10-05)
Fixed type hint
0.2.5 (2021-09-09)
Moved the actual portforward to own module
0.2.4 (2021-08-23)
Added adal import for Azure AD
Fixed host IPs with paths
Made timeout flexible
0.2.3 (2021-08-23)
Fixed case when hostIP contains a path
Added common and cloud provider auth plugins
0.2.2 (2021-08-23)
Fixed missing module portforward
0.2.1 (2021-08-19)
Decrease binary size if pre-compile wheels (Improvement of setuptools-golang)
0.2.0 (2021-08-14)
First Release on PyPI.
Made path to kube config variable.
Port-forwarding became non-blocking.
Fixed verification bug when port was None.
Added throwing own error.
0.1.0 (2021-08-09)
First release on Test PyPI.
Blocking port-forward with fixed path for kube config.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for portforward-0.4.5-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b12fe25062c94e75f6b389c689c8842ddf85283bdee45877bb3b8ad043d7a6c |
|
MD5 | 647d3500b74038946796b19c2c42c6b9 |
|
BLAKE2b-256 | 43bbe52416f0ced65bf32f8a8eae5897ba5d3d4dee57469030b0064353377e4d |
Hashes for portforward-0.4.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbb41002bce9bba240922ea76786bdb3c0a4aa4d44f4f1b204c5325c6437c273 |
|
MD5 | 6ac2fb1917a33d76dfe753b13d44dc1b |
|
BLAKE2b-256 | fade306c7f3b08e8012e64b85ae2d22429d2240318a38e5cadf364bab250b361 |
Hashes for portforward-0.4.5-cp311-cp311-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f55a6a04b5d764c7b35b0160660d465480985656f31290a09b8bd1b82dd1095 |
|
MD5 | bf16a8f6436703dbd3d9894bfd0fbe7b |
|
BLAKE2b-256 | de629c5daeb54f0784e26ca7301dff93499eedb45d5adc1ed1efb74b53bcdd5c |
Hashes for portforward-0.4.5-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e548c97fc224cc20630c82fc57730edf9eb83cb167ca349edf548e0abc04f09 |
|
MD5 | 8287928bf882584ea03b899c491e9cf5 |
|
BLAKE2b-256 | 8672970c8dc038423a460815dc8b23b1fe77959be533c598bd214ae9c005e3e4 |
Hashes for portforward-0.4.5-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d15084b138eaa159845f8e6953756676923213068e2a016d92650e3f77f44f63 |
|
MD5 | 45d64a29d48d9aed984de776a969b73d |
|
BLAKE2b-256 | 6b603675fcfe7390aad053f5c691fd6e6c55fb684407ee18831f6cffb8a64031 |
Hashes for portforward-0.4.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebbf8f4108e522b2469bd3734cab45ced9400dc41037ceb842394bcc36580b05 |
|
MD5 | d92e7fc0a1437604dccad75852f8ae61 |
|
BLAKE2b-256 | 819b9335ca4c63c4b6d4aa8d705a63b4a9fdc8703e1a1ec1f248fa29f16f2e3c |
Hashes for portforward-0.4.5-cp310-cp310-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5588ade92061c71fb667a3ee3b9ad2ffdcd7076ebdb8f91d330f1f54e48a1fc2 |
|
MD5 | a6acaee691304b855dec4b219755bbfc |
|
BLAKE2b-256 | 6605a1fc3e9acbd6ee79f5cf76fedef555dc183b56308a54b19ba846a15b538b |
Hashes for portforward-0.4.5-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ab9e2c155de1738d898a05dd46cdcfdaefd0f2bc9c09b527855dfe225f0b698 |
|
MD5 | a97ca86555800b94bd47e00d1e64d857 |
|
BLAKE2b-256 | 817fc6d0310eb977227efed2eb5fc4bbfd63780c9987854d4cf8950baa9a0342 |
Hashes for portforward-0.4.5-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf0446d19b9268e19ef3311001ecd703af2512d8d449fbc3cf7e7c49e5cb21f4 |
|
MD5 | 1f8c50f6e7ec6abd577ef7f817b0118f |
|
BLAKE2b-256 | 3729e9b68f0f6d0da6355c4644f6715afd3a6f1d3d3a3a0676ce5090589320ba |
Hashes for portforward-0.4.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcdee23d9e1ea582c0d1b4b4bbaa6b4e72de5382e9cbd02cb888946ed0c0ef2e |
|
MD5 | db2f10de64a7e3fcc3d7090d4bd05604 |
|
BLAKE2b-256 | 67c0cbf08ffe6129385ef8a06971a1cb3066a3c3b58f76b7b5e256d6586210a7 |
Hashes for portforward-0.4.5-cp39-cp39-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbb52bdf6d2c8f5f430ede9abc5fc322f48455a284ab093f9a0d48e46e0f815c |
|
MD5 | 9ba34013c833a4a8b9d9de47355ccf0f |
|
BLAKE2b-256 | 7a75493bdf8ec8950683b27bd4a9c86aef5e40f9bdae6f8979fefd89b027fb01 |
Hashes for portforward-0.4.5-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8422a914a745201e3737c33366b0b71fed9ab5b2ca5658fd2d62e2018b28ce6 |
|
MD5 | 672395a936f8e7ff807fde2ee117342b |
|
BLAKE2b-256 | 6e185a417c99472dae3e1f74207bfafd80d1aa0dfb77dc189ec981f79cd8aeb1 |
Hashes for portforward-0.4.5-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64c65707e7e76adad8fa7a8be29852a3ecb6e39acf157a09b33375d57d10f103 |
|
MD5 | ec72ec90c9b6a471db4f26e31b98ab3f |
|
BLAKE2b-256 | bfaf77b96c2590a152b34e5de00b81dbdb62fe718681bfbd7d00be7ac4f2fab7 |
Hashes for portforward-0.4.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81071b563f0398c017330c255e3766e12603b8ac7ab3a990f03a6092e38dd9cd |
|
MD5 | e65f0cf24d4af3281aec7a21b3539536 |
|
BLAKE2b-256 | 19166146052bffde9ae0d481643ac04e51686071280ee2612f31773d73f9af58 |
Hashes for portforward-0.4.5-cp38-cp38-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 307969f41cfb8f154e5898c12025b8d43154713f1d5a0e84df874df907e0315f |
|
MD5 | ad6e7bb6c5347819a8e06236caca3764 |
|
BLAKE2b-256 | 3b870513f416b162438c01b2824b8b7d90094bb732ad464d0c60a0239fb62284 |
Hashes for portforward-0.4.5-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f856a1d9a75062bbf59a9c30340a337fdbe4372090160e9ecb3366cf76ba6735 |
|
MD5 | 4cf9b63647838e0ac7fd6f2ea87268fe |
|
BLAKE2b-256 | b88790177ce94e8a82d84fa1502ed7c13d5d21e08bea2a2f8b4e9e31a61f1e31 |
Hashes for portforward-0.4.5-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 980bb9aa797953a65c4d4fa52d183b14fa9d1b722a933266f28f8b66030385b5 |
|
MD5 | b6db5e4f346d25e396cc18af6709206a |
|
BLAKE2b-256 | 708e035f6f64ef38c0b272161cfe96548dc5ad48cf63c9efa472fa1f2fc6f546 |
Hashes for portforward-0.4.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a70e06deaee9f7b9b2d19d130fc26bf318468325e5ee02629d5dbd6fa483c240 |
|
MD5 | f7ba22e24d4a60f73adca9c06bccb1ce |
|
BLAKE2b-256 | 15babc8c3c6833467ab41ae7b4064bc3d33eb1cfb5c3a161e911ffa4d2a18afd |
Hashes for portforward-0.4.5-cp37-cp37m-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64c2744e95cac8e073965fc02ce7884357569eba6a8993c2e1df3c5b91644d19 |
|
MD5 | 3c998bc04fc1733d540078e4a785baf9 |
|
BLAKE2b-256 | 6daea54425c9f5de2e39e0394abd65af03bd53ea3c8f2f8898961450374c624d |
Hashes for portforward-0.4.5-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6224e640106609e2943b1f32715a853e964867cf2f503f42e29dcb7a44b5c925 |
|
MD5 | 1d3489399bc32c83ac58405e024f09d5 |
|
BLAKE2b-256 | a6688649b0218783709a6a66f99e7b75c55d60d1b0a70ca929d35f48ea9ec0e5 |
Hashes for portforward-0.4.5-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc2019777ee83df3bbad22cfca7ab0239405da532486ec713d8d8c01176bd103 |
|
MD5 | e9eae4c605aa8bed1b22e5158ee30931 |
|
BLAKE2b-256 | 79e26d1888569ff3934f6a169a6ad9c5a8f9c23331f0862a03cc0520957f7114 |
Hashes for portforward-0.4.5-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d854d21f5de42ecc2d6a57469f2a8b2041f219e0a133e2f05345e758c4d90bee |
|
MD5 | 283854ca3bb4b61bdc7de0da5bca6157 |
|
BLAKE2b-256 | 9359ee801c07f4cc431168e1104d9efc10e75fe79b8aad9a2a60d28200e49fcf |
Hashes for portforward-0.4.5-cp36-cp36m-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19ce3146ea223f6725552f59655e73ed84ed282371ebe2ad664ed7a00b34cf97 |
|
MD5 | 1620b0a408bc53584698027fac5cd7f4 |
|
BLAKE2b-256 | 8d89bbc5ceb70fdbe05e2a83de3558a6a9a541744af3a647590e7395e2e56c6e |
Hashes for portforward-0.4.5-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 018879fec59ca60d389cdaebd2421bf8357bfdba9a218926a4a9974a25c13c9f |
|
MD5 | 8029a191b1f8ef848563e1d6ee22541e |
|
BLAKE2b-256 | 2a444cd61501e60235acb6071264c3f0bf1e55e1ad2271866fbeb7ce86320cce |