- Shell 100%
| kubectl-context | ||
| kubectl-ctx | ||
| kubectl-insp | ||
| kubectl-inspect | ||
| kubectl-namespace | ||
| kubectl-ns | ||
| kubectl-show | ||
| README.md | ||
personal kubectl plugin collection
This repo contains a personal collection of useful kubectl utilities I can't live without. Mainly:
kubectl context- switches kubectl context (shorthand:kubectl ctx)kubectl namespace- switches kubectl namespace (shorthand:kubectl ns)kubectl inspect- pipes kubectl get -o yaml output to bat for syntax highlighting (shorthand:kubectl insp)kubectl show- shows truly all resources in the given namespace (unlike kubectl get all; accepts-Aas well for monstrous outputs >:D)
Installation
You can simply clone this repository into ~/.kube/plugins and keep it up-to-date with git:
mkdir -p ~/.kube/plugins
git clone https://gitpot.org/sangelo/kubectl-plugins ~/.kube/plugins
Also make sure to add this directory to your $PATH so you can run the plugins from anywhere.
# in your .bashrc or .zshrc, or whatever shell you use
export PATH="$HOME/.kube/plugins:$PATH"
Usage
kubectl context
Lists all contexts or switches to the specified one.
Usage: kubectl context [CONTEXT_NAME]
- If CONTEXT_NAME is provided, switch to that context
- If no arguments are provided, list all available contexts
Examples
List contexts:
$ kubectl context
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* prod prod.example.com admin default
dev dev.example.com admin kube-system
Switch context:
$ kubectl context dev
Switched to context "dev".
kubectl namespace
Lists all namespaces or switches to the specified one.
Usage: kubectl ns [namespace]
- Switch to the specified namespace or list available namespaces if no argument is provided.
Examples
List namespaces:
$ kubectl namespace
CURRENT NAME
default
* kube-system
example
...
Switch to a namespace:
$ kubectl namespace kube-system
Context "dev" modified.
Switched to namespace: kube-system
kubectl inspect
Inspects a Kubernetes resource and outputs it in the specified format using bat.
Usage: kubectl inspect [-o output_format] <kubectl_args>
-o output_format: Specify output format (e.g.,json,yaml,wide,custom-columns, etc. - default:yaml)kubectl_args: Arguments to pass tokubectl getcommand
Examples
# inspect a pod
kubectl inspect pod my-pod
# inspect a deployment and output to json
kubectl inspect -o json deployment my-deployment
kubectl show
Lists all resources in the specified namespace or the current namespace if no argument is provided.
Difference to kubectl get all: Truly lists all available resources, not just a few basic ones.
Usage: kubectl-show [flags]
- Fetches truly ALL namespaced resources, passing standard
kubectl getflags.
Examples
# show all resources in the current namespace
kubectl show
# show all resources in the "kube-system" namespace
kubectl show -n kube-system
# show all resources in ALL namespaces
kubectl show -A