Skip to main content

Kubernetes Lite is a "liteweight" wrapper around various golang Kubernetes libraries using gopy

Project description

Kubernetes Lite

Kubernetes Lite is a lightweight Python wrapper around key Go-based Kubernetes libraries like client-go, controller-runtime, and envtest made accessible through gopy. It combines Go’s performance with Python’s ease of use—offering faster client operations, reduced memory overhead, and best-in-class testing capabilities.


🚀 Why Kubernetes Lite?

  • Up to 20% faster than the standard Python client.
  • 🧪 Best-in-class testing tools: Run a full Kubernetes control plane locally—no containers or mocks needed.
    • 🔧 Fully Compatible with existing Python Kubernetes clients like kubernetes.
  • 🧠 Unified Go + Python interface: Leverage Go’s resource-efficient internals while writing Python code.

🔬 Built-In Testing with EnvTest

Kubernetes Lite provides Python bindings to Go's envtest—an isolated, real Kubernetes control plane for testing your Python clients and controllers. This eliminates the need for mocking or spinning up complex test environments.

✅ Works with any Kubernetes client

✅ Seamless integration with pytest

✅ Mirrors Go’s native test workflow, including support for KUBEBUILDER_ASSETS and USE_EXISTING_CLUSTER

Example: Using EnvTest with the official Kubernetes client

from kubernetes import client, config
from kubernetes_lite.envtest import EnvTest
from kubernetes_lite.envtest.pytest import session_kubernetes_env

def test_kubernetes_core_api(session_kubernetes_env: EnvTest):
    config.load_config(config_file=session_kubernetes_env.config())
    v1 = client.CoreV1Api()
    pods = v1.list_pod_for_all_namespaces(watch=False)
    for i in pods.items:
        print(f"{i.status.pod_ip}\t{i.metadata.namespace}\t{i.metadata.name}")

🧰 Compatible and Lightweight Client

Kubernetes Lite exposes client-go’s powerful dynamic client with full compatibility with Kubernetes apimachinery options (both JSON and camelCase formats).

from kubernetes_lite.client import DynamicClient

client = DynamicClient()
client.resource("apps/v1", "Deployment").list()

📉 Benchmark results:

  • 🚀 ~20% faster client operations
  • 🧠 ~50% lower memory usage
  • ⚡ 300ms+ faster startup—ideal for CLI tools or cron jobs

[!NOTE] To be honest the "20%" runtime improvement is just a part of the sales pitch and isn't noticble in the real world. The official client is only 1-3ms behind Kubernetes Lite, which would not impact a networked client where network latencies usually are higher than 1ms. On the other hand, the 300ms startup improvement can be big for often used scripts.

client runtime operation timings client startup operation timings client memory usage


🛠 Setup EnvTest (CLI)

To aid in setting up envtest we also provide a wrapper around the setup-envtest cli:

python3 -m kubernetes_lite.setup_envtest use

Output:

Version: 1.32.0
OS/Arch: darwin/amd64
Path: /Users/yourname/.../k8s/1.32.0-darwin-amd64

You may use it manually before running your tests or let the EnvTest class handle it automatically during startup.


📦 Installation

[!WARNING] Due to Go limitations in version 1.21+, multiple CGO shared libraries are not supported in the same process. Avoid using other Go-based Python libraries alongside kubernetes_lite. Details

We provide precompiled wheels for x86 and ARM on Linux and macOS:

pip3 install kubernetes_lite

From Source

Make sure you have Go 1.23+ installed:

pip3 install --no-binary "kubernetes_lite" kubernetes_lite

📚 Documentation


🤝 Contributing

We welcome contributions of all kinds! See our contributing guide.


🧭 Code of Conduct

Please review our Code of Conduct before contributing.

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

kubernetes_lite-0.1.0.tar.gz (360.9 kB view details)

Uploaded Source

Built Distributions

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

kubernetes_lite-0.1.0-cp312-cp312-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.12Windows x86-64

kubernetes_lite-0.1.0-cp311-cp311-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.11Windows x86-64

