Repolode
kr8s-org

kr8s-org/kr8s

A Python client library for Kubernetes with an API modeled on kubectl, offering sync and async (asyncio/trio) interfaces.

Stars
1,001
Forks
71
Open issues
49
Last commit
6 days ago

What is it?

kr8s is a Python client library for Kubernetes. Its API is modeled on kubectl, so developers who already know commands like get, scale, label, cordon and exec can find equivalent methods on Pod, Deployment, Node and other object classes without learning a new vocabulary.

The library favors sensible defaults for authentication and client setup, and it caches clients so API objects do not need to be passed around between functions. Code is written by hand rather than generated from Swagger specs, which keeps the source readable. Both a standard synchronous API and an async API usable with asyncio and trio are provided.

Beyond basic CRUD, kr8s includes helpers for common operations such as pod exec, port forwarding in a background thread, and generating simple Pod definitions from keyword arguments. The project lists support for several Python versions and recent Kubernetes releases.

Key features

  • 01Method names and semantics follow kubectl for a shallow learning curve.
  • 02Provides both synchronous and async APIs that work with asyncio and trio.
  • 03Caches clients so API objects can be reused without passing clients around.
  • 04Includes helpers for pod exec, port forwarding and node cordoning.
  • 05Uses hand-written code instead of Swagger-generated client code.

Use cases

  • Writing Python automation that scales deployments or labels pods in a cluster.
  • Building asyncio-based controllers or services that talk to the Kubernetes API.
  • Replacing shell scripts that shell out to kubectl with typed Python code.

Quick start

  1. 1

    Install the library from PyPI

    pip install kr8s
  2. 2

    List all node names in your cluster

Things to know

  • Requires access to a Kubernetes cluster to do anything useful.

Topics

FAQ

What is kr8s?
A Python client library for Kubernetes with an API modeled on kubectl, offering sync and async (asyncio/trio) interfaces. kr8s is a Python client library for Kubernetes. Its API is modeled on kubectl, so developers who already know commands like get, scale, label, cordon and exec can find equivalent methods on Pod, Deployment, Node and other object classes without learning a new vocabulary.
Is kr8s free to use? What license does it have?
kr8s is open source under the BSD-3-Clause license. Check the license terms before using it in commercial products.
Is kr8s still maintained?
Actively maintained. The last commit to kr8s was on Oct 14, 2026.
What can I use kr8s for?
Writing Python automation that scales deployments or labels pods in a cluster. Building asyncio-based controllers or services that talk to the Kubernetes API. Replacing shell scripts that shell out to kubectl with typed Python code.
How do I install kr8s?
Install the library from PyPI: pip install kr8s List all node names in your cluster
Where can I get kr8s?
The source code and installation instructions are on GitHub: https://github.com/kr8s-org/kr8s

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects