- Local registry for KIND
We’ll run a registry container named kind-registry on port 5001 and attach it to the kind network so nodes can pull via kind-registry:5001/....
#!/usr/bin/env bash
set -euo pipefail
REG_NAME="kind-registry"
REG_PORT="5001"
if [ "$(docker ps -aq -f name=${REG_NAME})" ]; then
echo "Registry ${REG_NAME} already exists. Ensuring it's running and on 'kind' network..."
docker start "${REG_NAME}" >/dev/null || true
else
echo "Creating local registry ${REG_NAME} on port ${REG_PORT}"
docker run -d --restart=always -p "127.0.0.1:${REG_PORT}:5000" --name "${REG_NAME}" registry:2
fi
# Connect registry to kind network (if not already)
if ! docker network inspect kind >/dev/null 2>&1; then
echo "KIND network not found. Did you create the cluster in Lab 0?"
exit 1
fi
docker network connect kind "${REG_NAME}" 2>/dev/null || true
echo "Local registry is ready at: localhost:${REG_PORT} (nodes reach it as: kind-registry:5001)"
Run it once:
bash scripts/start_local_registry.sh
We’ll COPY the merged model folder (created in Lab 2) into /model in an image and push it to kind-registry:5001.
# Minimal base; just hosts files at /model
FROM alpine:3.20
RUN adduser -D -H -s /sbin/nologin model && mkdir -p /model && chown -R model /model
# Copy the merged Transformers folder produced by Lab 2
# (Contains config.json, .safetensors, tokenizer files, etc.)
COPY artifacts/train/REPLACE_RUN_ID/merged-model/ /model/
USER model
We’ll patch
REPLACE_RUN_IDat build time.
#!/usr/bin/env bash
set -euo pipefail
if [ $# -lt 2 ]; then
echo "Usage: $0 <RUN_ID> <TAG> e.g. $0 20251001-113045 v1"
exit 1
fi
RUN_ID="$1"
TAG="$2"
IMG="kind-registry:5001/atharva/smollm2-135m-merged:${TAG}"
# Safety checks
[ -d "artifacts/train/${RUN_ID}/merged-model" ] || { echo "Merged model folder not found for RUN_ID=${RUN_ID}"; exit 1; }
# Create a temp Dockerfile with RUN_ID patched
TMP_DF=$(mktemp)
sed "s|REPLACE_RUN_ID|${RUN_ID}|g" training/Dockerfile.model-asset > "$TMP_DF"
echo "==> Building model asset image: ${IMG}"
docker build -f "$TMP_DF" -t "${IMG}" .
echo "==> Pushing to local registry ${IMG}"
docker push "${IMG}"
echo "Done. Image: ${IMG}"
Run it:
# Example
bash scripts/build_model_image.sh <RUN_ID> <DOCKERHUB_USERNAME> v1
# e.g. bash scripts/build_model_image.sh 20251001-113045 initcron v1
You should now have an image kind-registry:5001/atharva/smollm2-135m-merged:v1 in the local registry.
This Pod mounts the image’s /model directory read-only at /model in the container. We then ls -lah /model.
apiVersion: v1
kind: Pod
metadata:
name: model-mount-check
namespace: atharva-ml
spec:
restartPolicy: Never
containers:
- name: inspect
image: debian:12-slim
command: ["bash","-lc","ls -lah /model/model && head -n 50 /model/model/config.json || true && sleep 5"]
volumeMounts:
- name: model
mountPath: /model
readOnly: true
volumes:
- name: model
image:
reference: kind-registry:5001/atharva/smollm2-135m-merged
pullPolicy: IfNotPresent