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 "liteweight" wrapper around various golang Kubernetes libraries using gopy. It brings the benefits of go's resource efficiency plus the feature set of packages like client-go and the controller-runtime to Python.

Documentation

Get going with our examples page or jump into more details with our API Reference!

Installation

[!WARNING] Since go 1.21 having multiple go shared objects in the same process is not supported. Thus you can not use other CGO based libraries with kubernetes-lite. If you would like to combine this package with another golang based one then please open an issue so we can discuss possible solutions.

Kubernetes Lite provides precompiled both x86 and arm wheels for Linux and MacOS. You can install the package with the standard pip install

pip3 install kubernetes_lite

Source Installation

To install Kubernetes Lite from source, you must install golang 1.23. You should then let setup-tools/pip install the package like normal.

pip3 install --no-binary "kubernetes_lite" kubernetes_lite

Dynamic Client

Kubernetes Lite exposes client-go's dynamic client, which, on average, is 20% faster and uses half the memory than the standard Kubernetes library. It supports all of the options defined by apimachinery in both their JSON and camelCase formats. See the examples folder for a recreation of client-go's own dynamic example.

In addition to the usage example you can check out the Api Reference for a detailed description of all methods and options.

from kubernetes_lite.client import DynamicClient

# Construct a client using https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/client/config#GetConfig
client = DynamicClient()
# List all deployments in a cluster
client.resource("apps/v1","Deployment").list()

The following graphs highlight the speed and efficiency of the dynamic client. One caveat is that the "20%" runtime improvement is on top of a fast standard client. The official client is only 1-3ms behind Kubernetes Lite, which would not impact a networked client where network latencies usually are much higher than 1ms. The real benefit of Kubernetes Lite's resource efficiency is startup time. If you have a simple script that needs to be run at frequent intervals, the startup save of 300ms can be impactful.

client runtime operation timings client startup operation timings client memory usage

EnvTest

To aid in testing all Python Kubernetes libraries, Kubernetes Lite also provides bindings to the controller-runtime's envtest package. This allows you to start a local control plane without needing a container runtime, which provides users real API server to test against, replacing the need for complicated "mock" clients and servers. As shown in our examples folder, these bindings and pytest fixtures work with any Kubernetes client, including the official one.

# Import standard Kubernetes client
from kubernetes import client, config
# Import Kubernetes Lite Fixture
from kubernetes_lite.envtest.pytest import session_kubernetes_env, EnvTest

def test_kubernetes_core_api(session_kubernetes_env: EnvTest):
    """Test that kubernetes core api works with envtest"""
    config.load_config(config_file=session_kubernetes_env.config())

    v1 = client.CoreV1Api()
    print("Listing pods with their IPs:")
    ret = v1.list_pod_for_all_namespaces(watch=False)
    for i in ret.items:
        print(f"{i.status.pod_ip}\t{i.metadata.namespace}\t{i.metadata.name}")

The EnvTest class was designed to be compatible with the controller-runtime version. It uses the same environmental configuration as go with support for envvars like KUBEBUILDER_ASSETS and USE_EXISTING_CLUSTER. For a complete guide to envtest checkout the controller-runtimes Configuring Envtest guide. The code snippets will be different; instead of setup-envtest, it will be python3 -m kubernetes_lite.setup_envtest, but the guide is still applicable.

Setup EnvTest

Along with envtest, Kubernetes Lite wraps it's helper script setup-envtest. This script is automatically called when starting an EnvTest instance but it can also be invoked manually with python3 -m kubernetes_lite.setup_envtest. It has the exact same options and use as the go version.

 python3 -m kubernetes_lite.setup_envtest use
Version: 1.32.0
OS/Arch: darwin/amd64
sha512: a7824ff8ae9c5062bcbde243a7a3a1c76e02de0c92e2b332daf1954405aeded856023f277d74197862d0d5909e9e1dca451b5f2e84796e451ad6011ec98f8433
Path: /Users/michaelhonaker/Library/Application Support/io.kubebuilder.envtest/k8s/1.32.0-darwin-amd64

Contributing

