Giter VIP home page Giter VIP logo

ktx's Introduction

ktx

Overview

Managing kubeconfig files can become tedious when you have multiple clusters and contexts to switch between. ktx aims to reduce friction caused by switching between various configurations.

ktx takes the approach of modifying the KUBECONFIG environment variable to select the desired config.

Getting Started

Prerequisites

  • Your shell is bash or zsh.
  • git is installed.

Install

# Clone the ktx repo
git clone https://github.com/heptiolabs/ktx
cd ktx

# Install the bash function
cp ktx "${HOME}"/.ktx

# Add this to your "${HOME}/".bash_profile (or similar)
source "${HOME}"/.ktx

# Install the auto-completion
cp ktx-completion.sh "${HOME}"/.ktx-completion.sh

# Add this to your "${HOME}/".bash_profile (or similar)
source "${HOME}"/.ktx-completion.sh

# Reload your shell
exec bash

Usage

Once ktx is installed you can use it as auto-complete:

$ kubectl get po
The connection to the server localhost:8080 was refused - did you specify the right host or port?
# useful to see what clusters you have in ${HOME}/.kube/
$ ktx <tab><tab>
alpha beta gamma delta epsilon
$ ktx gamma
$ kubectl get po
No resources found.

Optional Bells & Whistles

PS1

It is helpful to display the active cluster in the command prompt.

shows the cluster name in the command prompt

Steps

  1. Find out what the current value of PS1: echo "${PS1}"
  2. Put "\$(basename \${KUBECONFIG:=\"\"})" in front of the existing value of PS1

Note: The backslashes are very important. This tells bash to re-evaluate every time instead of once on load.

Example

salazar:ktx cha$ echo "${PS1}"
\h:\W \u$

# inside .bash_profile
export PS1="\$(basename \${KUBECONFIG:=\"\"}) \h:\W \u$ "

# Reload your shell
exec bash

Pronunciation Guide

ktx is pronounced as "k thanks"

ktx's People

Contributors

chuckha avatar xstevens avatar scottslowe avatar asenchi avatar davecheney avatar greenstatic avatar brenix avatar ulrichschreiner avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.