Introduction to Kubernetes Management Tools
This article is showing basic commands and information about tools called K9s and Popeye. These tools are really beneficial to manage kubernetes cluster in different ways
Introduction to K9s#
K9s is a terminal-based Kubernetes management tool that provides a streamlined way to interact with Kubernetes clusters. The aim of K9s is to make it easier to navigate, observe and manage your applications.
K9s is one of the most popular kubernetes tools out there and it has plenty of useful, user-friendly features. This article showcases some of the features below.
K9S Installation, Notes and Annotations#
Installation#
Download the Latest Release:
Visit the K9s GitHub Releases and copy download link of the latest Linux binary k9s_Linux_amd64.tar.gz. and download the installation file with:
Extract the Archive:
Move the Binary to PATH:
Verify Installation:
Note: If you are using microk8s and having issues loading data to k9s, you can try this command to fix it:Launching K9s:#
Start K9s by entering k9s in the Linux terminal.
Using K9s to View Kubernetes Resources:#
With K9s, you can inspect Pods, Services, and Nodes the same way it works in Vim. Pressing Ctrl + : and typing commands like po or pods will open a window showing all Pods in the cluster.
Viewing Logs in Real-Time#
K9s updates logs automatically in real-time.
To see pod logs:
1. Go to the <pod> page.
2. Select the pod and press L
To see the logs for a specific container, such as a PrestaShop container:
1. Go to the <pod> page.
2. Open the PrestaShop Pod by pressing Enter.
3. Select the PrestaShop container and press Enter again to view its logs.
Log Management Tips#
- Disable Auto-scroll: Press
Sto stop auto-scrolling when reviewing older logs. - Show Timestamps: Press
Tto display timestamps in logs. - Full-Screen Mode: Press
Fto toggle full-screen mode.
Adjusting Log Display Settings#
By default, K9s shows the last 100 log entries. To change this:
- Navigate to the K9s configuration file:
~/.config/k9s/config.yaml. - Under the
loggersection, adjust thetailvalue to the desired number (e.g.,500to display the last 500 logs).
You can also modify other settings as needed. For example:
Text Wrapping (W)
Showing Timestamps (T)
Additional features#
Delete pods by navigating to the <pod> view, selecting the pod you want to delete and press Ctrl + D and OK
Show All Resource Aliases: Press Ctrl + A.
X-ray View: Use :xray <resource> to inspect resources visually. For example, :xray po displays all Pods and their paths in a single view.
CPU and Memory Usage#
K9s will show CPU and Memory Usage, if you have metrics-server installed. It can be installed with procedures shown below:
Apply the Metrics Server manifest:
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
Verify Installation:
Check if the Metrics Server is running "READY 1/1":
Start the K9s and now you should see your CPU and Memory usage top-left corner under K8s Rev:
pods' CPU and memory usage can be seen after the RESTARTS column in the <pod> view
For more details about CLI arguments and key bindings, visit the official K9s website.
Popeye#
Popeye is a Kubernetes sanitizer tool that scans Kubernetes clusters for configuration issues and best-practice violations.
It inspects resources like Pods, Services, Deployments, and ConfigMaps to detect potential problems such as misconfigurations, outdated settings, and security risks and gives you score out of 100.
Installation#
Download the Latest Release:
Visit the Popeye GitHub Releases and copy download link of the latest Linux binary popeye_linux_amd64.tar.gz. and download the installation file with:
Extract the Archive:
Move the Binary to PATH:
Verify Installation:
How use Popeye#
Type popeye to the terminal to scan your Kubernetes cluster:
If you have a PC with Linux system, you can also download results to .html-file and view popeye results on web browser with
Command prints the path of the file. You can open it with
Kubelinter#
KubeLinter is a static analysis tool designed to identify potential issues and enforce best practices in Kubernetes resources such as YAML files, Helm charts, and Kubernetes manifests. It helps developers and operations teams ensure that their Kubernetes deployments follow security and configuration best practices before they are deployed to a cluster.
Go Installation#
First of all, we need to have Go (Goland). Download it with command
Verify that you've installed Go by typing the following command:
Install KubeLinter using Go#
With Go installed, you can install KubeLinter by running:
Ensure that Go's bin directory is in your PATH. You can add the following line to your ~/.profile or ~/.bashrc:
Reload your profile:
Verify the installation:
Now you can scan your yaml files with: