Skip to content

How to Install Kubectl in Ubuntu?

We are going to use the debian package managers to install Kubectl in Ubuntu.

sudo apt-get update && sudo apt-get install -y apt-transport-https gnupg2

Output

Hit:1 http://in.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://dl.google.com/linux/chrome/deb stable InRelease                                                                                                    
Hit:3 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease                                                                                                                              
Hit:4 https://packages.microsoft.com/repos/ms-teams stable InRelease                                                                                                                              
Hit:5 http://ppa.launchpad.net/ubuntuhandbook1/gimp/ubuntu focal InRelease                                                                              
Get:6 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]                                                        
Hit:7 http://archive.ubuntu.com/ubuntu focal InRelease                                                               
Get:8 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]                                               
Get:9 https://apt.releases.hashicorp.com focal InRelease [4,419 B]                              
Get:10 https://apt.releases.hashicorp.com focal/main amd64 Packages [20.8 kB]
Fetched 248 kB in 3s (93.0 kB/s)     
Reading package lists... Done
Reading package lists... Done
Building dependency tree       
Reading state information... Done
apt-transport-https is already the newest version (2.0.4).
The following package was automatically installed and is no longer required:
  libllvm10
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  gnupg2
0 upgraded, 1 newly installed, 0 to remove and 33 not upgraded.
Need to get 4,584 B of archives.
After this operation, 51.2 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 gnupg2 all 2.2.19-3ubuntu2.1 [4,584 B]
Fetched 4,584 B in 1s (8,013 B/s)  
Selecting previously unselected package gnupg2.
(Reading database ... 217875 files and directories currently installed.)
Preparing to unpack .../gnupg2_2.2.19-3ubuntu2.1_all.deb ...
Unpacking gnupg2 (2.2.19-3ubuntu2.1) ...
Setting up gnupg2 (2.2.19-3ubuntu2.1) ...
Processing triggers for man-db (2.9.1-1) ...
Advertisements
 curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

Output

OK
Advertisements
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list

Output

deb https://apt.kubernetes.io/ kubernetes-xenial main
Advertisements
sudo apt-get update
sudo apt-get install -y kubectl

Output

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libllvm10
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  kubectl
0 upgraded, 1 newly installed, 0 to remove and 33 not upgraded.
Need to get 7,945 kB of archives.
After this operation, 40.3 MB of additional disk space will be used.
Get:1 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 kubectl amd64 1.20.5-00 [7,945 kB]
Fetched 7,945 kB in 27s (289 kB/s)                                                                                                                                                                         
Selecting previously unselected package kubectl.
(Reading database ... 217881 files and directories currently installed.)
Preparing to unpack .../kubectl_1.20.5-00_amd64.deb ...
Unpacking kubectl (1.20.5-00) ...
Setting up kubectl (1.20.5-00) ...
Advertisements
kubectl version --client

Output

Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.5", GitCommit:"6b1d87acf3c8253c123756b9e61dac642678305f", GitTreeState:"clean", BuildDate:"2021-03-18T01:10:43Z", GoVersion:"go1.15.8", Compiler:"gc", Platform:"linux/amd64"}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.