Closed javiertury closed 1 week ago
The generated file /var/lib/rancher/k3s/agent/etc/certs.d/registry.domain/hosts.toml contains a https reference (why?)
That's the default endpoint. From the docs:
https://docs.k3s.io/installation/private-registry#default-endpoint-fallback Containerd has an implicit "default endpoint" for all registries. The default endpoint is always tried as a last resort, even if there are other endpoints listed for that registry in registries.yaml.
- The default endpoint for
docker.io
ishttps://index.docker.io/v2
.- The default endpoint for all other registries is
https://<REGISTRY>/v2
, where<REGISTRY>
is the registry hostname and optional port.
If it's falling back to that, it means the pull from your http endpoint failed first. Check the containerd logs and figure out why.
I tried adding --disable-default-registry-endpoint
to /etc/systemd/system/k3s.service
, doing a systemctl daemon-reload
and restarting k3s, but the /var/lib/rancher/k3s/agent/etc/containerd/certs.d/registry.domain/hosts.toml
still has the https url in there.
If it's falling back to that, it means the pull from your http endpoint failed first. Check the containerd logs and figure out why.
I checked containerd logs and there are requests always come in pairs. Is the first line on each pair the insecure HTTP one? Do you know what else should I check? As a sanity check, podman CLI push and pull from the registry fine with --tls-verify=false
.
time="2024-11-18T23:52:52.744088994+01:00" level=info msg="trying next host - response was http.StatusNotFound" host=registry.domain
time="2024-11-18T23:52:52.746469113+01:00" level=info msg="trying next host" error="failed to do request: Head \"https://registry.domain/v2/user/web/blobs/sha256:XXX\": http: server gave HTTP response to HTTPS client" host=registry.domain
Finally I found out the origin of this. k3s was connecting to the private repository over insecure HTTP fine, but since the image version was missing (deleted due to age), it tried the HTTPS endpoint which does not exist. kubectl only printed messages about the HTTPS error, but it omitting the fact that it connected to the first endpoint and the image was missing there. And that omission was driving me crazy.
Thanks a lot @brandond !
Environmental Info: K3s Version:
Node(s) CPU architecture, OS, and Version:
Cluster Configuration:
1 server, 1 agent
Describe the bug:
I configured an insecure private http registry by creating the file
/etc/rancher/k3s/registries.yaml
withThe insecure registry runs on port 80.
Until this summer, I had another cluster with a similar configuration (older k3s version and registry running on port 5000) and insecure HTTP registries worked fine. However this new k3s cluster wants to use only HTTPS and fails, as can be seen in the (redacted) logs
Steps To Reproduce:
Expected behavior:
k3s should be able to access insecure/plain HTTP registries
Actual behavior:
k3s always uses HTTPS on the plain HTTP registry
Additional context / logs:
The generated file
/var/lib/rancher/k3s/agent/etc/containerd/certs.d/registry.domain/hosts.toml
contains a https reference (why?)and the generated file
/var/lib/rancher/k3s/agent/etc/containerd/config.toml
doesn't include mirrors