In the dark ages… there was only kubectl

Kubernetes gives you a nice CLI tool named: kubectl

Kubectl — A command line interface for running commands against Kubernetes clusters (from kubernetes.io kubectl overview page)

We found ourselves performing various daily tasks using kubectl, in such a non-productive way; that includes viewing logs, ‘exec’ing into pods, watching deployment initialization process, deleting assets or just visiting our Kubernetes Dashboard.

Moreover, kubectl has auto-completion but its super slow, the search is not good enough and it doesn’t provide enough information on the context such as how many pods are active for the deployment? what’s its status? etc.

For example, in order to fetch logs, the kubectl command logs requires <pod-name> as an argument. Now we have to find the pod name we want either by typing $ kubectl get pods or by using the auto-completion.

This process is super slow so I had to find a way to make this process more efficient (did I mention we are productivity freaks?), so I started using labels which helped me find a subset of resources a bit faster, but even that wasn’t fast enough. Even bash history navigation (CTRL+R) didn’t satisfy my efficiency needs.

And then it hit me!

Introducing Alfred Workflow.

For those who are not familiar with Alfred, you guys are missing out.

Alfred (alternatives you can check: Wox, Hain) is a Mac OS task runner that that greatly extends what Spotlight can do, let’s you be more productive with custom actions, for example, open apps, run scripts and use most of your OS features as you desire; being faster than ever! And most importantly, lets you design completely custom workflows.

Simple To-Do List workflow example - www.alfredapp.com

Kubernetes Alfred Workflow

I decided to build a custom workflow to make the magic happen

(download here) by building a set of commands that wrap kubectl and provide the completion and search capabilities that we so badly missed. These commands include our most common day-to-day operations such as tailing logs, ‘exec’ing into containers etc.