Created
December 18, 2018 22:02
-
-
Save bobhenkel/e81c3ffebf66708a9bd079bd291f6a02 to your computer and use it in GitHub Desktop.
dind k8s local docker registry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/kubernetes-sigs/kubeadm-dind-cluster/issues/56 | |
Run registry in docker on your host: | |
$ docker run -d -p 5000:5000 --restart=always --name registry registry:2 | |
Now localhost:5000 is a registry url. | |
$ docker tag alpine:3.6 localhost:5000/alpine:3.6 | |
$ docker push localhost:5000/alpine:3.6 | |
... | |
3.6: digest: sha256:d6eda1410b93902ac84bdd775167c84ab59e5abadad88791d742fea93b161e93 size: 528 | |
Run a proxy to forward each node's localhost:5000 to host's :5000 with a simple script: | |
docker ps -a -q --filter=label=mirantis.kubeadm_dind_cluster | while read container_id; do | |
docker exec ${container_id} /bin/bash -c "docker rm -fv registry-proxy || true" | |
# run registry proxy: forward from localhost:5000 on each node to host:5000 | |
docker exec ${container_id} /bin/bash -c \ | |
"docker run --name registry-proxy -d -e LISTEN=':5000' -e TALK=\"\$(/sbin/ip route|awk '/default/ { print \$3 }'):5000\" -p 5000:5000 tecnativa/tcp-proxy" | |
done | |
docs: https://hub.docker.com/r/tecnativa/tcp-proxy/ | |
/sbin/ip route|awk '/default/ { print $3 }' is to get host's IP accessible from node container. | |
Test it: | |
$ kubectl run test --image=localhost:5000/alpine:3.6 -ti /bin/ash | |
If you don't see a command prompt, try pressing enter. | |
/ # |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment