How can I install kubectx on Ubuntu Linux 20.04?

Viewed 13457

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!

6 Answers

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

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

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

sudo snap install kubectx

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

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

This command should work:

sudo apt install kubectx

If you want find completely install kubectx guide, you need to go to this github page. You can use an installation for Debian. APT stands for Advanced Package Tool. It is a set of core tools inside Debian and Ubuntu Linux system. You can use the apt command to install apps, delete or remove apps, keep Ubuntu/Debian server up to date and more. You can read more about it here.

It is possible that you should add the package deb http://ftp.de.debian.org/debian buster main before you install kubectx in the file /etc/apt/sources.list and then run sudo apt-get update. After that installation should work without problems.

Related