Now we properly preloaded the images without load at boot

This commit is contained in:
2026-03-24 21:16:21 +08:00
parent 58da0aada6
commit 81d192d577
3 changed files with 148 additions and 125 deletions

View File

@@ -0,0 +1,65 @@
#!/bin/bash
set -euo pipefail
RUNTIME_ENDPOINT="${RUNTIME_ENDPOINT:-unix:///var/run/crio/crio.sock}"
# 1. Get pause image
PAUSE_IMAGE="$(kubeadm config images list | grep pause)"
echo "Using pause image: $PAUSE_IMAGE"
# 2. Create pod sandbox config
cat > pod.json <<EOF
{
"metadata": {
"name": "pause-test",
"namespace": "default",
"attempt": 1
},
"log_directory": "/tmp",
"linux": {}
}
EOF
# 3. Create container config
cat > container.json <<EOF
{
"metadata": {
"name": "pause-container"
},
"image": {
"image": "$PAUSE_IMAGE"
},
"log_path": "pause.log",
"linux": {}
}
EOF
# 4. Run pod sandbox
POD_ID=$(crictl --runtime-endpoint "$RUNTIME_ENDPOINT" runp pod.json)
echo "Pod ID: $POD_ID"
# 5. Create container
CONTAINER_ID=$(crictl --runtime-endpoint "$RUNTIME_ENDPOINT" create "$POD_ID" container.json pod.json)
echo "Container ID: $CONTAINER_ID"
# 6. Start container
crictl --runtime-endpoint "$RUNTIME_ENDPOINT" start "$CONTAINER_ID"
# 7. Verify
echo "=== Pods ==="
crictl --runtime-endpoint "$RUNTIME_ENDPOINT" pods
echo "=== Containers ==="
crictl --runtime-endpoint "$RUNTIME_ENDPOINT" ps
# 8. Cleanup
echo "Cleaning up..."
crictl --runtime-endpoint "$RUNTIME_ENDPOINT" stop "$CONTAINER_ID" || true
crictl --runtime-endpoint "$RUNTIME_ENDPOINT" rm "$CONTAINER_ID" || true
crictl --runtime-endpoint "$RUNTIME_ENDPOINT" stopp "$POD_ID" || true
crictl --runtime-endpoint "$RUNTIME_ENDPOINT" rmp "$POD_ID" || true
rm -f pod.json container.json
echo "Done."