Skip to content

Kubernetes Port-Forward Go-Edition For Python

License

Notifications You must be signed in to change notification settings

trisongz/aioportforward

 
 

Repository files navigation

portforward

PyPI - Downloads

Documentation Status Build status

Kubernetes Port-Forward Go-Edition For Python

Installation

Wheels are available for:

  • Windows
  • MacOS X
  • Linux

with Python versions:

  • 3.6
  • 3.7
  • 3.8
  • 3.9
  • 3.10

and architectures:

  • x84_64

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"
    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.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

This project is enabled by setuptools-golang.

About

Kubernetes Port-Forward Go-Edition For Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 49.9%
  • Makefile 24.6%
  • C 13.2%
  • Go 12.3%