LinuxCommandLibrary

kubie

Manage multiple Kubernetes contexts easily

TLDR

Display a selectable menu of contexts

$ kubie ctx
copy

Switch current shell to the given context
$ kubie ctx [context]
copy

Switch current shell to the given namespace
$ kubie ns [namespace]
copy

Switch current shell to the given context and namespace
$ kubie ctx [context] -n [namespace]
copy

Execute a command in the given context and namespace, without spawning a shell
$ kubie exec [context] [namespace] [command]
copy

Check the Kubernetes configuration files for issues
$ kubie lint
copy

SYNOPSIS

kubie [OPTIONS] COMMAND [ARGS...]

Common Commands:
kubie shell [OPTIONS]
kubie exec [OPTIONS] -- COMMAND [ARGS...]
kubie ctx [CONTEXT] [OPTIONS]
kubie ns [NAMESPACE] [OPTIONS]
kubie edit
kubie view
kubie setup SHELL

PARAMETERS

-c, --context <NAME>
    Specify the Kubernetes context to use for the operation. Can be used with shell, exec, ctx.

-n, --namespace <NAME>
    Specify the Kubernetes namespace to use for the operation. Can be used with shell, exec, ns.

--cluster <NAME>
    Filter available contexts by the associated cluster name. Useful when listing or selecting contexts.

--file <PATH>
    Specify an alternative kubeconfig file to load contexts from, overriding the default KUBECONFIG.

--env <KEY=VALUE>
    Set an environment variable for the new shell or command being executed (e.g., with shell or exec).

--shell <SHELL>
    Specify the shell to launch (e.g., bash, zsh, fish) when using kubie shell.

--raw
    Output raw context or namespace names without additional formatting, useful for scripting (e.g., with ctx or ns).

--no-fzf
    Disable the interactive fuzzy finder when selecting contexts or namespaces, forcing a direct lookup or listing.

-h, --help
    Display help message for the command or subcommand.

-V, --version
    Display version information.

DESCRIPTION

kubie is a powerful command-line tool designed to streamline interaction with Kubernetes clusters by simplifying the management of kubeconfig contexts and namespaces. It provides an intuitive way to switch between different Kubernetes environments without manually manipulating the KUBECONFIG environment variable or using complex kubectl config commands.

Written in Rust for performance, kubie enhances productivity by allowing users to quickly open new shells or execute commands within a specific context and namespace. It helps prevent accidental operations on the wrong cluster or namespace, a common pitfall in multi-cluster Kubernetes environments. Its key features include a fuzzy finder for quick selection, support for multiple kubeconfig files, and seamless shell integration.

CAVEATS

kubie relies on modifying the KUBECONFIG environment variable internally, which might occasionally lead to unexpected interactions if other tools also extensively manipulate this variable in a non-standard way. Shell integration (via kubie setup) is crucial for a smooth user experience, and incorrect setup can lead to functional issues. Users should be mindful of the contexts they are operating in, as kubie provides powerful access but does not add an additional layer of authorization.

INSTALLATION AND SETUP

kubie can be installed via cargo (Rust's package manager) using cargo install kubie, or by downloading pre-compiled binaries from its GitHub releases page. After installation, shell integration is required for full functionality. This is typically done by running eval "$(kubie setup <YOUR_SHELL>)" (e.g., zsh, bash, fish) in your shell's configuration file (e.g., .zshrc, .bashrc) to enable features like prompt updates and fuzzy finding.

TYPICAL USAGE

The most common use cases involve kubie shell to open a new shell with a specific context/namespace, or kubie exec to run a single command. For quick switching within the current shell, kubie ctx and kubie ns allow interactive selection (often with fuzzy search) or direct specification of the target context or namespace, updating your prompt accordingly. This greatly simplifies daily operations for Kubernetes administrators and developers.

HISTORY

kubie was created by @johannestroeger and is developed in Rust, emphasizing performance and reliability. It emerged as a solution to the common frustration of managing multiple Kubernetes contexts and namespaces efficiently, especially in environments with many clusters or frequent context switching. Its development has focused on providing a user-friendly and robust alternative to manual kubeconfig management, gaining popularity in the Kubernetes community for its ease of use and powerful features.

SEE ALSO

kubectl(1), kube-ps1(1), k9s(1)

Copied to clipboard