Skip to main content

Klube CLI Tool

Klube is a command-line interface (CLI) tool designed to simplify interactions with Kubernetes clusters. It provides a set of convenient commands that wrap around kubectl, making it easier to perform common operations like viewing logs, executing commands in pods, and copying files to and from pods.

Table of Contents

Installation

You can easily install Klube using pip:

pip install klube

During the installation process, Klube will automatically create an initial configuration file at ~/.klube/config.json. This file will contain default settings, including the default Kubernetes namespace.

After installation, you'll see a message confirming the creation of the configuration file and instructions on how to modify it.

Usage

After installation, you can use the klube command from anywhere in your terminal. The basic syntax is:

klube <command> [arguments]

If Klube doesn't recognize the command, it will pass it through to kubectl along with any arguments.

Key Features

Flexible Pod Identification

One of Klube's standout features is its flexible pod identification system. Unlike traditional kubectl commands that require exact pod names, Klube allows you to use as many or as few identifiers as you need to uniquely identify a pod. This can significantly speed up your workflow, especially in environments with many similarly named pods.

For example, if you have a pod named backend-service-5f7d9c7b5-2nlzx, you could use any of the following to identify it:

klube logs backend
klube logs backend service
klube logs backend-service-5f7d9c7b5-2nlzx

Klube will find the first pod that matches all provided identifiers. This feature works across all Klube commands, making it a powerful tool for quick Kubernetes operations.

Flexible Namespace Selection

Klube provides multiple ways to specify the Kubernetes namespace you want to work with, offering flexibility and ease of use:

  1. Command-line argument: klube --namespace mynamespace <command>
  2. Environment variable: export LUBE_NAMESPACE=mynamespace
  3. User configuration file: Set using klube config NAMESPACE mynamespace
  4. Default: If not specified, Klube uses the "default" namespace

The order of precedence is: Command-line argument > Environment variable > User configuration file > Default

This allows you to easily switch between namespaces for different projects or environments without modifying your scripts or commands.

Commands

Klube currently supports the following commands:

  • logs: View logs from a pod
  • exec: Execute a command in a pod
  • cp: Copy files to or from a pod
  • config: View or set configuration options

Examples

[Examples remain the same as in the previous version]

Configuration

Klube uses a user-specific configuration file located at ~/.klube/config.json. This file is created automatically during the installation process, and it can be viewed or modified using the klube config command.

The initial configuration file includes:

  • NAMESPACE: The default Kubernetes namespace to use (default: "default")

You can add other configuration options as needed. Remember that the namespace specified in the config file can be overridden by an environment variable or command-line argument.

To view your current configuration:

klube config

To modify a configuration option:

klube config KEY VALUE

For example, to change the default namespace:

klube config NAMESPACE my-namespace

Project Structure

klube/
├── setup.py
├── post_install.py
├── README.md
├── main.py
└── commands/
    ├── base.py
    ├── logs/
    │   └── handler.py
    ├── exec/
    │   └── handler.py
    └── cp/
        └── handler.py
  • setup.py: Package configuration for installation
  • post_install.py: Script to set up initial configuration during installation
  • main.py: Entry point for the CLI tool, handles configuration and command routing
  • commands/: Directory containing command handlers
    • base.py: Base class for command handlers
    • logs/, exec/, cp/: Specific command implementations

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

Release files for klube 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for klube 0.1.0
File Interpreter ABI Platform
klube-0.1.0-py3-none-any.whl Python 3 none any Details

Release files / klube-0.1.0-py3-none-any.whl

Download URL klube-0.1.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a01ba42af2241cf1aec6a8de1a7881b1d2a33ef70b836b5d0af81df8e879a47
BLAKE2b-256 checksum
How to use checksums
3c049a5b24217b4dddd93350e653b06343c88db2c6984b89ebc86b7726305bc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page