Difficulty: Intermediate
Estimated Time: 25 minutes

Creating A Kubectl Plugin

Kubernetes

This scenario takes you through the introductory steps for developing a kubectl plugin. You will create a plugin that will interact with a Kubernetes cluster. While the plugin is it's written in Go the steps will gently guide you, even if you are a bit new at writing code in Golang.

In this scenario you will learn how to:

  • Layout the source directory structure for a kubectl plugin
  • Connect implementation logic to command
  • Work with client references that can administer Kubernetes
  • List and create Pods via a custom plugin

Conclusion

Kubectl offers a helpful plugin feature to extend Kubernetes. The Community supported plugins are quite helpful. But sometimes, what the community offers is not what you you need. Fortunately, you can code you own plugin to solve specific problems related to your domain. If you do create a plugin that can help others, consider adding it to the public community of kubectl plugins.

Lessons Learned

With these steps you have learned:

  • ✔ how to layout the source directory structure for a kubectl plugin,
  • ✔ how to connect implementation logic to command,
  • ✔ how to work with client references that can administer Kubernetes,
  • ✔ how to list and create Pods via a custom plugin

Special Thank You

To Ken Sipe as he inspired this scenario from his labs found here.

References


For a deeper understanding of these topics and more join
Jonathan Johnson
at various conferences, symposiums, workshops and meetups.

Software Architectures ★ Speaker ★ Workshop Hosting ★ Kubernetes & Java Specialist

Kubectl CLI Plugin Development

Step 1 of 11

Your Kubernetes Cluster

For this scenario, Katacoda has just started a fresh Kubernetes cluster for you. Verify it's ready for your use.

kubectl version --short && \ kubectl get componentstatus && \ kubectl get nodes && \ kubectl cluster-info

The Helm package manager used for installing applications on Kubernetes is also available.

helm version --short

Kubernetes Dashboard

You can administer your cluster with the kubectl CLI tool or use the visual Kubernetes Dashboard. Use this script to access the protected Dashboard.

token.sh