Skip to content

Commit 4b64fbc

Browse files
committed
fix: update-kind-example-to-containerd_1.5
Signed-off-by: dmitrynovik <[email protected]>
1 parent ef2e4bf commit 4b64fbc

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

examples/local-kind-environment/scripts/kind-with-registry.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
set -o errexit
33

44
# create registry container unless it already exists
5+
# http://kind-registry.local:5000
6+
# curl -s -X GET kind-registry.local:5000/v2/_catalog | jq .
57
reg_name='kind-registry.local'
68
reg_port='5000'
79
if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" != 'true' ]; then
@@ -16,10 +18,26 @@ kind: Cluster
1618
apiVersion: kind.x-k8s.io/v1alpha4
1719
containerdConfigPatches:
1820
- |-
19-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"]
21+
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."${reg_name}:${reg_port}"]
2022
endpoint = ["http://${reg_name}:5000"]
2123
EOF
2224

25+
# 3. Add the registry config to the nodes
26+
#
27+
# This is necessary because localhost resolves to loopback addresses that are
28+
# network-namespace local.
29+
# In other words: localhost in the container is not localhost on the host.
30+
#
31+
# We want a consistent name that works from both ends, so we tell containerd to
32+
# alias localhost:${reg_port} to the registry container when pulling images
33+
REGISTRY_DIR="/etc/containerd/certs.d/${reg_name}:${reg_port}"
34+
for node in $(sudo kind get nodes); do
35+
sudo docker exec "${node}" mkdir -p "${REGISTRY_DIR}"
36+
cat <<EOF | sudo docker exec -i "${node}" cp /dev/stdin "${REGISTRY_DIR}/hosts.toml"
37+
[host."http://${reg_name}:${reg_port}"]
38+
EOF
39+
done
40+
2341
# connect the registry to the cluster network if not already connected
2442
if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${reg_name}")" = 'null' ]; then
2543
docker network connect "kind" "${reg_name}"

0 commit comments

Comments
 (0)