导语:k8s运行时从docker切换到containerd时出现了镜像snapshot的报错。初衷是想切换的更快更平滑。所以在未切换前,用ctr命令先把镜像导入到containerd中,导入显示成功(此时还是docker运行时)。再做切换,切到containerd,但运行容器报错failed to create snapshot: missing parent 。并且删除镜像后再次导入也不行。
报错如下
failed to pull and unpack image “harbor.deepwise.com/dev/licenseconsole:release-v1.0.1-231130_c5af537_21”: unable to prepare extraction snapshot: target snapshot “sha256:63290f9c9e5201f0507ee1b5701aa06c7f48bef7cce287fc77db92bec634d737”: already exists
failed to create snapshot: missing parent “k8s.io/26/sha256:5af4f8f59b764c64c6def53f52ada809fe38d528441d08d01c206dfb3fc3b691” bucket: not found
测试情况1
复现步骤如下
查看当前k8s的运行时
导入镜像并测试
ctr运行可用
cat > /etc/crictl.yaml << EOF
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 10
debug: false
pull-image-on-create: false
EOF
修改/etc/containerd/config.toml如下
disabled_plugins = []
imports = []
oom_score = 0
plugin_dir = ""
required_plugins = []
root = "/var/lib/containerd"
state = "/run/containerd"
temp = ""
version = 2
[cgroup]
path = ""
[debug]
address = ""
format = ""
gid = 0
level = ""
uid = 0
[grpc]
address = "/run/containerd/containerd.sock"
gid = 0
max_recv_message_size = 16777216
max_send_message_size = 16777216
tcp_address = ""
tcp_tls_ca = ""
tcp_tls_cert = ""
tcp_tls_key = ""
uid = 0
[metrics]
address = ""
grpc_histogram = false
[plugins]
[plugins."io.containerd.gc.v1.scheduler"]
deletion_threshold = 0
mutation_threshold = 100
pause_threshold = 0.02
schedule_delay = "0s"
startup_delay = "100ms"
[plugin