Snippets are small pieces of code that we often find repeating throughout our days as software engineers. Over time we see patterns and find these snippets are simple strings of code that we like to apply to different contexts. Sometimes we like to share them with our friends as tips, tutorials, or collect them into cheat sheets.
There is a plethora of open source and commercial snippet managers available for various targets. While they all have differentiating features, at their core they manage a library of code snippets. Recently popular are gist repositories that are similar if not the same as snippet libraries.
This scenario focuses on a specific type of snippet manager tuned for command-line interfaces (CLIs). It's called Pet.
Pet is a simple command-line snippet manager.
Snippet managers can be very distracting, as often they ask you to switch context to a different interface and user experience. There you search, find, select, and copy to a clipboard. If you work with a command line, bopping out to a different interface is disruptive to your workflow. A good snippet manager should be right in the CLI, right in the terminal where you are thinking and focused.
Pet is tuned just for CLIs, to allow you to pick and manage snippets. This is particularly helpful when learning or cruising at full speed with Kubernetes tools such as kubectl.
These next steps provide an introduction to Pet as a potential way to increase your productivity and learning with Kubernetes.
You will learn how:
- to install Pet
- to use the Pet commands to manage and use snippets
- to sync your snippets to a Git Gists repository
- to use Pet to manage your Kubernetes cheat sheets
The beauty of Pet is its simplicity. While there are other snippet and gist managers in open source and commercial channels, this one seems ideal for those who wish to remain close and focused at the command line. It's a CLI snippet manager specifically designed for CLI tools, making it helpful for kubectl, oc, linux, helm, ansible, or any other command-line arena where you might have clever patterns and tricks. Manage your tricks in a snippet library and store them in gists. Perhaps Pet will replace your cheat sheets and be the primary source for your favorite snippets.
With these steps you have learned:
- ✔ how to install Pet,
- ✔ how to use the Pet commands to manage and use snippets,
- ✔ how to sync your snippets to a Git Gists repository,
- ✔ how to use Pet to manage your Kubernetes cheat sheets.
Pet, a CLI Snippet Manager
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 && \
The Helm package manager used for installing applications on Kubernetes is also available.
helm version --short
You can administer your cluster with the
kubectl CLI tool or use the visual Kubernetes Dashboard. Use this script to access the protected Dashboard.