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

8

12

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.

Palaeogene answered 10/12, 2019 at 10:23 Comment(1)
Check if this file was created : /etc/apt/sources.list.d/kubernetes.listVervet
K
9

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
Katheryn answered 10/12, 2019 at 12:16 Comment(11)
Yes. I tried. When I tried the echo command , I am getting the error 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.Palaeogene
ah then it might be a firewall issue which is blocking access to apt.kubernetes.io check that outKatheryn
Thank you for your response sir. When I tried the comment to check the firewall status by using sudo ufw status. It showing inactive.Palaeogene
When I tried to ping apt.kubrentes.io, its pinging also.Palaeogene
try wget https://packages.cloud.google.com/apt/dists/kubernetes-xenial/InReleaseKatheryn
Yes. Itried. this one is working. And kubectl kubelet is also working. Will you modify your answer to include this please ? I can accept this as answer. Please update this in answer.Palaeogene
so basically for you, apt.kubernetes.io isn't working and packages.cloud.google.com is working, could you please say where the VM is running so that we can troubleshoot this weird issue? if you see in other network apt.kubernetes.io just redirects to https://packages.cloud.google.com/apt/Katheryn
VM is running on premise machine. Not in cloud.Palaeogene
Let us continue this discussion in chat.Katheryn
I get the error that it's not signed. W: GPG error: https://packages.cloud.google.com/apt kubernetes-xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FBShaveling
found a workaround for the public key issue... download it yourself, (its down a bit on the page) https://devkimchi.com/2018/06/05/running-kubernetes-on-wsl/Shaveling
H
6

Please try these commands:

echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list

curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg

sudo apt update

sudo apt install -y kubelet kubeadm kubectl
Heterocercal answered 5/5 at 7:19 Comment(0)
O
5

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
Output answered 6/4, 2021 at 1:4 Comment(0)
P
1

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.

Photomontage answered 27/1, 2021 at 15:38 Comment(0)
W
0

In my case, I followed the above steps and still had problems with the gpg key. So, if by chance, during the update, you get the message:

W: GPG error: https://packages.cloud.google.com/apt kubernetes-xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY "GPG_KEY"

copy the GPG_KEY and run the command:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys "GPG_KEY"

and then run sudo apt update -y again.

then:

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
Winn answered 5/7, 2023 at 12:37 Comment(0)
Y
0

See if the below solution works for you, it worked for me

sudo su -
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
exit
Yell answered 10/2 at 15:47 Comment(0)
V
0

See if this solution works for you, it worked for me

1. Download the latest release with the command:

curl -LO "https://dl.k8s.io/release/$(curl -L -s 
https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

2. Validate the binary

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.

If valid, the output is:

kubectl: OK

3. Install kubectl

sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

4. Test to ensure the version you installed is up-to-date:

kubectl version --client
Vermifuge answered 23/5 at 9:31 Comment(0)
S
0

You’re referencing packages that were deprecated last year and turned off earlier this year. If u want install k8s Follow the kubernetes official installation guide: https://v1-29.docs.kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/ . Try this and all will work fine for you.

Southbound answered 29/7 at 0:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.