Creating a basic plugin
In this section, let's create a simple plugin called toppods
to show Kubernetes cluster nodes. It is just a very simple example of how to create the plugin:
- We are going to create a simple
bash
-based plugin namedkubectl-toppods
:$ cat kubectl-toppods #!/bin/bash kubectl top pods
- Let's copy the
kubectl-toppods
file to the~/bin
path:$ cp kubectl-toppods ~/bin
- Make sure it is executable:
$ chmod +x ~/bin/ kubectl-toppods
- Now let's try to run it:
$ kubectl toppods NAME CPU(cores) MEMORY(bytes) postgresql-57578b68d9-6rpt8 1m 22Mi
Nice! You can see that the plugin is working, and it is not very difficult to create a kubectl
plugin.