Ship the control-agent controller for node
This commit is contained in:
@@ -18,6 +18,17 @@ STORAGE_DRIVER="${STORAGE_DRIVER:-overlay}"
|
||||
# Optional. Needed by many overlay-in-container setups.
|
||||
FUSE_OVERLAYFS="${FUSE_OVERLAYFS:-/usr/bin/fuse-overlayfs}"
|
||||
|
||||
# Optional extra images to include in addition to kubeadm's required images.
|
||||
# Example:
|
||||
# EXTRA_IMAGES=(
|
||||
# "docker.io/library/busybox:1.36"
|
||||
# "quay.io/cilium/cilium:v1.17.2"
|
||||
# )
|
||||
EXTRA_IMAGES=(
|
||||
"${EXTRA_IMAGES[@]:-}"
|
||||
"docker-daemon:monok8s/control-agent:$TAG"
|
||||
)
|
||||
|
||||
# Keep archive cache version/arch scoped so downloads do not get mixed.
|
||||
ARCHIVE_DIR="${KUBE_IMG_CACHE}/archives/${ARCH}/${KUBE_VERSION}"
|
||||
|
||||
@@ -70,48 +81,96 @@ fi
|
||||
|
||||
export CONTAINERS_STORAGE_CONF="${STORAGE_CONF}"
|
||||
|
||||
# Sanity check: list required images using the target kubeadm binary.
|
||||
mapfile -t kube_images < <(
|
||||
# Get kubeadm-required images.
|
||||
mapfile -t kubeadm_images < <(
|
||||
qemu-aarch64-static \
|
||||
"${ROOTFS}/usr/local/bin/kubeadm" \
|
||||
config images list \
|
||||
--kubernetes-version "${KUBE_VERSION}"
|
||||
)
|
||||
|
||||
if [ "${#kube_images[@]}" -eq 0 ]; then
|
||||
echo "No kubeadm images returned"
|
||||
if [ "${#kubeadm_images[@]}" -eq 0 ] && [ "${#EXTRA_IMAGES[@]}" -eq 0 ]; then
|
||||
echo "No images to seed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for img in "${kube_images[@]}"; do
|
||||
# Merge kubeadm images + EXTRA_IMAGES, preserving order and removing duplicates.
|
||||
images=()
|
||||
declare -A seen=()
|
||||
|
||||
for img in "${kubeadm_images[@]}" "${EXTRA_IMAGES[@]}"; do
|
||||
[ -n "${img}" ] || continue
|
||||
if [ -z "${seen[$img]+x}" ]; then
|
||||
images+=("${img}")
|
||||
seen["$img"]=1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Images to seed:"
|
||||
for img in "${images[@]}"; do
|
||||
echo " ${img}"
|
||||
done
|
||||
echo
|
||||
|
||||
for img in "${images[@]}"; do
|
||||
[ -n "${img}" ] || continue
|
||||
|
||||
safe_name="$(printf '%s' "${img}" | sed 's#/#_#g; s#:#__#g')"
|
||||
case "$img" in
|
||||
docker-daemon:*)
|
||||
SRC="$img"
|
||||
IMG_REF="${img#docker-daemon:}"
|
||||
USE_ARCHIVE=0
|
||||
;;
|
||||
docker://*)
|
||||
SRC="$img"
|
||||
IMG_REF="${img#docker://}"
|
||||
USE_ARCHIVE=1
|
||||
;;
|
||||
oci-archive:*)
|
||||
SRC="$img"
|
||||
IMG_REF="${img#oci-archive:}"
|
||||
USE_ARCHIVE=0
|
||||
;;
|
||||
*)
|
||||
# Default behavior for non-prefixed refs:
|
||||
# treat as remote registry image.
|
||||
SRC="docker://${img}"
|
||||
IMG_REF="$img"
|
||||
USE_ARCHIVE=1
|
||||
;;
|
||||
esac
|
||||
|
||||
safe_name="$(printf '%s' "${IMG_REF}" | sed 's#/#_#g; s#:#__#g')"
|
||||
archive="${ARCHIVE_DIR}/${safe_name}.tar"
|
||||
|
||||
if [ ! -f "${archive}" ]; then
|
||||
echo "Caching archive: ${img}"
|
||||
skopeo copy \
|
||||
--override-os "${OS}" \
|
||||
--override-arch "${ARCH}" \
|
||||
"docker://${img}" \
|
||||
"oci-archive:${archive}"
|
||||
if [ "${USE_ARCHIVE}" = "1" ]; then
|
||||
if [ ! -f "${archive}" ]; then
|
||||
echo "Caching archive: ${IMG_REF}"
|
||||
skopeo copy \
|
||||
--override-os "${OS}" \
|
||||
--override-arch "${ARCH}" \
|
||||
"${SRC}" \
|
||||
"oci-archive:${archive}"
|
||||
else
|
||||
echo "Archive hit: ${IMG_REF}"
|
||||
fi
|
||||
SRC_FINAL="oci-archive:${archive}"
|
||||
else
|
||||
echo "Archive hit: ${img}"
|
||||
echo "Using direct source: ${SRC}"
|
||||
SRC_FINAL="${SRC}"
|
||||
fi
|
||||
|
||||
# If already present in the target containers/storage, skip.
|
||||
if skopeo inspect "containers-storage:${img}" >/dev/null 2>&1; then
|
||||
echo "Store hit: ${img}"
|
||||
if skopeo inspect "containers-storage:${IMG_REF}" >/dev/null 2>&1; then
|
||||
echo "Store hit: ${IMG_REF}"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Seeding CRI-O store: ${img}"
|
||||
echo "Seeding CRI-O store: ${IMG_REF}"
|
||||
skopeo copy \
|
||||
--override-os "${OS}" \
|
||||
--override-arch "${ARCH}" \
|
||||
"oci-archive:${archive}" \
|
||||
"containers-storage:${img}"
|
||||
"${SRC_FINAL}" \
|
||||
"containers-storage:${IMG_REF}"
|
||||
done
|
||||
|
||||
echo
|
||||
|
||||
Reference in New Issue
Block a user