Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to locate package kubectl when installing the kubectl kubeadm for kubernetes installation

Tags:

kubernetes

I am trying to create a high availability cluster using the kubeadm tool. And I am trying to install the tools that specified in the pre-requistics of kubeadm installation. When I am running sudo apt-get install -y kubelet kubeadm kubectl , I am getting the error like the following,

Building dependency tree
Reading state information... Done
E: Unable to locate package kubelet
E: Unable to locate package kubeadm
E: Unable to locate package kubectl 

My Attempt

I am following the following official documentation for preparing the nodes from kubernetes.io. I am refering the following link for that,

https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#before-you-begin

Ans when I am continuing with following commands as described in the official documentation,

sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list deb https://apt.kubernetes.io/ kubernetes-xenial main EOF
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

Updates

When I tried the answer from Mr.Tummala, I am getting the error like the following,

W: Failed to fetch https://apt.kubernetes.io/dists/kubernetes-xenial/InRelease  Could not resolve host: apt.kubernetes.io
W: Some index files failed to download. They have been ignored, or old ones used instead.

But result like unable to locate the package.

like image 718
Mr.DevEng Avatar asked Dec 10 '19 10:12

Mr.DevEng


People also ask

What is Kubeadm and kubectl?

kubeadm: the command to bootstrap the cluster. kubelet: the component that runs on all of the machines in your cluster and does things like starting PODs and containers. kubectl: the command line until to talk to your cluster.


Video Answer


3 Answers

See if the below steps are doing the trick for you.

sudo apt-get update && sudo apt-get install -y apt-transport-https curl
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
like image 96
Tummala Dhanvi Avatar answered Oct 23 '22 05:10

Tummala Dhanvi


I would refer to the official documentation https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#installing-kubeadm-kubelet-and-kubectl

sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl

Then,

sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg

Finally

sudo apt-get update
# Optionally, view versions with 
# sudo apt-cache show kubectl
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
like image 40
daxmc99 Avatar answered Oct 23 '22 06:10

daxmc99


Try curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - then sudo bash -c 'cat <<EOF >/etc/apt/sources.list.d/kubernetes.list deb https://apt.kubernetes.io/ kubernetes-xenial main EOF' after it just run sudo apt-get update and then apt-cache policy kubelet | head -n 20 now you can try to install kubectl and kubeadm again.

like image 1
Yatesu Avatar answered Oct 23 '22 06:10

Yatesu