Skip to content
This repository has been archived by the owner on Sep 8, 2022. It is now read-only.
/ kubectl-ns Public archive

Simple kubectl plugin to display/switch namespaces

License

Notifications You must be signed in to change notification settings

postfinance/kubectl-ns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Release Software License Go Report Card

THIS PLUGIN IS ARCHIVED.

Please use kubectx instead.

kubectl ns plugin

Simple Plugin to display/change the current kube namespace with support for substring matching.

Build/Installation

Build from source

go version >= 1.13 with modules support enabled is required to build the plugin from source.

export GO111MODULES=on # optional if checked out outside of $GOPATH
go build

Installation

Pre-compiled statically linked binaries are available on the releases page.

Binary must be placed anywhere in $PATH named kubectl-ns 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). Supports the oidc, gcp and azure auth provider for authentication against the k8s api server.

Examples

For all the examples, assume your cluster has the following namespaces:

default
kube-system
kube-public
ingress-nginx
foo
bar
baz

display namespaces

Current namespace is displayed in a different color and last.

$ kubectl ns
default
kube-system
kube-public
ingress-nginx
foo
bar
baz

Substring matching can be used to display namespaces. For example if you are searching for a kube- namespace simply type:

$ kubectl ns kube-
kube-system
kube-public

change current namespace

You can switch the namespace by providing an exact name:

$ kubectl ns foo
namespace set to "foo"

But it's also possible to switch to the ingress-nginx namespace by typing a substring (as long as it is a unique name), for example:

$ kubectl ns ingress
namespace set to "ingress-nginx"