Skip to main content

A Library that contains a Proxy for KubeVirts VNC Websockets. Uses JWT Tokens for Authentication and to transfer data.

Project description

Websocket Proxy Lib

Library that contains a Proxy for KubeVirts VNC Websockets. It uses JWT Tokens for Authentication and to transfer data.

Installation

  • pip3 install lab-orchestrator-ws-proxy-lib

Documentation

Check out the developer documentation at websocketproxylib.readthedocs.io.

Usage

The library contains one module called ws_proxy_lib that contains one class. This class contains a run and a run_in_thread method that can be used to start the proxy.

First you need to initialize an object of the class. For that you need to pass some parameters:

  • remote_url: The base URL to the Kubernetes api (for example "ws://localhost:8001")
  • api_path: The path in the api that points to a VMI. This needs to contain the variables {namespace} and {vmi_name} (for example "/apis/subresources.kubevirt.io/v1alpha3/namespaces/{namespace}/virtualmachineinstances/{vmi_name}/vnc")
  • local_dev_mode: This is a boolean that indicated if you are running the lib locally in a development mode or running it in a Kubernetes cluster. Running it locally disables ssl. Running it in Kubernetes will automatically include the TLS client certificate from /var/run/secrets/kubernetes.io/serviceaccount/ca.crt and use the token from /var/run/secrets/kubernetes.io/serviceaccount/token.
  • secret_key: The key that is used to decrypt the token.

After that you can just start the proxy with the run and a run_in_thread method. Use the parameters host and port to specify on which host and port this runs.

The proxy works as follows:

It creates a websocket at the given host and port. Then when you want to access a VM you need to call the websocket with a path that contains the token and the VM-name divided by a slash. Example: localhost:5001/ABCTOKENDEF/ubuntu. The example contains the token ABCTOKENDEF and tries to access the VM with the name ubuntu. The token contains a list of allowed VM-names and if the given VM-name is part of the token you will be able to access the VM.

See more at: websocketproxylib.readthedocs.io.

Examples

For an example on how to use this library you can take a look at the WebsocketProxy Project which uses this library and integrates it into a docker image.

Contributing

Issues

Feel free to open issues.

Project Structure

The src folder contains the source code of the library. The tests folder contains the test cases. There is a makefile that contains some shortcuts for example to run the test cases and to make a release. Run make help to see all targets. The docs folder contains rst docs that are used in websocketproxylib.readthedocs.io.

Developer Dependencies

  • Python 3.8
  • Make
  • pip install -r requirements.txt
  • pip install -r requirements-dev.txt

Releases

Your part:

  1. Create branch for your feature (issue/ISSUE_ID-SHORT_DESCRIPTION)
  2. Code
  3. Make sure test cases are running and add new ones for your feature
  4. Create MR into master
  5. Increase version number in src/lab_orchestrator_ws_proxy_lib/__init__.py (semantic versioning)

Admin part:

  1. Check and accept MR
  2. Merge MR
  3. Run make release

Docs

To generate the docs run: cd docs && make html.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lab-orchestrator-ws-proxy-lib-0.0.4.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lab_orchestrator_ws_proxy_lib-0.0.4-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file lab-orchestrator-ws-proxy-lib-0.0.4.tar.gz.

File metadata

  • Download URL: lab-orchestrator-ws-proxy-lib-0.0.4.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.5.0.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.10

File hashes

Hashes for lab-orchestrator-ws-proxy-lib-0.0.4.tar.gz
Algorithm Hash digest
SHA256 b459eb1a7943d0e7154d8cfcc8b2c71b3951069d1b12b4536d553a6d1adc0230
MD5 4d84fb6773ada77e3eae5a4443ffe18b
BLAKE2b-256 45f8b06f4ffcf4567f473a1e3c25888abb8b10e27eb90a0ed5771ff5be08395f

See more details on using hashes here.

File details

Details for the file lab_orchestrator_ws_proxy_lib-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: lab_orchestrator_ws_proxy_lib-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.5.0.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.10

File hashes

Hashes for lab_orchestrator_ws_proxy_lib-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4dd9b5688612bf11c94033aabb2daee28dab2410025b7039c833c8ba12f2d64e
MD5 eddde30acc34deefce3a3eaa83bb261c
BLAKE2b-256 0786b073b189c0490e9ae50823dc47291fe6452f400936da55c114bcc5850f87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page