Explore Kubectl Output Implementations

“Special” Strategy Pattern in kubectl Go

Stefanie Lai
CodeX

--

Source: Unsplash, @rachel_4

In my last article, we walked through the usage of kubectl get -o/–output with examples of different formats, which are a little complex that even involve simple coding. To better master and memorize the output cheatsheet, nothing can help more than understanding the logic behind it. So let’s unveil its design and implementation from the kubectl source code.

Why from Source Code

Studying the kubectl source code is time-consuming, but you are well paid off by the benefits, which include but are not limited to

  • The logic helps us quickly understand the basic principles of different output formats, so as to make better use of them.
  • Comprehending kubectl and its related Kubernetes source code deepens our understanding of Kubernetes.
  • Our Go coding skill gets improved.

The Kubernetes source code is very complex with multi repositories involved, which are associated, referred to, and nested with one another. The right thing to do is to find an entry point that facilitates our further study.

My Conjecture on the Design

--

--

No responses yet