UbuntuUbuntu Based

How To Install K9s on Ubuntu 24.04 LTS

Install K9s on Ubuntu 24.04

In the ever-evolving landscape of Kubernetes management, K9s has emerged as a powerful command-line interface (CLI) tool that simplifies cluster navigation and management. This article provides a detailed guide on how to install K9s on Ubuntu 24.04 LTS, the latest long-term support release of the popular Linux distribution. Whether you’re a seasoned DevOps engineer or a Kubernetes newcomer, this tutorial will walk you through the process step-by-step, ensuring you can harness the full potential of K9s for your containerized applications.

Understanding K9s and Its Importance

K9s is a terminal-based UI that offers an intuitive interface for interacting with Kubernetes clusters. It provides real-time information about your cluster’s resources, allowing for quick navigation and management of pods, deployments, services, and more. By installing K9s on Ubuntu 24.04 LTS, you’re equipping yourself with a tool that significantly enhances productivity in Kubernetes operations.

Ubuntu 24.04 LTS, codenamed “Noble Numbat,” is the latest long-term support release from Canonical. It offers a stable and secure foundation for running containerized applications and managing Kubernetes clusters. The combination of K9s and Ubuntu 24.04 LTS provides a robust environment for cloud-native development and operations.

Prerequisites for Installing K9s

Before diving into the installation process, ensure you have the following prerequisites in place:

  • A server or desktop running Ubuntu 24.04 LTS
  • Basic familiarity with Linux command-line operations
  • SSH access to your server (for remote installations)
  • Sudo privileges or root access
  • An active internet connection for downloading packages
  • A Kubernetes cluster configured and accessible (optional, but recommended for immediate use of K9s)

Having these elements in place will ensure a smooth installation process and allow you to start using K9s immediately after installation.

Updating Your Ubuntu 24.04 LTS System

Before installing any new software, it’s crucial to ensure your system is up-to-date. This practice not only enhances security but also ensures compatibility with the latest packages. Follow these steps to update your Ubuntu 24.04 LTS system:

sudo apt update
sudo apt upgrade -y

The first command refreshes the package lists, while the second upgrades all installed packages to their latest versions. The “-y” flag automatically answers “yes” to any prompts, streamlining the upgrade process.

Installing the Snap Package Manager

Snap is a universal package management system developed by Canonical. It simplifies the installation and management of software across Linux distributions. While Ubuntu 24.04 LTS comes with Snap pre-installed, it’s good practice to ensure it’s up-to-date:

sudo apt install snapd -y

After installation, it’s recommended to log out and back in or restart your system to ensure all Snap paths are updated correctly.

Method 1: Installing K9s via Snap

Installing K9s using Snap is the simplest and most straightforward method. It ensures you always have the latest stable version and simplifies future updates. Follow these steps to install K9s via Snap:

sudo snap install k9s

This command downloads and installs the latest version of K9s from the Snap store. Once the installation is complete, you can verify it by checking the version:

k9s version

If you encounter any issues, such as “command not found” errors, ensure that the Snap bin directory is in your PATH. You can add it by appending the following line to your ~/.bashrc or ~/.zshrc file:

export PATH=$PATH:/snap/bin

After making this change, reload your shell configuration or log out and back in for the changes to take effect.

Method 2: Manual Installation from GitHub

For users who prefer more control over the installation process or need a specific version of K9s, manual installation from GitHub is an excellent alternative. This method involves downloading the binary directly from the K9s GitHub repository. Here’s a step-by-step guide:

1. First, create a directory to work in:

mkdir ~/k9s-installation
cd ~/k9s-installation

2. Download the latest release of K9s. Replace the version number with the latest available version from the K9s GitHub releases page:

curl -LO https://github.com/derailed/k9s/releases/download/v0.32.5/k9s_Linux_amd64.tar.gz

3. Extract the downloaded tarball:

tar xf k9s_Linux_amd64.tar.gz

4. Move the K9s binary to a directory in your PATH:

sudo mv k9s /usr/local/bin

5. Verify the installation:

k9s version

This manual installation method gives you more control over the version you’re installing and allows for easy updates by repeating the process with newer releases.

Configuring K9s for Optimal Performance

After successfully installing K9s, you may want to configure it to suit your specific needs and preferences. K9s uses a configuration file located at $HOME/.k9s/config.yml. If this file doesn’t exist, you can create it manually. Here’s an example of a basic configuration:

k9s:
  refreshRate: 2
  maxConnRetry: 5
  enableMouse: true
  headless: false
  logoless: false
  crumbsless: false
  readOnly: false
  noIcons: false
  logger:
    tail: 100
    buffer: 5000
    sinceSeconds: 60
    fullScreenLogs: false
    textWrap: false
    showTime: false

This configuration sets various options like refresh rate, mouse support, and logging preferences. You can modify these settings to optimize K9s for your workflow.

Basic Usage of K9s

Now that K9s is installed and configured, let’s explore its basic usage. To launch K9s, simply open your terminal and type:

k9s

Install K9s on Ubuntu 24.04

K9s will automatically connect to your current Kubernetes context. If you have multiple contexts, you can switch between them using the :context command within K9s.

Here are some basic commands to get you started:

  • :pod – View all pods
  • :deploy – View all deployments
  • :svc – View all services
  • :ns – Switch namespaces
  • ? – View help and all available commands

Navigate through the interface using arrow keys, and press Enter to select an item for more details or actions.

Troubleshooting Common Issues

While installing and using K9s on Ubuntu 24.04 LTS is generally straightforward, you might encounter some issues. Here are solutions to common problems:

1. “Command not found” error

If you receive a “command not found” error when trying to run K9s, ensure that the installation directory is in your PATH. For Snap installations, add /snap/bin to your PATH as mentioned earlier.

2. Connection issues with Kubernetes cluster

If K9s can’t connect to your Kubernetes cluster, verify that your kubeconfig file is correctly set up. You can check your current context with:

kubectl config current-context

3. Performance issues

If K9s is running slowly, try adjusting the refresh rate in the configuration file. A higher value will reduce resource usage but update less frequently.

4. Display issues

If you’re experiencing display problems, ensure your terminal supports true color. You can also try running K9s with the --readonly flag to reduce screen updates.

Congratulations! You have successfully installed K9s. Thanks for using this tutorial for installing the K9s Kubernetes CLI on the Ubuntu 24.04 system. For additional help or useful information, we recommend you check the official K9s website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button