I have set up a k3s Kubernetes standalone server with a insecure private registry but k3s fails to pull images from it.
The registries.yaml
file is set as documentation says. It is below.
mirrors:
"registry.cube.local:5000":
endpoint:
- "http://registry.cube.local:5000"
The image is in the registry but k3s pods won't push them showing the error below:
failed to do request: Head "https://registry.cube.local:5000/v2/batch/manifests/v0.9": http: server gave HTTP response to HTTPS client
As per the registries.yaml
configuration, that should not happen, because it is configured to use http. I went to checked the journal with journalctl -xn -u k3s.service | less
to spot errors and I can see the below warning:
Oct 17 21:51:20 local k3s[25571]: I1017 21:51:20.401763 25571 event.go:294] "Event occurred" object="kube-system/registries" fieldPath="" kind="Addon" apiVersion="k3s.cattle.io/v1" type="Warning" reason="ParseManifestFailed" message="Parse manifest at \"/root/k3s/server/manifests/registries.yaml\" failed: Object 'Kind' is missing in '{\"mirrors\":{\"registry.cube.local:5000\":{\"endpoint\":[\"http://registry.cube.local:5000\"]}}}'"
I did lint the yaml file, and the conversion to JSON seems correct as per logs, so I don't think it is a file formatting thing.
I tried setting up a secure private registry, but that did not work because it also relies on the registries.yaml
file configuration to work, and same error is shown with it.
I wonder someone sees the issue before I open a bug fot it on their github. It is really not making sense to me.
Best Answer
A github contributor helped me: https://github.com/k3s-io/k3s/issues/8677#issuecomment-1768569901
I was putting the file in the wrong location. Despite setting the installation location in a different location, registries.yaml is still read at
/etc/rancher/k3s/registries.yaml
as documented.