Having a running cluster means nothing without the ability to interact with it. To this end we can take two routes: terminal or graphical interface.
kubectl is the official command-line tool and allows us to interact with the Kubernetes APIs that are provided by the cluster control plane. Any operation, ranging from describing a payload to deploying an application can be performed via Kubectl.
In our example below, we easily return a list of pods running in a ‘demo’ namespace and obtain a set of logs from a pod:
kubectl get pods -n demo
kubectl logs my-pod -n demo
kubectx and kubens on the other hand, allows for the pre-selection of a cluster and a namespace where commands can be run respectively. This is mostly a cosmetic improvement, but one that saves the excessive typing of commands.
For instance, in our previous example above we used commands that referenced a namespace - this can be omitted when using kubens:
# all further commands will now apply to demo namespace
kubectl get pods
kubectl logs my-pod
k9s is a significantly different tool - a terminal UI application that provides a way to look in-depth at a selected cluster. It has built-in dashboards and metric aggregation that allows us to track both cluster and applications health. It’s also able to perform simple day-to-day tasks such as listing running pods or getting the logs from a payload.
List of pods and its resource footprint (source)
Lens IDE is a powerful, standalone GUI application that can control and explore Kubernetes clusters graphically. Whether running commands against a cluster, deploying an application via Helm, or just exploring Ingress configurations, Lens does it all visually.
List of pods and details of a particular pod (source)
No matter how different these tools may appear at first glance, they are all based upon one source of truth, the official Kubernetes APIs. Choosing one tool over another might be a matter of practicality, use case limitations (for example, usage of CLIs in CI/CD pipelines) or just personal preference.