DEV Community

CloudGrains
CloudGrains

Posted on

K9s Installation Script for Amazon Linux / RHEL-Based Systems-

This guide provides a shell script to automatically install the latest version of K9s, a terminal UI for managing Kubernetes clusters.

🚀 What This Script Does

Updates system packages

Installs required dependencies (wget, tar)

Fetches the latest K9s release version from GitHub

Downloads and installs the K9s binary

Cleans up leftover files

Verifies the installation

#!/bin/bash

# Update packages and install necessary dependencies
sudo yum update -y
sudo yum install -y wget tar

# Fetch the latest K9s version
K9S_VERSION=$(curl -s https://api.github.com/repos/derailed/k9s/releases/latest | grep tag_name | cut -d '"' -f 4)

# Download the latest K9s release
wget https://github.com/derailed/k9s/releases/download/${K9S_VERSION}/k9s_Linux_amd64.tar.gz

# Check if the download was successful
if [ $? -ne 0 ]; then
  echo "Failed to download K9s. Please check the version number and URL."
  exit 1
fi

# Extract the tarball and move the binary to /usr/local/bin
tar -xzf k9s_Linux_amd64.tar.gz
sudo mv k9s /usr/local/bin/

# Clean up
rm k9s_Linux_amd64.tar.gz

# Verify installation
k9s version

Enter fullscreen mode Exit fullscreen mode

🧩 Usage Instructions

  1. Save the script to a file
nano install_k9s.sh
Enter fullscreen mode Exit fullscreen mode

Paste the script and save.

  1. Make the script executable
chmod +x install_k9s.sh
Enter fullscreen mode Exit fullscreen mode
  1. Run the script
sh install_k9s.sh
Enter fullscreen mode Exit fullscreen mode

✅ Verify Installation

Run the following command:


## k9s version
Enter fullscreen mode Exit fullscreen mode

You should see the installed version printed.

Top comments (0)