kubernetes_lite-0.1.0-cp311-abi3-musllinux_1_2_x86_64.whl (13.1 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ x86-64

kubernetes_lite-0.1.0-cp311-abi3-musllinux_1_2_aarch64.whl (11.8 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

kubernetes_lite-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (11.8 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

kubernetes_lite-0.1.0-cp311-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.1 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

kubernetes_lite-0.1.0-cp311-abi3-macosx_11_0_arm64.whl (11.6 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

kubernetes_lite-0.1.0-cp311-abi3-macosx_10_9_x86_64.whl (12.5 MB view details)

Uploaded CPython 3.11+macOS 10.9+ x86-64

File details

Details for the file kubernetes_lite-0.1.0.tar.gz.

File metadata

  • Download URL: kubernetes_lite-0.1.0.tar.gz
  • Upload date:
  • Size: 360.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kubernetes_lite-0.1.0.tar.gz
Algorithm Hash digest
SHA256 84e8bdc49e0066ba30c67ec9ff859a9e591054bd92c1a02208aba9513340e870
MD5 efe3c9b228e4c714aff999ceb0031b50
BLAKE2b-256 7c65d37b98179c0bbb85f0d5a251c9af9bdacafe2ea48ff8c218f2a52a78cbf6

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.1.0.tar.gz:

Publisher: publish_release.yml on IBM/Kubernetes-Lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kubernetes_lite-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6615e3ba820deebe4b97333eee8fd13fa83864f3403b67a17f1f3c229c0be518
MD5 da364b0932c03ef484e65889679752e7
BLAKE2b-256 6b09e942c21dfb716462463e0f06207184fdab321f09d303af6bad64a4c1cbe8

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.1.0-cp312-cp312-win_amd64.whl:

Publisher: publish_release.yml on IBM/Kubernetes-Lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kubernetes_lite-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ba5708cb0b3fc81e27a768ae1bf0fc67a01cbeeefb1065f5c8f5eaa03db29f78
MD5 e2ed9cf3feafd9e32f994308d79b6443
BLAKE2b-256 59338066fd51176d59e384d51c706a170d008ae613449ab66b3ac29349cc36a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.1.0-cp311-cp311-win_amd64.whl:

Publisher: publish_release.yml on IBM/Kubernetes-Lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kubernetes_lite-0.1.0-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.1.0-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7304f599debb4cd641882afd3c0576660188e249caaa0c3158abd5dc7cab8948
MD5 0be2e028c39b195c4d81b35cb160f27f
BLAKE2b-256 aa614677b7920def66e20cbac7ef06091a6ffe74eccc00f91cc1a559b259659e

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.1.0-cp311-abi3-musllinux_1_2_x86_64.whl:

Publisher: publish_release.yml on IBM/Kubernetes-Lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kubernetes_lite-0.1.0-cp311-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.1.0-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e4f61b8ae63ec2a271765130226a23e126e69ecc47326fc8abbcdfb76479d614
MD5 3f605b09e2fab701119eeb86e908bd29
BLAKE2b-256 6b0769342965a4558ef7248160bca531864e2ee3eaa6cce0211546a06919b8dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.1.0-cp311-abi3-musllinux_1_2_aarch64.whl:

Publisher: publish_release.yml on IBM/Kubernetes-Lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kubernetes_lite-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1ecdb135f5ed03452959dfb53d7bd600ec8b1982d2e9236551c33ccb7a4ed04f
MD5 e9f325ed5a2da0d86ea91c3e17bbbd99
BLAKE2b-256 4c4b0c47f5dc2bc939f4e66825f4b192e78bc377d1b218fdf5fd627472d61672

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish_release.yml on IBM/Kubernetes-Lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kubernetes_lite-0.1.0-cp311-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.1.0-cp311-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b7fe227df12549ae851452b9fddc5ef12f0f923a7a56f51ab9f1b68c8be50741
MD5 7f4ac917f68e11c5cb237e20a6fcb034
BLAKE2b-256 360f38c2ab1030c19de04cae686dc19097a5e866f3ae335ea3d0b282c509e308

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.1.0-cp311-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish_release.yml on IBM/Kubernetes-Lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kubernetes_lite-0.1.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3db5d01db717022f01f3d672ba6eb2c7114335d3538d804bf742855adb6c5b51
MD5 634c70c53b4fdd17b67744e9d39f94c2
BLAKE2b-256 9d9e9b5bba562ca26105a542e186b900ae0af0630b4c216158ce68475e21c864

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.1.0-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: publish_release.yml on IBM/Kubernetes-Lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kubernetes_lite-0.1.0-cp311-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.1.0-cp311-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3bb313c724c60a3709acac0876bafe87b5ab69634f12aa2a915e4e5e1cde5961
MD5 13d8853860f97b470501c5835944d717
BLAKE2b-256 e74978cae574e627c331bc1cbc089415684bea96ed698326920de8318a5f591d

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.1.0-cp311-abi3-macosx_10_9_x86_64.whl:

Publisher: publish_release.yml on IBM/Kubernetes-Lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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