krew kubectl plugin manager

Version 0.5.0 · source

Start here

kubectl krew update
Refresh plugin index
kubectl krew search
Browse plugins
kubectl krew search <keyword>
Filter by keyword
kubectl krew info <plugin>
Plugin details
kubectl krew install <plugin>
Install a plugin
kubectl <plugin>
Run it
kubectl krew list
What is installed
kubectl krew upgrade
Update everything

Concepts

  1. Index git repo of manifests
  2. search / info find a plugin
  3. ~/.krew/bin on your PATH
  4. Run as a kubectl command

Setup

export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
Put krew plugins on PATH (bash/zsh)
Add to .bashrc or .zshrc, then restart the shell.
kubectl krew
Check the install works
set -gx PATH $PATH $HOME/.krew/bin
Put plugins on PATH (fish)
export KREW_ROOT=<dir>
Use another install directory
Keep it set afterwards and add $KREW_ROOT/bin to PATH.
rm -rf -- ~/.krew
Uninstall krew and all plugins
export KREW_NO_UPGRADE_CHECK=1
Silence upgrade reminders

Discover

kubectl krew update
Refresh the plugin index
kubectl krew search
List all available plugins
kubectl krew search <keyword>
Search plugins by keyword
kubectl krew info <plugin>
Show plugin version and description

Install and run

kubectl krew install <plugin>
Install a plugin
kubectl krew install <plugin> <plugin>
Install several at once
kubectl <plugin>
Run an installed plugin
kubectl krew install <index>/<plugin>
Install from a named index
Plugins from the default index need no prefix.
kubectl plugin list
All kubectl plugins, krew or not

Manage

kubectl krew list
List plugins installed via krew
kubectl krew upgrade
Upgrade all plugins (and krew)
kubectl krew upgrade <plugin>...
Upgrade only the named plugins
kubectl krew uninstall <plugin>...
Remove plugins
kubectl krew list | tee backup.txt
Back up the installed list
kubectl krew install < backup.txt
Restore plugins from the list

Indexes

kubectl krew index list
Show configured indexes
kubectl krew index add <name> <git-uri>
Add a custom index
Any git remote works, including SSH addresses.
kubectl krew index remove <name>
Remove an index
export KREW_DEFAULT_INDEX_URI=<git-uri>
Replace the default index
Set before installing krew or after removing the default index.
kubectl krew install --enable-netrc <index>/<plugin>
Install from a private registry
kubectl krew install --netrc-file <path> <index>/<plugin>
Use a custom .netrc file
export HTTPS_PROXY="<host:port>"
Install behind a proxy
HTTP_PROXY and NO_PROXY are honoured too.

Recipes

First plugin
kubectl krew updatekubectl krew search treekubectl krew info treekubectl krew install treekubectl tree deployment <name>
Move plugins to a new machine
# old machinekubectl krew list | tee backup.txt# new machine, after installing krewkubectl krew install < backup.txt
Keep everything current
kubectl krew updatekubectl krew upgradekubectl krew list
Private plugin index
kubectl krew index add corp git@github.com:corp/krew-index.gitkubectl krew searchkubectl krew install corp/<plugin>