I'm getting a rate limiting issue when trying to spin up a K3D cluster via k3d cluster create MyCluster --servers 1 -p "8081:80@loadbalancer" -p "443:443@loadbalancer" --registry-create registry:0.0.0.0:80 because the image for the registry (docker.io/library/registry:2) is failing to pull due to rate limiting.
This is happening because I'm on a company VPN that apparently makes calls to Dockerhub a lot.
When I faced this issue with other images in the past, I used
docker save IMAGE_NAME > IMAGE.tar on the dev machine and
docker load < IMAGE.tar on the target machine (after file transfer from dev to target machine).
I then pushed to the local k3d registry (e.g. docker tag alpine:3.16.2 127.0.0.1:5000/alpine:3.16.2 && docker push 127.0.0.1:5000/alpine:3.16.2) to get around the rate limit.
In this case however, the image needed is for the registry itself. Is there any way to get around this rate limit issue by creating the cluster with a local registry image file?
Yup, creating a local registry and then integrating it with k3D should indeed work. Here are the steps you'd follow:
Start by creating your local registry.
Add the registry to the
registries.yamlconfiguration file. [1]Next, check that the registry's network is connected to the k3d cluster network to enable direct communication.
Verify that your registry container and k3d cluster are on the same network by executing
docker network lsand searching for a network named similarly tok3d-my-cluster. Then, connect your registry container to this network with the following command:docker network connect k3d-my-cluster registry.localhostYou may test it by pushing the image to your local development machine, then use that local deployment in your K3D cluster
For more general information, you can check the answer of @Suhas_Pote in this StackOverflow thread and this guide.
[1]. https://k3d.io/v5.4.2/usage/registries/