kubernetes-sigs / kind

Kubernetes IN Docker - local clusters for testing Kubernetes
https://kind.sigs.k8s.io/
Apache License 2.0
13.48k stars 1.56k forks source link

Cannot delete manually loaded docker images(`kind load docker-image`) inside control-plane container #3369

Open vinayakbhat24 opened 1 year ago

vinayakbhat24 commented 1 year ago

What happened: We cannot delete images loaded to Kind cluster using the command kind load docker-image .... The issue is that it increases the RAM usage every time new images are loaded into the cluster since we cannot delete old images.

What you expected to happen: Inside the docker container control plane crictl rmi IMAGE_ID -> should delete a respective image, but not deleting. We also tried with a non-truncated IMAGE ID, but no success.

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?: We tried to debug the issue using debug flags everywhere. The issue is found to be empty RepoTags for loaded images. This can be easily seen with the command crictl inspecti {ImageID}

Also, we tried using ctr command, but no success.

Environment:

### Tasks
BenTheElder commented 1 year ago

You have to also delete the digest-only reference created by image importing.

As long as there is another reference to the image you're just deleting the tag.

/kind support /remove-kind bug

BenTheElder commented 1 year ago

aside: it should be disk usage, not RAM, unless somehow your docker volumes are memory backed

vinayakbhat24 commented 1 year ago

@BenTheElder Tried out the following commands to delete digest reference, but no luck!

#crictl images --digests=true --no-trunc
docker.io/library/import-2023-09-26                       <none>               sha256:cf5db0e942a3bb33a6394331f7216ed7eceb94d0bfa117b628dc40d799150796   sha256:29504ba812afe36081ccbdf84f813675998aed17b66e36985035ded7f4296b82   128MB

#crictl rmi docker.io/library/import-2023-09-26@sha256:cf5db0e942a3bb33a6394331f7216ed7eceb94d0bfa117b628dc40d799150796
ERRO[0000] no such image docker.io/library/import-2023-09-26@sha256:cf5db0e942a3bb33a6394331f7216ed7eceb94d0bfa117b628dc40d799150796 
FATA[0000] unable to remove the image(s)
BenTheElder commented 1 year ago

I'm not sure if crictl supports this properly, you might have to use ctr -n=k8s.io

victork0917 commented 12 months ago

@vinayakbhat24 Did you manage to resolve the issue? If yes, could you please provide the command you use? Thanks.

vinayakbhat24 commented 11 months ago

@victork0917 I have not been able to resolve the issue yet.

rriski commented 10 months ago

Related: https://github.com/containerd/containerd/issues/7698

StLeoX commented 2 months ago

This bug can still be reproduced in kind v0.23.0. And I used load image-archive to get around this problem.

BenTheElder commented 2 months ago

Please try v0.24, which is the latest release and ships with a set of images that have newer containerd

subhankarc commented 2 months ago

Hi @BenTheElder

I am facing the same problem on 0.24.0 as well.

# crictl images --digests=true --no-trunc | grep nginx
docker.io/library/nginx                         1.16.0               sha256:66f3d00a86a04a2bc78b7682a0fb9b8dff86fe56c4662245253a39707b00579c   sha256:162eee5cdbffd3ef183cc6d8b7a16c3aa7f5516dbbeab986204a1b1077561974   107MB
root@kind-control-plane:/# 
root@kind-control-plane:/# 
root@kind-control-plane:/# crictl rmi docker.io/library/nginx@sha256:66f3d00a86a04a2bc78b7682a0fb9b8dff86fe56c4662245253a39707b00579c
ERRO[0000] no such image docker.io/library/nginx@sha256:66f3d00a86a04a2bc78b7682a0fb9b8dff86fe56c4662245253a39707b00579c 
FATA[0000] unable to remove the image(s)
$ kind version
kind v0.24.0 go1.23.1 linux/arm64
BenTheElder commented 2 months ago

Was this image ever run in the cluster?

Have you tried using the tag instead of the digest?

stmcginnis commented 2 months ago

Either of these should work:

# crictl rmi nginx:1.16.0                                                           
Deleted: docker.io/library/nginx:1.16.0

Or

root@kind-control-plane:/# crictl images | grep nginx             
docker.io/library/nginx                         latest               39286ab8a5e14       71MB
root@kind-control-plane:/# crictl rmi 39286ab8a5e14
Deleted: docker.io/library/nginx:latest
subhankarc commented 2 months ago

@BenTheElder @stmcginnis

Thanks! yes only the tag works.

also ctr -n=k8s.io images rm docker.io/library/nginx:1.16.0 works.

BenTheElder commented 2 months ago

This might be a bug in crictl? docker.io/library defaulting normalization (at least from the point of view of compatibility with kubernetes pods) might be missing somewhere.