I am trying to set up a Kubernetes cluster on a fresh Ubuntu 22.04 LTS instance, but every time I run the sudo apt-get install command for kubelet, kubeadm, and kubectl, I get the "unable to locate package" error. I have already run the update command, yet the terminal still can't find these tools in the default repositories. Am I missing a specific repository source or a GPG key configuration that is required for the official Kubernetes packages? This is stalling my entire CI/CD pipeline setup.
3 answers
The issue occurs because Kubernetes packages are not hosted in the default Ubuntu/Debian repositories. To fix this, you must manually add the Kubernetes APT repository. In early 2024, the repository location changed from Google-hosted to the community-owned pkgs.k8s.io. You need to download the GPG key, save it to /etc/apt/keyrings/, and then add the repository to your sources list. If you are following an old tutorial that points to apt.kubernetes.io, it will fail because that legacy repository was deprecated. Always ensure you are using the latest community repository URL and run sudo apt update before attempting the installation again.
Are you following the updated documentation for the new community-led package repositories at pkgs.k8s.io, or are you still using the old Google Cloud (https://www.google.com/search?q=packages.cloud.google.com) instructions?
You need to add the keyring and the new repo. The command would look like echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /".
I agree with Barbara. Without the signed-by flag pointing to the keyring, apt will reject the repository for security reasons, leading to the same "unable to locate" error you are seeing.
That is exactly the problem most people face right now, Christopher. Since the legacy Google-hosted repositories were frozen, anyone trying to install the latest versions of Kubernetes will get a "not found" error or end up with ancient versions if they don't switch to the new community-owned infrastructure. You must make sure your /etc/apt/sources.list.d/kubernetes.list file points to the specific Kubernetes minor version you want, like v1.30, because the new repo structure is version-specific rather than a single "catch-all" bucket.