Working Effectively with Kubernetes

by Extending Your kubectl

MorningSpace

## kubectl and Its Plugins * kubectl is the essential utility to interact with Kubernetes cluster. * kubectl plugins extend kubectl with new commands, allowing for new and custom features not included in the main distribution of kubectl. * A plugin is a standalone executable file, whose name begins with `kubectl-`.
## Write a kubectl Plugin 1. Write plugin in any programming language or script. 2. Make the plugin executable, e.g.: using `chmod`. 3. Place it anywhere in your PATH to install the plugin. https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/
## Distribute Your kubectl Plugin * [Krew](https://krew.dev/), as a plugin manager maintained by the Kubernetes SIG CLI community, offers a cross-platform way to package and distribute your plugins. * Krew maintains a [plugin index](https://krew.sigs.k8s.io/plugins/) so that other people can discover your plugin and install it. ```shell # Install kubectl plugin using krew $ kubectl krew install <your_plugin> # Print help information for the kubectl plugin $ kubectl <your_plugin> --help ```
## Reference Cases | Plugin | Description |:-- |:-- |[KubeAssert](https://github.com/morningspace/kubeassert) | Assert Kubernetes resources from command line. |[KubeMacro](https://github.com/morningspace/kubemacro) | Wrap a set of kubectl or Kubernetes API calls as a macro, a single unit of work, to run from command line.

KubeAssert

KubeMacro

Thanks !

Find me by visiting: