65 lines
1.5 KiB
Bash
Executable File
65 lines
1.5 KiB
Bash
Executable File
#!/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." |