Skip to content

A kubectl plugin for interactively changing the kubeconfig context

Notifications You must be signed in to change notification settings

weibeld/kubectl-ctx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

kubectl ctx

A kubectl plugin for interactively changing your kubeconfig context.

Demo

This makes it easier to work with multiple clusters from the same machine.

Also see kubectl-ns for switching between namespaces.

Installation

To install the plugin, download the kubectl-ctx file and save it in any directory that is in your PATH:

curl -O https://raw.githubusercontent.com/weibeld/kubectl-ctx/master/kubectl-ctx

Then, make the kubectl-ctx file executable:

chmod +x kubectl-ctx

Now, you can verify that the plugin is correctly installed by running the following command:

kubectl plugin list

This lists all the plugins that kubectl detected, and the kubectl-ctx plugin should now be listed there.

To uninstall the plugin, simply delete the kubectl-ctx file.

Usage

Change the current context:

kubectl ctx

List all contexts:

kubectl ctx -l

How It Works

When you run kubectl ctx, the plugin changes the current-context element of your kubeconfig configuration:

How it works

Note that this includes a physical change to one of your kubeconfig files (the default kubeconfig file is ~/.kube/config, but you can have multiple kubeconfig files by by listing them in the KUBECONFIG environment variable).

When you run kubectl ctx -l, the plugin displays the names of all the contexts in your kubeconfig configuration.

Dependencies

The plugin depends on the fzf command being available on your system.

You can install fzf as follows:

  • Homebrew (macOS) and Linuxbrew (Linux):
    brew install fzf
  • From source (macOS and Linux):
    git clone https://github.com/junegunn/fzf.git ~/.fzf
    ~/.fzf/install
  • For further installation options, see here

About

A kubectl plugin for interactively changing the kubeconfig context

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages