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

12/10/2019

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.

-- Jacob
kubernetes

1 Answer

12/10/2019

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
-- Tummala Dhanvi
Source: StackOverflow