Files
kubesolo-os/test/integration/test-k8s-ready.sh
Adolfo Delorenzo e372df578b feat: initial Phase 1 PoC scaffolding for KubeSolo OS
Complete Phase 1 implementation of KubeSolo OS — an immutable, bootable
Linux distribution built on Tiny Core Linux for running KubeSolo
single-node Kubernetes.

Build system:
- Makefile with fetch, rootfs, initramfs, iso, disk-image targets
- Dockerfile.builder for reproducible builds
- Scripts to download Tiny Core, extract rootfs, inject KubeSolo,
  pack initramfs, and create bootable ISO/disk images

Init system (10 POSIX sh stages):
- Early mount (proc/sys/dev/cgroup2), cmdline parsing, persistent
  mount with bind-mounts, kernel module loading, sysctl, DHCP
  networking, hostname, clock sync, containerd prep, KubeSolo exec

Shared libraries:
- functions.sh (device wait, IP lookup, config helpers)
- network.sh (static IP, config persistence, interface detection)
- health.sh (containerd, API server, node readiness checks)
- Emergency shell for boot failure debugging

Testing:
- QEMU boot test with serial log marker detection
- K8s readiness test with kubectl verification
- Persistence test (reboot + verify state survives)
- Workload deployment test (nginx pod)
- Local storage test (PVC + local-path provisioner)
- Network policy test
- Reusable run-vm.sh launcher

Developer tools:
- dev-vm.sh (interactive QEMU with port forwarding)
- rebuild-initramfs.sh (fast iteration)
- inject-ssh.sh (dropbear SSH for debugging)
- extract-kernel-config.sh + kernel-audit.sh

Documentation:
- Full design document with architecture research
- Boot flow documentation covering all 10 init stages
- Cloud-init examples (DHCP, static IP, Portainer Edge, air-gapped)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 10:18:42 -06:00

70 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# test-k8s-ready.sh — Verify K8s node reaches Ready state
# Usage: ./test/integration/test-k8s-ready.sh <iso-path>
# Requires: kubectl on host, QEMU with port forwarding
set -euo pipefail
ISO="${1:?Usage: $0 <path-to-iso>}"
TIMEOUT_BOOT=120
TIMEOUT_K8S=300
API_PORT=6443
DATA_DISK=$(mktemp /tmp/kubesolo-data-XXXXXX.img)
dd if=/dev/zero of="$DATA_DISK" bs=1M count=1024 2>/dev/null
mkfs.ext4 -q -L KSOLODATA "$DATA_DISK" 2>/dev/null
cleanup() {
kill "$QEMU_PID" 2>/dev/null || true
rm -f "$DATA_DISK"
}
trap cleanup EXIT
echo "==> K8s readiness test: $ISO"
# Launch QEMU with API port forwarded
qemu-system-x86_64 \
-m 2048 -smp 2 \
-nographic \
-cdrom "$ISO" \
-boot d \
-drive "file=$DATA_DISK,format=raw,if=virtio" \
-net nic,model=virtio \
-net user,hostfwd=tcp::${API_PORT}-:6443 \
-append "console=ttyS0,115200n8 kubesolo.data=/dev/vda" \
&
QEMU_PID=$!
# Wait for API server
echo " Waiting for K8s API on localhost:${API_PORT}..."
ELAPSED=0
while [ "$ELAPSED" -lt "$TIMEOUT_K8S" ]; do
if kubectl --kubeconfig=/dev/null \
--server="https://localhost:${API_PORT}" \
--insecure-skip-tls-verify \
get nodes 2>/dev/null | grep -q "Ready"; then
echo ""
echo "==> PASS: K8s node is Ready (${ELAPSED}s)"
# Bonus: try deploying a pod
echo " Deploying test pod..."
kubectl --server="https://localhost:${API_PORT}" --insecure-skip-tls-verify \
run test-nginx --image=nginx:alpine --restart=Never 2>/dev/null || true
sleep 10
if kubectl --server="https://localhost:${API_PORT}" --insecure-skip-tls-verify \
get pod test-nginx 2>/dev/null | grep -q "Running"; then
echo "==> PASS: Test pod is Running"
else
echo "==> WARN: Test pod not Running (may need more time or image pull)"
fi
exit 0
fi
sleep 5
ELAPSED=$((ELAPSED + 5))
printf "\r Elapsed: %ds / %ds" "$ELAPSED" "$TIMEOUT_K8S"
done
echo ""
echo "==> FAIL: K8s node did not reach Ready within ${TIMEOUT_K8S}s"
exit 1