CLI and SDK for creating, managing, and scaling Ray clusters on Kubernetes
Project description
Krayne
CLI and SDK for creating, managing, and scaling Ray clusters on Kubernetes.
Krayne wraps the KubeRay operator behind a clean, opinionated interface so ML practitioners can get distributed compute without touching Kubernetes manifests.
A fast and intuitive terminal TUI (Terminal User Interface) is also available.
Navigate clusters, create with prefilled forms, scale, delete, and toggle tunnels — all with keyboard shortcuts. See the Interactive TUI guide for details.
Quickstart
pip install krayne
Create a Ray cluster with a single command:
krayne create my-cluster --gpus-per-worker 1 --workers 2
Or use the Python SDK to define code and infrastructure together:
import ray
from krayne.api import managed_cluster
from krayne.config import ClusterConfig, WorkerGroupConfig
config = ClusterConfig(
name="hello-world",
worker_groups=[WorkerGroupConfig(replicas=2)],
)
with managed_cluster(config) as managed:
ray.init(managed.tunnel.client_url) # ray://localhost:... (tunneled)
@ray.remote
def hello(x):
return f"Hello from worker, {x}!"
futures = [hello.remote(i) for i in range(4)]
print(ray.get(futures))
ray.shutdown()
# Tunnels closed, then cluster deleted
Tunnels are opened by default — access the dashboard, notebook, and other services via localhost:
from krayne.api import managed_cluster
from krayne.config import ClusterConfig
config = ClusterConfig(name="my-cluster")
with managed_cluster(config) as managed:
# Tunnel (localhost) URLs via managed.tunnel
print(managed.tunnel.dashboard_url) # http://localhost:...
print(managed.tunnel.client_url) # ray://localhost:...
# In-cluster IPs via managed.cluster
print(managed.cluster.dashboard_url) # http://10.0.0.1:8265
# Tunnels closed, then cluster deleted
Interactive TUI
Krayne includes a k9s-style interactive terminal UI:
krayne tui
Or run it directly without installing: uvx krayne tui
Features
- Zero-config defaults — every command works with no flags. Sensible defaults get you a working cluster instantly.
- CLI and SDK — the CLI is a thin shell over the Python SDK. Anything you do from the terminal, you can do from code.
- Interactive TUI — k9s-style terminal UI for keyboard-driven cluster management.
- Functional API — stateless free functions, not class hierarchies. Easy to test, easy to compose.
- Pydantic config — validated configuration with YAML override support. No silent failures.
- Rich output — beautiful terminal tables via Rich, with
--output jsonfor scripting.
CLI Overview
krayne create <name> Create a new Ray cluster
krayne get List clusters in a namespace
krayne describe <name> Show detailed cluster info
krayne scale <name> Scale a worker group
krayne delete <name> Delete a cluster
krayne tui Launch interactive TUI
All commands support -n/--namespace, --output json, and --debug flags.
Documentation
Full documentation is available at the Krayne docs site.
Requirements
- Python 3.10+
- A Kubernetes cluster with the KubeRay operator installed
- A valid kubeconfig (or running inside the cluster)
Development
# Clone and install
git clone https://github.com/roulbac/krayne.git
cd krayne
uv sync
# Run tests
uv run pytest
# Run integration tests (sandbox is provisioned automatically by test fixtures)
uv run pytest -m integration
Acknowledgements
Krayne is inspired by Spotify-Ray (sp-ray), Spotify's internal platform for running Ray on Kubernetes. The sp-ray team demonstrated that a CLI and SDK with sensible defaults, progressive disclosure of complexity, and managed KubeRay infrastructure can let ML practitioners focus on business logic instead of Kubernetes manifests. Krayne follows this philosophy as an open-source tool for the broader community.
License
Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file krayne-0.2.2.tar.gz.
File metadata
- Download URL: krayne-0.2.2.tar.gz
- Upload date:
- Size: 43.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43f5e7e611eb31e5b4d6cd03a88202ac4772419857c2aee1bfeb41e475bc8f8f
|
|
| MD5 |
f0c0ac8e41f97fc013ac8f85e5dab637
|
|
| BLAKE2b-256 |
de0ece2de5bdc24470977fa5207a978736cceb048b628e073b29551b3a5f39a9
|
Provenance
The following attestation bundles were made for krayne-0.2.2.tar.gz:
Publisher:
publish.yml on roulbac/krayne
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
krayne-0.2.2.tar.gz -
Subject digest:
43f5e7e611eb31e5b4d6cd03a88202ac4772419857c2aee1bfeb41e475bc8f8f - Sigstore transparency entry: 1338938900
- Sigstore integration time:
-
Permalink:
roulbac/krayne@113660ef6a7626b4ece7fd0e361496fe9e700202 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/roulbac
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@113660ef6a7626b4ece7fd0e361496fe9e700202 -
Trigger Event:
release
-
Statement type:
File details
Details for the file krayne-0.2.2-py3-none-any.whl.
File metadata
- Download URL: krayne-0.2.2-py3-none-any.whl
- Upload date:
- Size: 60.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01a555e24d51b9595d0a66ccef7a144d78dadf39d4209b0a338441d88f30342a
|
|
| MD5 |
adeb18cb96f28f3c1cb3ba73f6e6a927
|
|
| BLAKE2b-256 |
d77cf77fd5399e995e07958f1c69047dc43174c21be57f20d831e1c4b6f96cd9
|
Provenance
The following attestation bundles were made for krayne-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on roulbac/krayne
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
krayne-0.2.2-py3-none-any.whl -
Subject digest:
01a555e24d51b9595d0a66ccef7a144d78dadf39d4209b0a338441d88f30342a - Sigstore transparency entry: 1338939435
- Sigstore integration time:
-
Permalink:
roulbac/krayne@113660ef6a7626b4ece7fd0e361496fe9e700202 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/roulbac
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@113660ef6a7626b4ece7fd0e361496fe9e700202 -
Trigger Event:
release
-
Statement type: