我正在尝试在我的实验室环境中安装 Kubernetes 测试。我使用为 curl、apt 和 wget 配置的代理,但 forcepoint 使用了一个特殊证书。所有 ssl 连接都将通过 forcepoint 证书传递。我已经将此 forcepoint 证书安装到根 ca。
我尝试按照说明安装 kubernetes https://phoenixnap.com/kb/install-kubernetes-on-ubuntu
我在第 10 步就卡住了。
- 最后,通过键入以下内容初始化集群
sudo kubeadm init --control-plane-endpoint=master-node --upload-certs
这里我遇到了 ImagePull 的连接问题。
为了更详细地说明这一点,我尝试在其余图像之前拉取图像,但sudo kubeadm pull image
收到以下错误消息:
W0125 14:11:00.320619 32932 version.go:104] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable-1.txt": Get "https://dl.k8s.io/release/stable-1.txt": dial tcp 34.107.204.206:443: connect: connection refused
W0125 14:11:00.320751 32932 version.go:105] falling back to the local client version: v1.28.2failed to pull image "registry.k8s.io/kube-apiserver:v1.28.2": output: E0125 14:11:00.598053 32975 remote_image.go:171] "PullImage from image service failed" err="rpc error: code = Unknown desc = failed to pull and unpack image \"registry.k8s.io/kube-apiserver:v1.28.2\": failed to resolve reference \"registry.k8s.io/kube-apiserver:v1.28.2\": failed to do request: Head \"https://registry.k8s.io/v2/kube-apiserver/manifests/v1.28.2\": dial tcp 34.96.108.209:443: connect: connection refused" image="registry.k8s.io/kube-apiserver:v1.28.2"
time="2024-01-25T14:11:00Z" level=fatal msg="pulling image: rpc error: code = Unknown desc = failed to pull and unpack image \"registry.k8s.io/kube-apiserver:v1.28.2\": failed to resolve reference \"registry.k8s.io/kube-apiserver:v1.28.2\": failed to do request: Head \"https://registry.k8s.io/v2/kube-apiserver/manifests/v1.28.2\": dial tcp 34.96.108.209:443: connect: connection refused"
error: exit status 1
To see the stack trace of this error execute with --v=5 or higher
如果我尝试访问https://dl.k8s.io/release/stable-1.txt通过 wget 一切正常。
wget https://dl.k8s.io/release/stable-1.txt
--2024-01-25 14:11:59-- https://dl.k8s.io/release/stable-1.txt
Connecting to 172.25.82.137:81... connected.
Proxy request sent, awaiting response... 302 Found
Location: https://cdn.dl.k8s.io/release/stable-1.txt [following]
--2024-01-25 14:12:00-- https://cdn.dl.k8s.io/release/stable-1.txt
Connecting to 172.25.82.137:81... connected.
Proxy request sent, awaiting response... 200 OK
Length: 7 [text/plain]
Saving to: ‘stable-1.txt’
stable-1.txt
100% [====================================================================>]
7 --.-KB/s in 0s
2024-01-25 14:12:01 (205 KB/s) - ‘stable-1.txt’ saved [7/7]
您知道问题可能出在哪里吗?
答案1
您可能缺少 kubeadm 的代理设置,我会尝试在 bash 中设置代理:
export HTTP_PROXY=http://proxy.example.com:port
export HTTPS_PROXY=http://proxy.example.com:port
export NO_PROXY=localhost,127.0.0.1,.example.com
您可能需要重新启动 containerd 服务
systemctl restart containerd.service