4

I am trying to install Kubernetes (kubectl) on Ubuntu 16.04 (x64) by following the instructions here. I am behind some proxy at work and I am sure that is the reason for the failure. I know there are a bunch of related questions out there but I have already tried any suggestion I could find. Any help will be greatly appreciated.

Currently, I am stuck at getting apt update to work. It is failing with -

W: The repository 'https://apt.kubernetes.io kubernetes-xenial Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch https://apt.kubernetes.io/dists/kubernetes-xenial/main/binary-amd64/Packages  server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

I have tried multiple things here - Updated my apt.conf(at /etc/apt/apt.conf) with

Acquire::https::packages.cloud.google.com::Verify-Peer "false";

I also tried by specifying the above as a command line argument -

sudo apt-get update -o Acquire::https::packages.cloud.google.com::Verify-Peer=false

I have tried running apt-get update with --allow-unauthenticated & --allow-insecure-repositories but somehow apt-secure is still ignoring all these instructions. I went through the man-page for apt-secure but couldn't find anything wrong with the options I specified.

I have updated keys using -

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 6A030B21BA07F4FB

I have updated my CA certs. I have ran - sudo rm /var/lib/apt/lists/* to remove all the lists.

Contents of /etc/apt/sources.list.d/kubernetes.list

deb https://apt.kubernetes.io/ kubernetes-xenial main
muru
  • 193,181
  • 53
  • 473
  • 722
Kumar Prashant
  • 41
  • 1
  • 1
  • 3
  • [`apt` need to be configured](https://askubuntu.com/questions/257290/configure-proxy-for-apt) even if you have `HTTPS_PROXY` environment variable correctly configured. BTW if you are trying Kubernetes locally take a look to [this](https://askubuntu.com/a/1109537/349837) answer. – Pablo Bianchi Jan 14 '19 at 07:05

2 Answers2

12

There will be a redirection issue sometimes.

Use the source below will solve this.

deb http://packages.cloud.google.com/apt/ kubernetes-xenial main
Yan QiDong
  • 221
  • 2
  • 5
  • Now it is 2021 and the workaround still works. Thanks for it. Ubuntu/Google did not bother to fix the issue with their official guide "How to install kubectl". – Shtefan Aug 08 '21 at 00:52
1

For latest ubuntu version where deb command is not found

sudo apt-add-repository 'deb http://packages.cloud.google.com/apt/ kubernetes-xenial main

And for any errors for the packages add the gpg key

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

and then execute

sudo apt-get update
ravi.zombie
  • 161
  • 1
  • 4
  • this is works great on ubuntu 22 ! better than official documentation on kubernetes website (https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/) – Rexave Nov 29 '22 at 16:37