6 K8s collaboration tools to help you improve work efficiency

Kubernetes is a powerful container orchestration platform for automating deployment, management, and scaling of complex applications. Kubectl, a command line tool, is officially provided to allow users to interact with Kubernetes clusters using CLI (command line interface).

Over the years, Kubectl has been deeply integrated with other tools developed by the open source community, which not only improves the user experience, but also makes our production work more efficient. Below, I will introduce several powerful tools that are convenient for you to use Kubernetes for your reference.

In order to facilitate the testing of the following tools, it is recommended to use kind to create a Kubernetes cluster locally. Using kind can facilitate the installation of the Kubernetes cluster and clean it up at the end.

# install kindbrew install kind# create clusterkind create cluster --name playground --image kindest/node:v1.21.14

01

K9s

K9s is a terminal UI that can interact with the K8s cluster. It makes it easy to browse your namespaces, services, deployments, etc., and continuously monitors Kubernetes for changes, making it easier to manage applications.

brew install k9s

02

Popeye

Popeye is an open source tool that scans live Kubernetes clusters and reports potential issues with deployed resources and configurations. It cleans up the cluster based on what is deployed. Scanning the cluster detects misconfigurations and helps us ensure best practices. Additionally, if our Kubernetes cluster is overloaded, it will report over/under-allocated resources and warn when the cluster is running low on capacity. ​​​​​​​​

# Installbrew install derailed/popeye/popeye# Runpopeye

03

Kube-bench

Kube-bench is also a handy tool to check whether the Kubernetes cluster is safely deployed through the records in the CIS Kubernetes Benchmark test. ​​​​​​​​

# Run kube-bench as a job and inspect the logscurl https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job.yaml | kubectl apply -f -# get the logs, replace <kube-bench-95cf7> with your pod idkubectl logs kube-bench-95cf7 -f

Once the job is running, just select the container and check the logs. Similarly, we can use K9s to quickly observe the cluster when we are dealing with the cluster.

04

Kubectx
Kubens and fzf

Typically, you may have multiple clusters, dev/test/production, local or cloud. We can use Kubectx and Kubens to quickly switch directly between different clusters and namespaces . Besides that,  fzf provides an interactive way to switch contexts , so you don't have to remember any clusters or namespaces.

  • # Install kubectx, kubens, fzfbrew install kubectx fzf# Switch between namespaceskubens

05

Stern

Stern allows us to use multiple Pods on Kubernetes, helping us collect logs from different Pods and differentiate them by color.

The query is a regex that doesn't require specifying an exact ID, and can also easily filter out Pod names. If a Pod is deleted, it is removed from the tail, and if a new Pod is added, it is automatically dragged to the tail. When a Pod contains multiple containers, Stern can also directly view the logs of all containers in the Pod instead of viewing them individually. ​​​​​​​​

# Installbrew install stern# stern <keyword>stern deploy

In this example with 3 replicas, we can aggregate the logs by selecting the Pod with the key. As you can see, each Pod corresponds to a different color.

06

Bat

Bat can provide syntax highlighting for us when viewing yaml in the shell environment. ​​​​​​​​

# Install batbrew install bat# Explore themesbat --list-themes# Bat a filebat deployment.yaml

I hope this article is useful to everyone, and more software tools that work well with Kubernetes are waiting for us to explore and discover together.

Reference link:

[1] kind (k8s.io): https://kind.sigs.k8s.io/

[2] GitHub - derailed/k9s: Kubernetes CLI To Manage Your Clusters In Style!: https://github.com/derailed/k9s

[3] GitHub - derailed/popeye: A Kubernetes cluster resource sanitizer: https://github.com/derailed/popeye

[4] GitHub - aquasecurity/kube-bench: Checks whether Kubernetes is deployed according to security best practices as defined in the CIS Kubernetes Benchmark: https://github.com/aquasecurity/kube-bench

[5] GitHub - ahmetb/kubectx: Faster way to switch between clusters and namespaces in kubectl: https://github.com/ahmetb/kubectx

[6] GitHub - wercker/stern: Multi pod and container log tailing for Kubernetes: https://github.com/wercker/stern

[7] GitHub - sharkdp/bat: A cat clone with wingshttps://github.com/sharkdp/bat


 author of this article 

Cheng Rui

Cloud Native Research Institute Product Manager

Guess you like

Origin blog.csdn.net/DaoCloud_daoke/article/details/127392373