Container unknown service runtime.v1alpha2.ImageService处理

问题:k8s初始化失败,发现contaird(crictl images)无法获取到镜像

init] Using Kubernetes version: v1.24.0
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR CRI]: container runtime is not running: output:
time="2022-06-10T01:57:30+08:00" level=fatal msg="getting status of runtime:
rpc error: code = Unimplemented desc = unknown service
runtime.v1alpha2.RuntimeService"

1.这里执行命令获取失败,用了百度很多方法都不行,后面看到说是xfs文件系统有关

[root@ceph-node01 ~]# crictl images
DEBU[0000] get image connection                         
DEBU[0000] connect using endpoint 'unix:///run/containerd/containerd.sock' with '10s' timeout 
DEBU[0000] connected successfully using endpoint: unix:///run/containerd/containerd.sock 
DEBU[0000] ListImagesRequest: &ListImagesRequest{Filter:&ImageFilter{Image:&ImageSpec{Image:,Annotations:map[string]string{},},},} 
DEBU[0000] ListImagesResponse: nil                      
FATA[0000] listing images: rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.ImageService

2.xfs文件系统的ftype=0就会有问题,需要设置ftype=1
我这里主要有两个分区 /根分区 /data分区(想要调整ftype=1的话需要格式化,根分区格式化比较麻烦我们选择格式化/data)

[root@ceph-node01 ~]# xfs_info /
meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=3276800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=13107200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=6400, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@ceph-node01 ~]# xfs_info /data
meta-data=/dev/mapper/centos-data isize=256    agcount=4, agsize=57671424 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=230685696, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=112639, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

3.先备份好数据,格式化后再移回来(我这里注释掉了fstab的data挂在,然后重启了机器)

[root@ceph-node01 ~]# mkfs.xfs -f -n ftype=1 /dev/mapper/centos-data         
meta-data=/dev/mapper/centos-data isize=512    agcount=4, agsize=57671424 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=230685696, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=112639, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

4.格式化完后挂在回去

[root@ceph-node01 ~]# mount  /dev/mapper/centos-data /data/
[root@ceph-node01 ~]# xfs_info  /dev/mapper/centos-data    
meta-data=/dev/mapper/centos-data isize=512    agcount=4, agsize=57671424 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=230685696, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=112639, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

5.重点来了,因为containerd的数据默认放在/下的,/分区现在ftype还是=0,我们需要移动一下
containerd的这两个目录移动到到/data下,然后软连接回去

[root@ceph-node01 ~]# systemctl stop containerd
[root@ceph-node01 ~]# mv /opt/containerd /data/ 
[root@ceph-node01 ~]# mv /var/lib/containerd /data/containerd_data
[root@ceph-node01 ~]# ln -s /data/containerd /opt/
[root@ceph-node01 ~]# ln -s /data/containerd_data /var/lib/containerd

6.测试发现问题解决

[root@ceph-node01 ~]# systemctl start containerd
[root@ceph-node01 ~]# crictl images            
IMAGE               TAG                 IMAGE ID            SIZE
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值