kubectl安装无法连接packages.cloud.google.com

1、问题描述

Err:4 https://packages.cloud.google.com/apt kubernetes-xenial InRelease                                                                                                                                   
  Could not connect to packages.cloud.google.com:443 (216.58.200.238), connection timed out
Fetched 3,781 B in 31s (121 B/s)                             
Reading package lists... Done
W: Failed to fetch https://apt.kubernetes.io/dists/kubernetes-xenial/InRelease  Could not connect to packages.cloud.google.com:443 (216.58.200.238), connection timed out
W: Some index files failed to download. They have been ignored, or old ones used instead.

2、解决方案

问题1

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

手动下载https://packages.cloud.google.com/apt/doc/apt-key.gpg
将下载后的apt-key.gpg复制到/usr/share/keyrings/kubernetes-archive-keyring.gpg文件下

sudo cp apt-key.gpg /usr/share/keyrings/kubernetes-archive-keyring.gpg

问题2

echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list

调整为

echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list

你可能感兴趣的:(kubectl安装无法连接packages.cloud.google.com)