'How can I install kubectx on Ubuntu Linux 20.04?

I would like to install kubectx on Ubuntu 20.04. I couldn't find any info on how to do it. Any comment is much appreciated. Thanks!



Solution 1:[1]

This package contains in deb http://ftp.de.debian.org/debian buster main repo which is not available in ubuntu.

First you need to do add this to /etc/apt/sources.list like below

#for kubectlx
deb [trusted=yes] http://ftp.de.debian.org/debian buster main

Then run

sudo apt-get update

Then you can install using this cmd.

sudo apt install kubectx

Solution 2:[2]

The following steps worked for me;

  1. sudo apt-get update
  2. sudo git clone https://github.com/ahmetb/kubectx /usr/local/kubectx
  3. sudo ln -s /usr/local/kubectx/kubectx /usr/local/bin/kubectx
  4. sudo ln -s /usr/local/kubectx/kubens /usr/local/bin/kubens
  5. Enter kubens in your console and you should be able to see your namespaces

Solution 3:[3]

There is a kubectx snap package in all currently supported versions of Ubuntu:

sudo snap install kubectx

Solution 4:[4]

I successfully installed ctx and ns as kubectl plugin using Krew.

kubectl krew install ctx
kubectl krew install ns

There's one minor catch. You won't use the commands like this:

kubectx
kubens

But rather like this:

kubectl ctx
kubectl ns

Solution 5:[5]

To install kubectx without having to edit your /etc/apt/sources.list:

Snapcraft - Install kubectx on Ubuntu

If snapd is not enabled:

Install Snapd

  1. sudo apt update
  2. sudo apt install snapd

With snapd enabled:

Install kubectx

  1. sudo snap install kubectx

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cdev
Solution 2 Umar Kayondo
Solution 3 karel
Solution 4 Josef Sábl
Solution 5