我无法使用 kubeadm 从 gcr.io 提取图像。我不明白问题所在,因为它似乎具有正确的互联网访问权限,可以正确获取最新版本信息。
它运行在 ubuntu 20.04 机器上。Kubernetes 已安装:
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && \
sudo apt-get update -q && \
sudo apt-get install -qy kubelet=1.19.15-00 kubectl=1.19.15-00 kubeadm=1.19.15-00
sudo kubeadm init
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
kubectl taint nodes --all node-role.kubernetes.io/master-
但是运行 kubeadm 作为预检图像拉取时会返回此错误
kubeadm config images pull --v=5
I1021 08:14:07.979301 1611622 initconfiguration.go:104] detected and using CRI socket: /var/run/dockershim.sock
I1021 08:14:07.979712 1611622 interface.go:400] Looking for default routes with IPv4 addresses
I1021 08:14:07.979726 1611622 interface.go:405] Default route transits interface "eth0"
I1021 08:14:07.980302 1611622 interface.go:208] Interface eth0 is up
I1021 08:14:07.980394 1611622 interface.go:256] Interface "eth0" has 3 addresses :[45.142.179.100/22 2a03:4000:4a:e35:4490:e9ff:feca:f24f/64 fe80::4490:e9ff:feca:f24f/64].
I1021 08:14:07.980421 1611622 interface.go:223] Checking addr 45.142.179.100/22.
I1021 08:14:07.980436 1611622 interface.go:230] IP found 45.142.179.100
I1021 08:14:07.980448 1611622 interface.go:262] Found valid IPv4 address 45.142.179.100 for interface "eth0".
I1021 08:14:07.980458 1611622 interface.go:411] Found active IP 45.142.179.100
I1021 08:14:08.074551 1611622 version.go:185] fetching Kubernetes version from URL: https://dl.k8s.io/release/stable-1.txt
I1021 08:14:13.375386 1611622 version.go:254] remote version is much newer: v1.22.2; falling back to: stable-1.20
I1021 08:14:13.375442 1611622 version.go:185] fetching Kubernetes version from URL: https://dl.k8s.io/release/stable-1.20.txt
exit status 1
output: Error response from daemon: Get "https://k8s.gcr.io/v2/": dial tcp: lookup k8s.gcr.io: Temporary failure in name resolution
, error
更新
我只是使用一个空白的 ubuntu 机器,添加一个新用户:
$ sudo adduser <USER>
$ sudo usermod -aG sudo <USER>
$ exit
$ ssh <USER>@<IP>
$ sudo visudo
<USER> ALL=(ALL) NOPASSWD:ALL
$ sudo passwd -l root
并运行此例程。这就是我在安装 kubernetes 之前所做的一切,如上所示。
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo touch /var/lib/dpkg/lock
sudo DEBIAN_FRONTEND=noninteractive apt-get -y update > /dev/null
sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq \
apache2-utils \
apt-transport-https \
build-essential \
ca-certificates \
cifs-utils \
curl \
containerd.io \
docker-ce \
docker-ce-cli \
gnupg2 \
haveged \
libpam-pwdfile \
nfs-common \
nfs-kernel-server \
python \
software-properties-common \
unattended-upgrades \
vsftpd > /dev/null
cat <<EOF | sudo tee /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl enable docker.service
swapoff -a
sudo exportfs -a
sudo usermod -aG docker <USER>
sudo hostnamectl set-hostname kubernetes-main