k3s doesn't have a builtin plugin for a local registry, so this is how to install the docker registry. The registry will be exposed via the default traefik ingress (on port 80 and 443).
resolvectl query registry.localhost
returns127.0.0.1
- on most Linux distros it does. If not, enable and configuresystemd-resolved
- K3s comes with traefik ingress controller by default, so the ingress for the registry service is configured for that.
kubectl create namespace docker-registry
kubectl apply -f docker-registry.yaml -n docker-registry
We need to make sure both docker/podman are able to push to the local unsecure registry and to make k3s be ablet to use the registry hosted inside of it.
docker build -t registry.localhost/test:latest .
docker push registry.localhost/test:latest
Note
configure http://registry.localhost
as insecure registry: https://docs.docker.com/registry/insecure/
podman build -t registry.localhost/test:latest .
podman push --tls-verify=false registry.localhost/test:latest
Note
configure http://registry.localhost
as insecure registry: https://github.com/containers/image/blob/main/docs/containers-registries.conf.5.md
For setting up as insecure registry in k3s see: https://docs.k3s.io/installation/private-registry and the /etc/rancher/k3s/registries.yaml
file in this gist (last file).
of-course another alternative is to just use http://ttl.sh/ but that will create both outbound and inbound traffic over the internet for no reason.