Skip to content

Introduction to Kubernetes Management Tools

Original Author: Anton Jylhä
Lastmod: 11.12.2024
Status: In progress

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:

wget <download link>

Extract the Archive:

tar -xvzf k9s_Linux_amd64.tar.gz

Move the Binary to PATH:

sudo mv k9s /usr/local/bin/

Verify Installation:

k9s version
Note: If you are using microk8s and having issues loading data to k9s, you can try this command to fix it:

microk8s config > ~/.kube/config

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 S to stop auto-scrolling when reviewing older logs.
  • Show Timestamps: Press T to display timestamps in logs.
  • Full-Screen Mode: Press F to toggle full-screen mode.

Adjusting Log Display Settings#

By default, K9s shows the last 100 log entries. To change this:

  1. Navigate to the K9s configuration file: ~/.config/k9s/config.yaml.
  2. Under the logger section, adjust the tail value to the desired number (e.g., 500 to 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":

kubectl get deployment metrics-server -n kube-system

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:

wget <download link>

Extract the Archive:

tar -xvzf popeye_linux_amd64.tar.gz

Move the Binary to PATH:

sudo mv popeye /usr/local/bin/

Verify Installation:

popeye version

How use Popeye#

Type popeye to the terminal to scan your Kubernetes cluster:

popeye

If you have a PC with Linux system, you can also download results to .html-file and view popeye results on web browser with

popeye --save --out html --output-file report.html

Command prints the path of the file. You can open it with

open <PATH>

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

sudo snap install go --classic 

Verify that you've installed Go by typing the following command:

go version

Install KubeLinter using Go#

With Go installed, you can install KubeLinter by running:

go install golang.stackrox.io/kube-linter/cmd/kube-linter@latest

Ensure that Go's bin directory is in your PATH. You can add the following line to your ~/.profile or ~/.bashrc:

export PATH=$PATH:$(go env GOPATH)/bin

Reload your profile:

source ~/.profile

Verify the installation:

kube-linter version

Now you can scan your yaml files with:

kube-linter lint <yaml file>