How to install k9s (kubernetes cli) on linux

How to Install K9s (Kubernetes CLI) on Linux

In this article, we will see how to install k9s (Kubernetes CLI) on Linux to manage Kubernetes Clusters. K9s is a powerful command-line interface (CLI) tool designed to simplify and enhance the interaction with Kubernetes clusters. It provides a terminal-based user interface, enabling developers and system administrators to manage and observe Kubernetes resources and their status more efficiently. K9s streamlines the workflow with Kubernetes, making it more accessible and user-friendly, especially for those who prefer working within a terminal environment. Here we will see how to install K9s (Kubernetes CLI) on Linux.

 

Key Features

a) Interactive Interface: K9s offers a text-based user interface that is interactive and easy to navigate. It displays Kubernetes resources in a well-organized and readable format.

Sponsored

b) Real-Time Monitoring: One of the standout features of K9s is its ability to monitor Kubernetes resources in real-time. This allows users to observe the live status of their cluster, including pods, nodes, deployments, and more.

c) Resource Management: With K9s, users can perform various resource management tasks such as viewing, creating, updating, and deleting Kubernetes resources directly from the interface.

d) Logs and Debugging: K9s provides easy access to logs of Kubernetes pods, making it simpler to troubleshoot issues. Users can tail logs of multiple pods and containers for real-time monitoring.

e) Filtering and Searching: The tool allows users to filter and search for specific Kubernetes resources, which can be particularly useful in large clusters with numerous resources.

f) Port Forwarding and Shell Access: K9s supports port forwarding to Kubernetes pods and provides shell access for direct interaction with containers, enhancing debugging and interaction capabilities.

g) Customizable and Extensible: Users can customize the tool’s behavior and appearance to suit their preferences. K9s also supports plugins, allowing for further extensibility.

See also  How to Add User to Sudoers & Add User to Sudo Group on Ubuntu

h) Kubernetes Context Management: It allows users to switch between different Kubernetes contexts easily, which is helpful when managing multiple clusters.

i) Shortcut Keys: K9s offers numerous keyboard shortcuts for common tasks, increasing efficiency and reducing the need for typing long kubectl commands.

 

How to install k9s (kubernetes cli) on linux

How to Install K9s (Kubernetes CLI) on Linux

Also Read: How to Install latest version of Golang(Go) in Linux

Step 1: Prerequisites

a) You should have a running Linux System.

b) You should have sudo or root access to run privileged commands.

c) You should have wget or curl utility available in your Server.

d) You should have atleast GO v1.20 or above installed in your System.

e) You should also have make utility installed in your System.

 

Step 2: Update Your System

Before installing K9s in your system, it is recommended to check and install all the latest available updates to keep your server safe and secure from any potential vulnerabilities and bugs. If you are using ubuntu or debian based linux then you can update packages by running sudo apt update && sudo apt upgrade command as shown below.

Sponsored
sudo apt update && sudo apt upgrade

If you are using RHEL or CentOS or Fedora based linux then you can update packages by running either sudo yum update && sudo yum upgrade or sudo dnf update && sudo dnf upgrade command as shown below.

sudo yum update && sudo yum upgrade
sudo dnf update && sudo dnf upgrade

 

See also  High-performance computing (HPC) technologies: what does the future hold? [part 6]

Step 3: Download K9s

You have to visit GitHub website and download the latest version of K9s using any of the file downloader utility such as wget or curl utility. Here we are downloading the file using wget utility as shown below. Below command download the tarball in current working directory.

cyberithub@ubuntu:~$ wget https://github.com/derailed/k9s/archive/refs/tags/v0.29.1.tar.gz
--2023-12-16 22:52:34-- https://github.com/derailed/k9s/archive/refs/tags/v0.29.1.tar.gz
Resolving github.com (github.com)... 20.207.73.82
Connecting to github.com (github.com)|20.207.73.82|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/derailed/k9s/tar.gz/refs/tags/v0.29.1 [following]
--2023-12-16 22:52:35-- https://codeload.github.com/derailed/k9s/tar.gz/refs/tags/v0.29.1
Resolving codeload.github.com (codeload.github.com)... 20.207.73.88
Connecting to codeload.github.com (codeload.github.com)|20.207.73.88|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: ‘v0.29.1.tar.gz’

v0.29.1.tar.gz [ <=> ] 6.39M 3.26MB/s in 2.0s

2023-12-16 22:52:37 (3.26 MB/s) - ‘v0.29.1.tar.gz’ saved [6702839]

 

Also Read

 

Step 4: Extract File

To extract files from tarball, run tar -xzvf v0.29.1.tar.gz command as shown below. This will create a directory called k9s-0.29.1 in current location and extract all files in it.

cyberithub@ubuntu:~$ tar -xzvf v0.29.1.tar.gz
k9s-0.29.1/
k9s-0.29.1/.codebeatsettings
k9s-0.29.1/.dockerignore
k9s-0.29.1/.github/
k9s-0.29.1/.github/FUNDING.yml
k9s-0.29.1/.github/ISSUE_TEMPLATE/
k9s-0.29.1/.github/ISSUE_TEMPLATE/bug_report.md
k9s-0.29.1/.github/ISSUE_TEMPLATE/feature_request.md
k9s-0.29.1/.github/dependabot.yml
k9s-0.29.1/.github/workflows/
k9s-0.29.1/.github/workflows/lint.yml
k9s-0.29.1/.github/workflows/test.yml
k9s-0.29.1/.gitignore
k9s-0.29.1/.golangci.yml
k9s-0.29.1/.goreleaser.yml
k9s-0.29.1/.semaphore/
k9s-0.29.1/.semaphore/semaphore.yml
k9s-0.29.1/.travis.yml
k9s-0.29.1/CNAME
k9s-0.29.1/COPYING
k9s-0.29.1/Dockerfile
k9s-0.29.1/LICENSE
k9s-0.29.1/Makefile
k9s-0.29.1/README.md
k9s-0.29.1/assets/
k9s-0.29.1/assets/imhotep_logo.png
k9s-0.29.1/assets/k9s-xmas.png
k9s-0.29.1/assets/k9s.png
k9s-0.29.1/assets/k9s_doc.png
k9s-0.29.1/assets/k9s_err.png
k9s-0.29.1/assets/k9s_fez.png
k9s-0.29.1/assets/k9s_health.png
k9s-0.29.1/assets/k9s_helm.png
k9s-0.29.1/assets/k9s_popeye.png
k9s-0.29.1/assets/k9s_small.png
k9s-0.29.1/assets/k9s_xray.png
k9s-0.29.1/assets/k9salpha.png
k9s-0.29.1/assets/logo.png
k9s-0.29.1/assets/logo_w.png
k9s-0.29.1/assets/mail.png
k9s-0.29.1/assets/popeye/
k9s-0.29.1/assets/popeye/report.png
k9s-0.29.1/assets/popeye/sanitizers.png
k9s-0.29.1/assets/screen_dp.png
k9s-0.29.1/assets/screen_logs.png
k9s-0.29.1/assets/screen_po.png
k9s-0.29.1/assets/shirts/
k9s-0.29.1/assets/shirts/k9s_back.png
k9s-0.29.1/assets/shirts/k9s_front.png
k9s-0.29.1/assets/skins/
k9s-0.29.1/assets/skins/dracula.png
k9s-0.29.1/assets/story/
...............................................

 

Also Read

 

Step 5: Build Files

Then switch to directory using cd k9s-0.29.1 command and build all the files using make build command as shown below. This command will read build rules from Makefile and execute all the steps as per the defined rule. You have to patiently wait for sometime to complete the build step.

