kubeadm init 无法通过代理连接

kubeadm init 无法通过代理连接

我有这个版本的 kubeadm

[root@megatron ~]# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.0", GitCommit:"4ce5a8954017644c5420bae81d72b09b735c21f0", GitTreeState:"clean", BuildDate:"2022-05-03T13:44:24Z", GoVersion:"go1.18.1", Compiler:"gc", Platform:"linux/amd64"}

我的 docker 已设置并正常工作,并且可以通过我使用的代理轻松正确地提取所有需要的图像。

我在配置文件、.bashrc 和环境等中都有全面的 HTTP 代理配置。

当我尝试运行 kubeadm 并让其拉取镜像时,它超时了

I0520 10:56:32.085975  260833 version.go:186] fetching Kubernetes version from URL: https://dl.k8s.io/release/stable-1.txt
exit status 1
output: time="2022-05-20T10:59:03-04:00" level=fatal msg="pulling image: rpc error:                                                                                        code = Unknown desc = failed to pull and unpack image \"k8s.gcr.io/kube-apiserver:                                                                                       v1.24.0\": failed to resolve reference \"k8s.gcr.io/kube-apiserver:v1.24.0\": faile                                                                                       d to do request: Head \"https://k8s.gcr.io/v2/kube-apiserver/manifests/v1.24.0\": d                                                                                       ial tcp 172.253.63.82:443: i/o timeout"
, error
k8s.io/kubernetes/cmd/kubeadm/app/util/runtime.(*CRIRuntime).PullImage
        cmd/kubeadm/app/util/runtime/runtime.go:121
k8s.io/kubernetes/cmd/kubeadm/app/cmd.PullControlPlaneImages
        cmd/kubeadm/app/cmd/config.go:340
k8s.io/kubernetes/cmd/kubeadm/app/cmd.newCmdConfigImagesPull.func1
        cmd/kubeadm/app/cmd/config.go:312
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute
        vendor/github.com/spf13/cobra/command.go:856
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC
        vendor/github.com/spf13/cobra/command.go:974
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute
        vendor/github.com/spf13/cobra/command.go:902
k8s.io/kubernetes/cmd/kubeadm/app.Run
        cmd/kubeadm/app/kubeadm.go:50
main.main
        cmd/kubeadm/kubeadm.go:25
runtime.main
        /usr/local/go/src/runtime/proc.go:250
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1571
failed to pull image "k8s.gcr.io/kube-apiserver:v1.24.0"
k8s.io/kubernetes/cmd/kubeadm/app/cmd.PullControlPlaneImages
        cmd/kubeadm/app/cmd/config.go:341
k8s.io/kubernetes/cmd/kubeadm/app/cmd.newCmdConfigImagesPull.func1
        cmd/kubeadm/app/cmd/config.go:312
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute
        vendor/github.com/spf13/cobra/command.go:856
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC
        vendor/github.com/spf13/cobra/command.go:974
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute
        vendor/github.com/spf13/cobra/command.go:902
k8s.io/kubernetes/cmd/kubeadm/app.Run
        cmd/kubeadm/app/kubeadm.go:50
main.main
        cmd/kubeadm/kubeadm.go:25
runtime.main
        /usr/local/go/src/runtime/proc.go:250
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1571

我甚至手动拉取了必要的图像

[root@megatron ~]# kubeadm config images list
k8s.gcr.io/kube-apiserver:v1.24.0
k8s.gcr.io/kube-controller-manager:v1.24.0
k8s.gcr.io/kube-scheduler:v1.24.0
k8s.gcr.io/kube-proxy:v1.24.0
k8s.gcr.io/pause:3.7
k8s.gcr.io/etcd:3.5.3-0
k8s.gcr.io/coredns/coredns:v1.8.6
[root@megatron ~]# docker pull k8s.gcr.io/coredns/coredns:v1.8.6
v1.8.6: Pulling from coredns/coredns
Digest: sha256:5b6ec0d6de9baaf3e92d0f66cd96a25b9edbce8716f5f15dcd1a616b3abd590e
Status: Image is up to date for k8s.gcr.io/coredns/coredns:v1.8.6
k8s.gcr.io/coredns/coredns:v1.8.6
[root@megatron ~]#

我需要帮助来理解为什么 kubeadm 没有使用正确的 http 代理,这似乎是在尝试获取https://dl.k8s.io/release/stable-1.txt

获取该文件没有问题,为什么 kubeadm 没有获取它?

[root@starscream ~]# wget https://dl.k8s.io/release/stable-1.txt
--2022-05-20 11:09:46--  https://dl.k8s.io/release/stable-1.txt
Connecting to [PROXY]:8080... connected.
Proxy request sent, awaiting response... 302 Moved Temporarily
Location: https://storage.googleapis.com/kubernetes-release/release/stable-1.txt [following]
--2022-05-20 11:09:47--  https://storage.googleapis.com/kubernetes-release/release/stable-1.txt
Connecting to [PROXY]:8080... 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

2022-05-20 11:09:48 (331 KB/s) - ‘stable-1.txt’ saved [7/7]

更新:

在查看了强制版本选项后,我尝试了

kubeadm config images pull --kubernetes-version 1.24.0 --v=5

现在它不会尝试检索 stable-1.txt。我怀疑我忽略了它无论如何都可能能够检索它的事实。

现在它仍在尝试拉取 docker 已有的镜像。为什么 kubeadm 尝试拉取已存在的镜像?

I0520 12:57:24.402436  228499 kubelet.go:214] the value of KubeletConfiguration.cgroupDriver is empty; setting it to "systemd"
exit status 1
output: time="2022-05-20T12:59:54-04:00" level=fatal msg="pulling image: rpc error: code = Unknown desc = failed to pull and unpack image \"k8s.gcr.io/kube-apiserver:v1.24.0\": failed to resolve reference \"k8s.gcr.io/kube-apiserver:v1.24.0\": failed to do request: Head \"https://k8s.gcr.io/v2/kube-apiserver/manifests/v1.24.0\": dial tcp 142.250.145.82:443: i/o timeout"
, error

代理未被使用仍然没有帮助。我可以接受这一点,但为什么 kubeadm 不使用现有的图像?

相关内容