Skip to content

Commit

Permalink
Configure the local registry in each node
Browse files Browse the repository at this point in the history
containerd no longer supports inline registry configuration; files
must be created on each node to point to the registry. See
kubernetes-sigs/kind#2875 and
https://kind.sigs.k8s.io/docs/user/local-registry/ for details.

This restores the project's ability to test newly-built images.

Signed-off-by: Stephen Kitt <[email protected]>
  • Loading branch information
skitt authored and tpantelis committed Jan 13, 2025
1 parent f97ed8c commit e8b4801
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
23 changes: 23 additions & 0 deletions scripts/shared/lib/clusters_kind
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function provider_create_cluster() {
cat "${RESOURCES_DIR}/${cluster}-config.yaml"
kind create cluster ${image_flag:+"$image_flag"} --name="${cluster}" --config="${RESOURCES_DIR}/${cluster}-config.yaml"
kind_fixup_config
kind_configure_registry "${cluster}"

[[ "$LOAD_BALANCER" != true ]] || delete_cluster_on_fail deploy_load_balancer
[[ "$AIR_GAPPED" != true ]] || air_gap_iptables
Expand Down Expand Up @@ -232,6 +233,28 @@ function run_local_registry() {
fi
}

function kind_configure_registry() {
local cluster="$1"
REGISTRY_DIR="/etc/containerd/certs.d/localhost:5000"
for node in $(kind --name="${cluster}" get nodes); do
docker exec "${node}" mkdir -p "${REGISTRY_DIR}"
docker exec -i "${node}" cp /dev/stdin "${REGISTRY_DIR}/hosts.toml" <<EOF
[host."http://${KIND_REGISTRY}:5000"]
EOF
done
kubectl apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: local-registry-hosting
namespace: kube-public
data:
localRegistryHosting.v1: |
host: "localhost:5000"
help: "https://kind.sigs.k8s.io/docs/user/local-registry/"
EOF
}

function provider_failed() {
if [[ "$(cat /proc/sys/fs/inotify/max_user_instances)" -lt 512 ]]; then
echo "Your inotify settings are lower than our recommendation."
Expand Down
4 changes: 2 additions & 2 deletions scripts/shared/resources/kind-cluster-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ networking:
serviceSubnet: ${service_cidr}
containerdConfigPatches:
- |-
[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"localhost:5000\"]
endpoint = [\"http://kind-registry:5000\"]
[plugins.\"io.containerd.grpc.v1.cri\".registry]
config_path = \"/etc/containerd/certs.d\"
kubeadmConfigPatches:
- |
apiVersion: kubeadm.k8s.io/v1beta2
Expand Down
4 changes: 2 additions & 2 deletions scripts/shared/resources/kind-cluster-dual-stack-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ networking:
ipFamily: dual
containerdConfigPatches:
- |-
[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"localhost:5000\"]
endpoint = [\"http://kind-registry:5000\"]
[plugins.\"io.containerd.grpc.v1.cri\".registry]
config_path = \"/etc/containerd/certs.d\"
kubeadmConfigPatches:
- |
apiVersion: kubeadm.k8s.io/v1beta2
Expand Down
4 changes: 2 additions & 2 deletions scripts/shared/resources/kind-cluster-ipv6-stack-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ networking:
ipFamily: ipv6
containerdConfigPatches:
- |-
[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"localhost:5000\"]
endpoint = [\"http://kind-registry:5000\"]
[plugins.\"io.containerd.grpc.v1.cri\".registry]
config_path = \"/etc/containerd/certs.d\"
kubeadmConfigPatches:
- |
apiVersion: kubeadm.k8s.io/v1beta2
Expand Down

0 comments on commit e8b4801

Please sign in to comment.