#!/bin/sh set -eu KUBE_VERSION="${KUBE_VERSION:-v1.35.3}" REGISTRY_ADDR="${REGISTRY_ADDR:-127.0.0.1:5000}" mkdir -p /opt/registry cat >/opt/registry/config.yml </opt/crictl.yaml <<'EOF' runtime-endpoint: unix:///var/run/crio/crio.sock image-endpoint: unix:///var/run/crio/crio.sock timeout: 10 debug: false EOF registry serve /opt/registry/config.yml >/var/log/registry.log 2>&1 & REG_PID=$! cleanup() { kill "$REG_PID" 2>/dev/null || true } trap cleanup EXIT INT TERM for _ in $(seq 1 30); do if curl -fsS "http://${REGISTRY_ADDR}/v2/_catalog" >/dev/null; then break fi sleep 1 done curl -fsS "http://${REGISTRY_ADDR}/v2/_catalog" >/dev/null for img in $(kubeadm config images list --kubernetes-version "${KUBE_VERSION}"); do name="${img#registry.k8s.io/}" echo "Importing ${img} from ${REGISTRY_ADDR}/${name}" skopeo copy --src-tls-verify=false \ "docker://${REGISTRY_ADDR}/${name}" \ "containers-storage:${img}" done echo "Imported images now visible to CRI-O:" crictl images kill "$REG_PID" 2>/dev/null || true wait "$REG_PID" 2>/dev/null || true trap - EXIT INT TERM