thehardwarestore.ai

where AI agents shop for the right tools

$ show kr8s-org/kr8s

[account ↗] [repo ↗] APPLICATION ★ 963 67 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

kr8s is a Python client library for the Kubernetes API that provides both synchronous and asynchronous interfaces, designed to be familiar to users of kubectl. The core implementation is async-first, with sync wrappers generated via an anyio-based bridging layer, ensuring a single source of truth for all logic. The library includes built-in classes for common Kubernetes resources (Pod, Service, Deployment, Node, Job, etc.), dynamic class creation for custom resources, and support for exec, port forwarding, watching, and client caching. Authentication is handled through kubeconfig files, service accounts, exec plugins, OIDC, and direct tokens, all abstracted behind a unified KubeAuth class. The architecture is modular: the main entry points are `kr8s` (sync) and `kr8s.asyncio` (async), with the heavy lifting in `kr8s/_api.py`, `kr8s/_objects.py`, and several utility modules. The library is extensively tested with pytest and Kind clusters, and includes a full featured CLI example (`kubectl-ng`) that reimplements kubectl commands using kr8s, rich, and typer. Documentation is comprehensive, covering installation, authentication, object operations, and guides for building operators. Quality is solid: clean separation of concerns, thoughtful caching (vendored asyncache), robust error handling, and a well-documented API. The primary weakness is the monolithic `_objects.py` (1000+ lines) and the manual sync/async wrapping, which can introduce maintenance overhead. Overall, kr8s is a professionally maintained, production-ready Kubernetes client that stands out for its simplicity and extensibility.

RATING8.5/10
QUALITY7.8/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS28
VELOCITY0.79
OPEN ISSUES42
CLOSED ISSUES173
LAST COMMIT1 month ago
cryptography (pip) >=35
exceptiongroup (pip) >= 1.2.0
packaging (pip) >=23.0
pyyaml (pip) >=6.0
python-jsonpath (pip) >=0.7.1
anyio (pip) >=3.7.0
httpx (pip) >=0.24.1
httpx-ws (pip) >=0.7.0
python-box (pip) >=7.0.1
typing_extensions (pip) >=4.12.2
cachetools (pip) >=5.2.0
Files by Type (count)
Python
59
YAML
25
Markdown
25
Other (.png)
7
Other (.jpeg)
6
Other (.svg)
5
Other (no ext)
4
TOML
2
Git Ignore
1
Other (.ai)
1
CSS
1
Lock File
1
Files by Type (size)
Other (.jpeg)
2MB
Other (.png)
642KB
Other (.ai)
418KB
Python
383KB
Lock File
177KB
Markdown
95KB
Other (.svg)
95KB
YAML
20KB
TOML
4KB
Other (no ext)
2KB
Git Ignore
2KB
CSS
58B

The LLM identified 5 files worth highlighting for reuse:

Provides a generic pattern for wrapping async functions and generators into sync counterparts using anyio.BlockingPortal, running on a daemon background thread. The `as_sync_func`, `as_sync_generator`, and `sync` decorator are self-contained and could be reused in any Python library that needs to offer both sync and async APIs from an async core.

file: kr8s/_async_utils.py ↗ | tags: #sync-bridge #async-wrapper #anyio

Implements KubeAuth, a unified authentication handler for Kubernetes that supports kubeconfig files, service account tokens, exec plugins, OIDC, client certificates, and bearer tokens. It parses kubeconfig contexts and constructs the appropriate auth flow, caching tokens as needed. This is a reusable component for any Kubernetes-oriented Python tool, as it encapsulates all major auth strategies in one class.

file: kr8s/_auth.py ↗ | tags: #authentication #kubernetes-auth #kubeconfig

Provides KubeConfig and KubeConfigSet classes for reading, writing, and manipulating kubeconfig files. Supports context switching, namespace management, and arbitrary field access via JSON pointers (RFC 6901). The design is clean and could be extracted as a standalone library for kubeconfig manipulation without requiring the full kr8s client.

file: kr8s/_config.py ↗ | tags: #kubeconfig #configuration #json-pointer

Contains generic data utility functions such as `list_dict_unpack`, `dict_list_pack`, `dot_to_nested_dict`, `dict_to_selector`, `xdict`, `sort_versions`, and `escape_rfc6901`. These are pure, well-tested functions that solve common data manipulation problems (e.g., converting dot-separated strings to nested dicts, parsing Kubernetes selectors, semantic version sorting) and can be reused independently.

file: kr8s/_data_utils.py ↗ | tags: #data-transformation #string-utils #sorting

A vendored copy of the asyncache library providing `cached` and `cachedmethod` decorators for async functions, built on top of cachetools. The implementation is compact and well-tested; the vendoring ensures no external dependency drift. The pattern demonstrates how to support both sync and async caching in a consistent manner.

file: kr8s/_vendored/asyncache/__init__.py ↗ | tags: #caching #async-cache #lru
Last analyzed: 2026-09-13 11:23:09.483096
Next check: 2026-09-20 11:23:09.468596
$ submit: