K9s is a powerful terminal-based tool designed to simplify the management and monitoring of Kubernetes clusters. Whether you're a Kubernetes beginner or a seasoned user, K9s offers a streamlined interface to navigate and interact with your clusters efficiently. In this guide, we'll walk you through the step-by-step process of installing K9s on Ubuntu.
Prerequisites
Before starting, make sure you have:
Docker.
Minikube.
K9s
Here is a file to install all these in your Ubuntu machine (copy paste line by line)
# Installation of Docker sudo apt update && apt upgrade sudo apt-get remove docker docker-engine docker.io containerd runc sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg sudo echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose -y sudo curl https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker -o /etc/bash_completion.d/docker.sh sudo curl -L https://raw.githubusercontent.com/docker/compose/1.25.1/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose sudo usermod -aG docker $USER newgrp docker # Installation of Minikube curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 sudo install minikube-linux-amd64 /usr/local/bin/minikube #Installation of Kubectl curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl chmod +x kubectl sudo mv kubectl /usr/local/bin/ minikube start --driver=docker # To Change/create password for user sudo passwd ubuntu # Installation of Homebrew to install K9's. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" sudo sudo apt-get install build-essential -y test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv) test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv) test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >> ~/.bash_profile echo "eval \$($(brew --prefix)/bin/brew shellenv)" >> ~/.profile brew install derailed/k9s/k9s k9s
Deploye your k8s application:
kubectl apply -f
your-k8s-files.yaml
Using K9s Shortcuts
Master these shortcuts for efficient cluster management:
?
: Display commands help:pods, :svc, :deploy
: Jump to resources:ns
: Switch namespaces:ctx
: Switch contexts/
: Start a searchctrl-a
: Select all itemsesc
: Clear selection or cancelenter
: View resource detailsl
: View logss
: Shell into a podctrl-c
: Quit K9sfor example press
shift+:
and search ns or namespaces and press enter to view all Namespaces. select the namespace using up and down arrow and press enter to enter into the namespace.to view pods enter
shift+: pods
in the namespace you wantto view nodes enter
shift+: nodes
to view services enter
shift+: svc
in the namespace you wantto view pv enter
shift+: pv
in the namespace you wantto view pvc enter
shift+: pvc
in the namespace you wantto view deployments enter
shift+: deploy
in the namespace you want