大网数据广告活动
服务器运维问答

Kubeadm with containerd cannot use locally loaded images

· 52CE 我爱测

I'm trying to build kubernetes with containerd in bare-metal server (RHEL8). There's no Internet connection so I manually downloaded needed images (e.g. k8s.gcr.io/kube-scheduler:v1.22.1) and loaded them using "ctr image import".…

问题原文

原帖链接 · Daigo · CC BY-SA 4.0

I'm trying to build kubernetes with containerd in bare-metal server (RHEL8).

There's no Internet connection so I manually downloaded needed images (e.g. k8s.gcr.io/kube-scheduler:v1.22.1) and loaded them using "ctr image import".

The images seem to be loaded successfully.

#ctr images ls -q
k8s.gcr.io/coredns/coredns:v1.8.4
k8s.gcr.io/etcd:3.5.0-0
k8s.gcr.io/kube-apiserver:v1.22.1
k8s.gcr.io/kube-controller-manager:v1.22.1
k8s.gcr.io/kube-proxy:v1.22.1
k8s.gcr.io/kube-scheduler:v1.22.1
k8s.gcr.io/pause:3.5

Then I executed "kubeadm init" but it failed with ImagePull errors.

#kubeadm init --kubernetes-version=1.22.1 --cri-socket=/run/containerd/containerd.sock
[init] Using Kubernetes version: v1.22.1
[preflight] Running pre-flight checks
        [WARNING FileExisting-tc]: tc not found in system path
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
error execution phase preflight: [preflight] Some fatal errors occurred:

How can I let kubeadm to use local images? Or is it OK to ignore these preflight errors?

Edit: This procedure (manually loading images instead of executing kubeadm config images pull) worked well when with docker and CentOS7.

已采纳解答

原帖链接 · Daigo · CC BY-SA 4.0

It turned out that I had to load images to the k8s.io namespace of the containerd so that Kubernetes can recognize them. I was importing the images to the wrong namespace (default).

ctr -n k8s.io images import xxx.tar
...

After loading all the images that Kubernetes needs, kubeadm init worked well without executing
kubeadm config images pull. The images that Kubernetes can use are shown in
ctr -n k8s.io images ls or crictl images.

# crictl images
IMAGE                                                          TAG                 IMAGE ID            SIZE
k8s.gcr.io/coredns/coredns                                     v1.8.4              8d147537fb7d1       47.7MB
k8s.gcr.io/etcd                                                3.5.0-0             0048118155842       296MB
k8s.gcr.io/kube-apiserver                                      v1.22.1             f30469a2491a5       130MB
k8s.gcr.io/kube-controller-manager                             v1.22.1             6e002eb89a881       123MB
k8s.gcr.io/kube-proxy                                          v1.22.1             36c4ebbc9d979       105MB
k8s.gcr.io/kube-scheduler                                      v1.22.1             aca5ededae9c8       53.9MB
k8s.gcr.io/pause                                               3.5                 ed210e3e4a5ba       686kB

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-10-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。