I'm using the latest version of microk8s and docker on the same VM. microk8s registry is enabled.
I restaged my image argus
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
argus 0.1 6d72b6be9981 3 hours ago 164MB
localhost:32000/argus registry 6d72b6be9981 3 hours ago 164MB
then I pushed it
$ docker push localhost:32000/argus:registry
The push refers to repository [localhost:32000/argus]
c8a05c6fda3e: Pushed
5836f564d6a0: Pushed
9e3dd069b4a1: Pushed
6935b1ceeced: Pushed
d02e8e9f8523: Pushed
c5129c726314: Pushed
0f299cdf8fbc: Pushed
edaf6f6a5ef5: Pushed
9eb034f85642: Pushed
043895432150: Pushed
a26398ad6d10: Pushed
0dee9b20d8f0: Pushed
f68ef921efae: Pushed
registry: digest: sha256:0a0ac9e076e3249b8e144943026bc7c24ec47ce6559a4e087546e3ff3fef5c14 size: 3052
all working seemingly fine but when I try to deploy a pod with:
$ microk8s kubectl create deployment argus --image=argus
deployment.apps/argus created
$ microk8s kubectl get pods
NAME READY STATUS RESTARTS AGE
argus-84c8dcc968-27nlz 0/1 ErrImagePull 0 9s
$ microk8s kubectl logs argus-84c8dcc968-27nlz
Error from server (BadRequest): container "argus" in pod "argus-84c8dcc968-27nlz" is waiting to start: trying and failing to pull image
The image can not be pulled, I tried the $ microk8s ctr images ls
but this does not tell me anything.
So what is it that I'm doing wrong here?
update:
A bit of an update here when I try:
$ microk8s ctr image pull localhost:32000/argus:registry
ctr: failed to resolve reference "localhost:32000/argus:registry": failed to do request: Head "https://localhost:32000/v2/argus/manifests/registry": http: server gave HTTP response to HTTPS client
So it seems that it does not like that it gets and http
response from my local repository. I looked into the config at /var/snap/microk8s/current/args/containerd-template.toml
and there the localhost
repository is correctly configured:
[plugins."io.containerd.grpc.v1.cri".registry]
# 'plugins."io.containerd.grpc.v1.cri".registry.mirrors' are namespace to mirror mapping for all namespaces.
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["https://registry-1.docker.io", ]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:32000"]
endpoint = ["http://localhost:32000"]
I'm running all of this on a centos8 VM. When I installed docker
I needed to do it with sudo dnf install docker-ce --nobest
because otherwise there was some kind of conflict with containerd maybe it has todo something with this?
you can use kubectl describe to check the pod
i guess it try to pull the "argus" from docker.io
have you try add localhost:32000 to the image parameter?
microk8s kubectl create deployment argus --image=localhost:32000/argus:registry
Okay, there were multiple issues at play here, and I think I solved them all. First of, I made a mistake with the Docker Image. It was a test image, but it should have had something that continuously runs because after PID 1 ends the container gets restarted, the reasons is that microk8s/kubernetes
assumes a there is a problem. That's why there was the crash loop.
Second, to check which repositories are present in the local registry, it's easiest to curl
the rest API
of the registry with:
$curl http://host:32000/v2/_catalog
to get a list of all images, and:
$curl http://host:32000/v2/{repositoryName}/tags/list
to get all tags for a given repo.
Lastly, to pull from the registry to the cluster manually without getting the https
error, it's necessary to add the --plain-http
option like this:
$microk8s ctr image pull --plain-http localhost:32000/repo:tag