Skip to content
Permalink
Browse files

simplify registry proof of concept

  • Loading branch information
BenTheElder committed Feb 5, 2020
1 parent 779fcc8 commit 4b3beebe8d2097b5c2be27de742e0ef15c78ec74
Showing with 5 additions and 13 deletions.
  1. +2 −4 site/content/docs/user/local-registry.md
  2. +3 −9 site/static/examples/kind-with-registry.sh
@@ -26,9 +26,7 @@ The registry can be used like this.
1. First we'll pull an image `docker pull gcr.io/google-samples/hello-app:1.0`
2. Then we'll tag the image to use the local registry `docker tag gcr.io/google-samples/hello-app:1.0 localhost:5000/hello-app:1.0`
3. Then we'll push it to the registry `docker push localhost:5000/hello-app:1.0`
4. And now we can use the image `kubectl create deployment hello-server --image=registry:5000/hello-app:1.0`
4. And now we can use the image `kubectl create deployment hello-server --image=localhost:5000/hello-app:1.0`

If you build your own image and tag it like `localhost:5000/image:foo` and then use
it in kubernetes as `registry:5000/image:foo`.

> Note: you may update your local hosts file as well, for example by adding `127.0.0.1 registry` in your laptop's `/etc/hosts`, so you can reference it in a consistent way by simply using `registry:5000`.
it in kubernetes as `localhost:5000/image:foo`.
@@ -13,20 +13,14 @@ if [ "${running}" != 'true' ]; then
-d --restart=always -p "${reg_port}:5000" --name "${reg_name}" \
registry:2
fi
reg_ip="$(docker inspect -f '{{.NetworkSettings.IPAddress}}' "${reg_name}")"

# create a cluster with the local registry enabled in containerd
cat <<EOF | kind create cluster --name "${KIND_CLUSTER_NAME}" --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."registry:${reg_port}"]
endpoint = ["http://registry:${reg_port}"]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"]
endpoint = ["http://${reg_ip}:${reg_port}"]
EOF

# add the registry to /etc/hosts on each node
ip_fmt='{{.NetworkSettings.IPAddress}}'
cmd="echo $(docker inspect -f "${ip_fmt}" "${reg_name}") registry >> /etc/hosts"
for node in $(kind get nodes --name "${KIND_CLUSTER_NAME}"); do
docker exec "${node}" sh -c "${cmd}"
done

0 comments on commit 4b3beeb

Please sign in to comment.
You can’t perform that action at this time.