I'm setting up a Kubernetes cluster with windows nodes. I accidentally created a local image in the default namespace.
As shown by ctr image ls
, my image is in the default namespace:
REF TYPE DIGEST SIZE PLATFORMS LABELS
docker.io/library/myimage:latest application/vnd.docker.distribution.manifest.v2+json sha256:XXX 6.3 GiB windows/amd64 -
Therefore, Kubernetes cannot find the image while creating the pod (ErrImageNeverPull
, imagePullPolicy
is set to Never
). The reason for this is, the image isn't in the right namespace k8s.io:
The command ctr --namespace k8s.io image ls
shows the base Kubernetes images:
REF TYPE DIGEST SIZE PLATFORMS LABELS
mcr.microsoft.com/oss/kubernetes/pause:3.6 application/vnd.docker.distribution.manifest.list.v2+json sha256:XXX 3.9 KiB linux/amd64,linux/arm64,windows/amd64 io.cri-containerd.image=managed
mcr.microsoft.com/oss/kubernetes/pause@sha256:DIGEST application/vnd.docker.distribution.manifest.list.v2+json sha256:XXX 3.9 KiB linux/amd64,linux/arm64,windows/amd64 io.cri-containerd.image=managed
...
The most straight-forward approach I tried, was exporting the image, deleting the image, and importing the image with different namespace. (as mentioned on a Github comment in the cri-tools project)
ctr --namespace k8s.io image import --base-name foo/myimage container_import.tar
It works. But I wonder, if there is any shorter (less time consuming) way than re-importing the image. (Maybe by running a simple command or changing a text file.)
To clarify my question: I have one node with a container stored in namespace "default". I want to have the same container stored in namespace "k8s.io" on the same node. What else can I do, instead of running the following two (slow) commands?
ctr -n default image export my-image.tar my-image
ctr -n k8s.io image import my-image.tar
I assume a more faster way of renaming the namespace, since it is just editing some meta data.