cyberithub@ubuntu:~$ cd k9s-0.29.1/
cyberithub@ubuntu:~/k9s-0.29.1$ make build
fatal: not a git repository (or any of the parent directories): .git
go: downloading k8s.io/client-go v0.28.4
go: downloading k8s.io/klog/v2 v2.110.1
go: downloading github.com/mattn/go-colorable v0.1.13
go: downloading github.com/rs/zerolog v1.31.0
go: downloading github.com/spf13/cobra v1.8.0
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading k8s.io/cli-runtime v0.28.4
go: downloading github.com/go-logr/logr v1.3.0
go: downloading github.com/fvbommel/sortorder v1.1.0
go: downloading k8s.io/api v0.28.4
go: downloading k8s.io/apimachinery v0.28.4
go: downloading k8s.io/metrics v0.28.4
go: downloading github.com/adrg/xdg v0.4.0
go: downloading github.com/derailed/tcell/v2 v2.3.1-rc.3
go: downloading github.com/derailed/tview v0.8.2
go: downloading github.com/fsnotify/fsnotify v1.7.0
go: downloading github.com/mattn/go-runewidth v0.0.15
go: downloading github.com/sahilm/fuzzy v0.1.0
go: downloading golang.org/x/text v0.14.0
go: downloading github.com/atotto/clipboard v0.1.4
........................................................

 

Also Read

 

Step 6: Check Version

After running successful build, you can check the current installed version by running ./execs/k9s version command as shown below.

cyberithub@ubuntu:~/k9s-0.29.1$ ./execs/k9s version
 ____   __.________
|    |/ _/   __    ______
|      < ____     / _ __/
|    |      /    /___ 
|____|__  /____//____   >
        /            /

Version: v0.29.0
Commit:
Date: 2023-12-17T07:52:47Z

 

Step 7: Execute K9s

To execute and start k9s terminal, you can run ./execs/k9s command. This will start the CLI which can then further be used to manage your Kubernetes Cluster.

cyberithub@ubuntu:~/k9s-0.29.1$ ./execs/k9s

 

Step 8: Check all available options

To check all the options available with k9s utility, you can use ./execs/k9s --help command as shown below.

cyberithub@ubuntu:~/k9s-0.29.1$ ./execs/k9s --help
K9s is a CLI to view and manage your Kubernetes clusters.

Usage:
k9s [flags]
k9s [command]

Available Commands:
completion    Generate the autocompletion script for the specified shell
help          Help about any command
info          Print configuration info
version       Print version/build info

Flags:
  -A, --all-namespaces                Launch K9s in all namespaces
      --as string                     Username to impersonate for the operation
      --as-group stringArray          Group to impersonate for the operation
      --certificate-authority string  Path to a cert file for the certificate authority
      --client-certificate string     Path to a client certificate file for TLS
      --client-key string             Path to a client key file for TLS
      --cluster string                The name of the kubeconfig cluster to use
  -c, --command string                Overrides the default resource to load when the application launches
      --context string                The name of the kubeconfig context to use
      --crumbsless                    Turn K9s crumbs off
      --headless                      Turn K9s header off
  -h, --help                          help for k9s
      --insecure-skip-tls-verify      If true, the server's caCertFile will not be checked for validity
      --kubeconfig string             Path to the kubeconfig file to use for CLI requests
      --logFile string                Specify the log file (default "/tmp/k9s-cyberithub.log")
  -l, --logLevel string               Specify a log level (info, warn, debug, trace, error) (default "info")
      --logoless                      Turn K9s logo off
  -n, --namespace string              If present, the namespace scope for this CLI request
      --readonly                      Sets readOnly mode by overriding readOnly configuration setting
  -r, --refresh int                   Specify the default refresh rate as an integer (sec) (default 2)
      --request-timeout string        The length of time to wait before giving up on a single server request
      --screen-dump-dir string        Sets a path to a dir for a screen dumps
      --token string                  Bearer token for authentication to the API server
      --user string                   The name of the kubeconfig user to use
      --write                         Sets write mode by overriding the readOnly configuration setting

Use "k9s [command] --help" for more information about a command.


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply