From efa6ac3566f147ca9fd915156c1db9da1a58720e Mon Sep 17 00:00:00 2001 From: dmitrynovik Date: Tue, 13 Feb 2024 23:43:18 +1100 Subject: [PATCH] fix: update-kind-example-to-containerd_1.5 --- .../scripts/kind-with-registry.sh | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/examples/local-kind-environment/scripts/kind-with-registry.sh b/examples/local-kind-environment/scripts/kind-with-registry.sh index f19cbeab29..1a7821c7b9 100755 --- a/examples/local-kind-environment/scripts/kind-with-registry.sh +++ b/examples/local-kind-environment/scripts/kind-with-registry.sh @@ -2,6 +2,8 @@ set -o errexit # create registry container unless it already exists +# http://kind-registry.local:5000 +# curl -s -X GET kind-registry.local:5000/v2/_catalog | jq . reg_name='kind-registry.local' reg_port='5000' if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" != 'true' ]; then @@ -16,10 +18,26 @@ kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 containerdConfigPatches: - |- - [plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"] + [plugins."io.containerd.grpc.v1.cri".registry.mirrors."${reg_name}:${reg_port}"] endpoint = ["http://${reg_name}:5000"] EOF +# 3. Add the registry config to the nodes +# +# This is necessary because localhost resolves to loopback addresses that are +# network-namespace local. +# In other words: localhost in the container is not localhost on the host. +# +# We want a consistent name that works from both ends, so we tell containerd to +# alias localhost:${reg_port} to the registry container when pulling images +REGISTRY_DIR="/etc/containerd/certs.d/${reg_name}:${reg_port}" +for node in $(sudo kind get nodes); do + sudo docker exec "${node}" mkdir -p "${REGISTRY_DIR}" + cat <