kubectl-lsdeploy: A simple kubectl plugin to show deployments along with their pods

kubectl-lsdeploy: A simple kubectl plugin to show deployments along with their pods

Dominik

2 minute read

I started looking a bit into Kubernetes and for no other reason than curiosity I wanted to visualize some dependencies to get a better understanding on how things work, e.g. where my container (pods) actually spawn when I apply one of these nice YAML files with a deployment. Unfortunately I wasn’t able to find a get command within kubectl that showed my all the information in a single call, except if you heavily use labels and selectors. I wanted something simple and found the ability to create kubectl plugins. Long story short, this led to my first personal repo on GitHub – which also happens to be my first Python project:

kubectl-lsdeploy

+----------------------+---------------------------+--------------------------------------+--------------------------------------------+-----------------+
 |      Namespace       |         Deployment        |              ReplicaSet              |                    Pod                     |   Hosting node  |
 +----------------------+---------------------------+--------------------------------------+--------------------------------------------+-----------------+
 |       default        |            demo           |           demo-7cbf698c44            |           demo-7cbf698c44-6z68g            | 192.168.113.131 |
 |       default        |           demo2           |           demo2-5657dc98db           |           demo2-5657dc98db-4jwbk           | 192.168.113.131 |
 |     kube-system      |          coredns          |          coredns-6955765f44          |          coredns-6955765f44-bp7zl          | 192.168.113.131 |
 |     kube-system      |          coredns          |          coredns-6955765f44          |          coredns-6955765f44-k4swp          | 192.168.113.131 |
 |     kube-system      |          coredns          |          coredns-6955765f44          |               etcd-minikube                | 192.168.113.131 |
 |     kube-system      |          coredns          |          coredns-6955765f44          |        kube-addon-manager-minikube         | 192.168.113.131 |
 |     kube-system      |          coredns          |          coredns-6955765f44          |          kube-apiserver-minikube           | 192.168.113.131 |
 |     kube-system      |          coredns          |          coredns-6955765f44          |      kube-controller-manager-minikube      | 192.168.113.131 |
 |     kube-system      |          coredns          |          coredns-6955765f44          |              kube-proxy-mzzd7              | 192.168.113.131 |
 |     kube-system      |          coredns          |          coredns-6955765f44          |          kube-scheduler-minikube           | 192.168.113.131 |
 |     kube-system      |          coredns          |          coredns-6955765f44          |            storage-provisioner             | 192.168.113.131 |
 | kubernetes-dashboard | dashboard-metrics-scraper | dashboard-metrics-scraper-7b64584c5c | dashboard-metrics-scraper-7b64584c5c-6nxks | 192.168.113.131 |
 | kubernetes-dashboard |    kubernetes-dashboard   |    kubernetes-dashboard-79d9cd965    |    kubernetes-dashboard-79d9cd965-fj6lj    | 192.168.113.131 |
 +----------------------+---------------------------+--------------------------------------+--------------------------------------------+-----------------+

The code quality is probably very poor but this time I was more eager to get a minimal working code base out instead of waiting for the perfect result. If nothing else I can now start improving while also gaining more insights into GitHub Actions for some testing and building automation.