Skip to main content

A simple kubectl context switcher cli tool

Project description

contswi - Kubernetes Context Switcher

contswi is a simple but effective command-line tool designed for Linux environments to quickly switch between different Kubernetes contexts. By leveraging kubectl, this tool allows users to select and change their active context using an intuitive menu-driven interface, navigable with arrow keys.

Features

  • Quickly view all available Kubernetes contexts.
  • Highlight the current active context.
  • Easily switch between contexts using an interactive, arrow-key driven menu.
  • Clean, responsive, and simple interface that fits into any Kubernetes workflow.

Requirements

Before using contswi, ensure you have the following set up:

  1. kubectl: The Kubernetes command-line tool must be installed and properly configured on your system. This application interacts directly with kubectl to retrieve and set contexts.

  2. Pre-configured Kubernetes Contexts: You must have one or more Kubernetes contexts already set up in your kubeconfig. If you don't have any contexts configured, refer to the Kubernetes context documentation to set them up.

Installation

You can install the contswi tool in two ways: directly from the source code or via pip.

1. Installing from Source

  1. Clone the repository:

    git clone https://github.com/yourusername/contswi.git
    cd contswi
    
  2. Install the tool:

    After cloning the repository, you can install the tool locally with pip:

    pip install .
    

2. Installing via pip

To install the tool directly from PyPI, simply run:

pip install contswi

Usage

Once installed, you can use the contswi tool to interactively switch Kubernetes contexts.

Run the tool

contswi

Key Bindings

  • Up Arrow (): Move the selection upwards.
  • Down Arrow (): Move the selection downwards.
  • Enter: Select the highlighted context and switch to it.
  • Ctrl+C: Exit the program at any time.

Example

  1. Running contswi will present a list of your Kubernetes contexts:

      dev-cluster  
    > prod-cluster <  
      staging-cluster  
    
  2. Use the arrow keys to navigate through the contexts and press Enter to switch.

  3. The tool will execute the equivalent of:

    kubectl config use-context <selected_context>
    
  4. You will see the selected context become the active one.

Error Handling

If you encounter any errors or issues with the program (e.g., no configured contexts), the tool will handle it gracefully, providing helpful error messages.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Feel free to submit issues, feature requests, or pull requests to improve the functionality of this tool. Contributions are always welcome!


Author

Gabor Puskas
GitHub
LinkedIn


contswi is designed to make Kubernetes context management fast and simple, enhancing the experience for developers and DevOps engineers working across multiple clusters and environments.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

contswi-0.1.3.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

contswi-0.1.3-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file contswi-0.1.3.tar.gz.

File metadata

  • Download URL: contswi-0.1.3.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.17

File hashes

Hashes for contswi-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6413c30053075b91f5a220ef6fec7f088c474b9a0355400093b2f4040c1c6b5b
MD5 c0a7491394c36e1fd9c3fe39d01eaf2f
BLAKE2b-256 81b3b6e7f605e467ac77194184632aa68b79395a4f6c646dcb13f4616ca6bf7e

See more details on using hashes here.

File details

Details for the file contswi-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: contswi-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.17

File hashes

Hashes for contswi-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b6860c10a427f829819022917a98ba6b1cfa5b7dd994a13ee66c8b7cb6b89bf2
MD5 0e2c8893ac24657424316f934e77d86c
BLAKE2b-256 df49e2d43d24316e7b44dab4a3a30e8b3c67f3c4d2d123bf575c18ccfe4f104c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page