Skip to content
Latchkey

kubectl krew install: Usage, Options & Common CI Errors

Install kubectl plugins on a runner from the krew index.

kubectl krew is the plugin manager for kubectl, and krew install adds plugins (kubectl ctx, kubectl ns, kubectl neat) from its index. On a fresh CI runner you install the plugins your scripts call in a setup step.

What it does

kubectl krew install NAME downloads a plugin from the krew-index and drops its binary under the krew bin directory, making it available as kubectl NAME. krew update refreshes the index; krew list shows what is installed. krew itself is installed once, then plugins layer on top.

Common usage

Terminal
kubectl krew update
kubectl krew install ctx ns
kubectl krew install neat
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
kubectl ns my-namespace

Common errors in CI

"kubectl: \"NAME\" is not a kubectl command" after installing means the krew bin dir is not on PATH - export ${KREW_ROOT:-$HOME/.krew}/bin into PATH in the same shell. Fresh runners have no plugins and an empty index, so run krew update before install or you get "plugin NAME does not exist". Installs hit GitHub over the network, so they fail in air-gapped CI unless the plugins are vendored, and an unpinned plugin can change behaviour build-to-build - pin to a known plugin version where the index allows. A cached krew home from a prior job may already have the plugin; krew install on an installed plugin errors, so guard with krew list.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →