Introduction to plugin development
If you are looking to start developing plugins for
kubectl, read the
on this topic.
To summarize the documentation, the procedure is to:
- Write an executable binary, named
kubectl-foo to have a plugin that can be
- Place the executable to a directory listed in user’s
variable. (Plugins distributed with Krew don’t need to worry about this).
- You can’t overwrite a builtin
kubectl command with a plugin.
If you are writing a plugin in Go: Consider using the cli-runtime project
which is designed to provide the same command-line arguments, kubeconfig
parser, Kubernetes API REST client, and printing logic. Look at
sample-cli-plugin for an example of a kubectl plugin.
Also, there’s an unofficial GitHub template
repo for a Krew plugin
in Go that implements some best practices mentioned in this guide, and helps
you automate releases using GoReleaser to create release when a tag is pushed.
While developing a plugin, make sure you check out:
After you develop a plugin with a good name following the best practices, you
can develop a Krew plugin manifest and
submit your plugin to Krew.