Check out our contributing guide to learn how to contribute to Kubernetes Lite.

Code of Conduct

Participation in Kubernetes Lite is governed by our Code of Conduct.

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.0.6.tar.gz (361.6 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.0.6-cp312-cp312-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.11Windows x86-64

kubernetes_lite-0.0.6-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.0.6-cp311-abi3-musllinux_1_2_aarch64.whl (11.8 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

kubernetes_lite-0.0.6-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.0.6-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.0.6-cp311-abi3-macosx_11_0_arm64.whl (11.6 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

kubernetes_lite-0.0.6-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.0.6.tar.gz.

File metadata

  • Download URL: kubernetes_lite-0.0.6.tar.gz
  • Upload date:
  • Size: 361.6 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.0.6.tar.gz
Algorithm Hash digest
SHA256 8c745e81eb19a3ecf0cc70963ceb787367cfb6535b478adf46fa18df20b4cdc3
MD5 f011ac3fb649cb8a90a7cbfcc61a0b52
BLAKE2b-256 6218619c05013166f26c77d2a36c50db64492a9f249ff02fbf6baf712f4aef84

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.0.6.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.0.6-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.0.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 33e3d949e770d47d0ae8e5eda9c982c46e0cc1aaaf0b0b834bc7d2f4fbec847e
MD5 0412edbe240f5c6f19e0584b9cbdda3f
BLAKE2b-256 68e74def7082906670138a95158a6b76273561454cbcf1d45e242e8e962f3889

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.0.6-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.0.6-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.0.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3bb57b96e71ebac37dba733ac30b887de2bd791c16287d590e42df45b6514658
MD5 1ce903491d30b8a5d70c3b0f8347ca6b
BLAKE2b-256 47b4a8457452ce22c26d17b2b4f2dbd62daf1e4c6d7295c41a0e77f26ddc4f1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.0.6-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.0.6-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.0.6-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d6d1c58fced5eab4beeebf6ba64a5a59af5f0c81f48fbe58cde484578f687208
MD5 28d826640cebbebc989b35a9b8451131
BLAKE2b-256 e30e4aed56c09d244c5e74a3dbe395b0ba69eaf9e72ecdf1a41f8843ff6377fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.0.6-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.0.6-cp311-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.0.6-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 23bfca36d77f316e6b916833788eb9cd7ae606367375b66b4121ac4350353b96
MD5 21b570d59bb9148fecd79e118110965a
BLAKE2b-256 d864e431247ba1d13df559ec48d9106dda8b51ea38631341ad399c00eed20501

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.0.6-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.0.6-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.0.6-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fe5ebb471a0f921d01dacc660d06e49819920c22f2da8f718085cf794e4acdaf
MD5 53ac9384a65af1912fae202fe15dd04e
BLAKE2b-256 86befcdd4978fcdc3cd67a41263257fbb01038b2cdec5a57841a53e86cce953f

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.0.6-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.0.6-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.0.6-cp311-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e2356d40ef1ba6f84464d3561f46eae646ac73cb74fa335c59813f617f867ccc
MD5 b2ed3f9e414a8d920d802fd202a97b2a
BLAKE2b-256 371526f1dd28f7f933d1f21c037c96b28f9032faa3c1a6d86a2d0dd544a52c75

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.0.6-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.0.6-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.0.6-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aec0298c57d12cf6fefdc01714cf5292b85e45458c6e42c32d9d5d10ec40d6f6
MD5 a527df0044c459251cfdca1322d849ca
BLAKE2b-256 bc4cf163f917ee1b9a4a7845b744eae92370f8aea8797864a28f1367bed00a24

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.0.6-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.0.6-cp311-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for kubernetes_lite-0.0.6-cp311-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c911648e19b9d0c90f3617cf6ae88bad065aa586ffc792354bbd67fc8f7440ee
MD5 5979f53538a7f7762115717512cc8b2e
BLAKE2b-256 e8174e7b32bc3bb7b02e3fa0336e4bced2f10068e1548c050a65630f077f3c6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubernetes_lite-0.0.6-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