I hate using Kubectl command often to manage Kubernetes Cluster ? Here is what I did to avoid using Kubectl

My pug fixing my Bug

Hey everyone hope everything is great during this Pandemic…I am gonna to write this story to my Cloud community and share some tips and techniques what I use to manage the Kubernetes Cluster for my day to day operations.

I always believe in understanding and following all the process and guidelines when a new technology/tool arrives into the market, but once I become expert I believe in making my own way to achieve the same thing with little efforts…as I am big fan of making my own reusable components/tools, frameworks which can make the life easier for the development and also for my team.

I always practice SWAT analysis (See, Think, Do and Care framework) in my professional and personal life and see how better doing each day from yesterday.

In this quick 3 min read article I am going to provide some tips and techniques which can probably save lot of your times , you type in the Kubectl command while managing your Kubernetes cluster….Okay without wasting much time …lets jump in..remember this is not a golden ticket or shortcut rather a way to make life simple during Kubernetes cluster management.

First let me start with ‘alias’ which even people who are working for years in Kubernetes cluster wouldn’t have chance to use this simple feature which makes life simple.

So when I thought what I can do to avoid Kubectl, I did this

$ alias hey=Kubectl

So now for example if I need to list all the resources inside the cluster I can use like below

$ hey get all

instead of “kubectl get all” …sounds great…easy…whatever might be this is bit fun…actually you can make like this to make it more simpler

$ alias k=kubectl

Similar like when I often run the dry run on the busybox which makes me crazy to repeat the same command again and again and this what I did to make my life.

$ alias dr=’kubectl — dry-run=client -o yaml’

so now all I need to do is just run like below

$ dr

To do a dry run test of my busybox…now all I need to do is

$ alias bbt=’kubectl run busybox-test — image=busybox -it — rm — restart=Never — ‘

and then now just do this

$ bbt

Hope this helps and saves some time and fun working with Kubernetes Cluster Management.

Finally one secret tip , if you need Bash autocomplete for Kubectl commands, all you need do is just the below.

echo “source <(kubectl completion bash)” >> ~/.bashrc

Begin your new way of Kubectl

Happy Cluster Management! Enjoy have a great rest of the week.

Please feel free to reach out to me on borntowinuk@gmail.com if you need information or support.

Enterprise Architect — Certified Cloud Specialist (Azure, Google, AWS and Alibaba), AI/AR SME, Cross Platform Mobile Development (React Native, Xamarin, iOS)