kubectl ctx plugin
Simple Plugin to display/change the current kube context in your KUBECONFIG.
Installation
Pre-compiled statically linked binaries are available on the releases page.
Binary must be placed anywhere in $PATH
named kubectl-ctx
with execute permissions.
For further information, see the offical documentation on plugins here.
Compatibility
Known to work on Windows and Linux. Requires kubectl >= 1.12 (tested with versions >1.12).
Examples
For all the examples, assume you have the following contexts.
foo
bar
baz
localhost
display contexts
Current context is displayed in a different color.
$ kubectl ctx
bar
baz
foo
localhost
Substring matching can be used to display contexts. For example if you are searching a context named ba
simply type:
$ kubectl ctx ba
bar
baz
change current context
You can switch the context by providing an exact name:
$ kubectl ctx foo
current context set to "foo"
But it's also possible to switch to the localhost
context by typing a substring (as long as it is a unique name), for example:
$ kubectl ctx local
current context set to "localhost"