skillfed

kr8s

A Kubernetes API library

kr8s v0.20.15 912.7K downloads/30d#4,741 on PyPI963
Permissive license BSD-3-Clause Active released

What it is and what it does

kr8s is a Python client for Kubernetes designed to feel familiar to users of kubectl. Instead of wrestling with Swagger-generated code or low-level API calls, you work with human-readable objects and methods that mirror kubectl's command structure. It handles authentication with sensible defaults, reducing boilerplate setup.

The library provides both synchronous and asynchronous APIs (compatible with asyncio and trio), client-side caching to avoid redundant API calls, and batteries-included utilities for common tasks like pod execution, port forwarding, node cordoning, and deployment scaling. You can list resources with label selectors, generate objects from templates, and manipulate cluster state in a Pythonic way.

Use it for:

  • Automate cluster operations (scaling deployments, cordoning nodes, adding labels) in Python scripts or applications.
  • Build monitoring or admin dashboards that query Kubernetes resources without learning the raw API.
  • Execute commands in pods or set up port forwards programmatically for debugging or data transfer.
  • Write integration tests that create, inspect, and clean up Kubernetes resources in a familiar syntax.
  • Migrate kubectl workflows into Python-based CI/CD pipelines or infrastructure-as-code tools.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A Python client library for Kubernetes that mirrors kubectl's command patterns, offering both sync and async APIs to query, create, and manage cluster resources.

Yes. kr8s is actively maintained, has no known vulnerabilities, low install friction, and a permissive license. It solves a real problem—making Kubernetes automation accessible to Python developers without requiring deep API knowledge. The kubectl-inspired design and async support make it suitable for both simple scripts and production automation.

Install

kr8s on PyPI

pip

pip install kr8s

uv

uv add kr8s

poetry

poetry add kr8s

Installing kr8s

Before you install

Low friction: pure Python wheel with 11 runtime dependencies (httpx, pyyaml, cryptography, and others) all common and well-maintained. Active maintenance with a recent commit on 2026-08-12 and 963 repository stars.

License in practice

BSD-3-Clause is permissive; you can use this in commercial or proprietary projects with minimal restrictions, provided you include the license text.

Quickstart

pip install kr8s

import kr8s

for node in kr8s.get("nodes"):
    print(node.name)

Requires Python >=3.9 and a running Kubernetes cluster or valid kubeconfig for authentication.

Verify before relying

  • Whether sensible defaults for authentication work seamlessly in all common deployment environments (local, cloud, CI/CD).
  • Performance characteristics when querying large clusters or handling high-frequency operations.
  • Scope of kubectl-inspired utilities beyond the documented examples (pod operations, scaling, labeling).

Package facts

License BSD-3-Clause (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 11 — anyio, cachetools, cryptography, exceptiongroup, httpx-ws, httpx, packaging, python-box, python-jsonpath, pyyaml, typing-extensions
Maintenance actively maintained — 210 days since the last release
Last repo commit
First released
Downloads 912,699/month — #4,741 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: kr8s-0.20.15-py3-none-any.whl

Keywords: kubectl, kubernetes

Programming Language :: Python :: 3

Tags

kubernetes python clientkubectl-like api libraryk8s cluster managementasync kubernetes clientpython kubernetes automationkubectl python wrapperkubernetes resource operations
kubernetesdevops-automationasync-ready

More Distributed Computing packages