fix: kubeconfig server accessible via port forwarding, integration tests use proper auth
Some checks failed
CI / Go Tests (push) Has been cancelled
CI / Build Go Binaries (amd64, linux, linux-amd64) (push) Has been cancelled
CI / Build Go Binaries (arm64, linux, linux-arm64) (push) Has been cancelled
CI / Shellcheck (push) Has been cancelled

Bind kubeconfig HTTP server to 0.0.0.0:8080 (was 127.0.0.1) so integration
tests can reach it via QEMU SLIRP port forwarding. Add shared wait_for_boot
and fetch_kubeconfig helpers to qemu-helpers.sh. Update all 5 integration
tests to fetch kubeconfig via HTTP and use it for kubectl authentication.

All 6 tests pass on Linux with KVM: boot (18s), security (7/7), K8s ready
(15s), workload deploy, local storage, network policy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-12 15:25:32 -06:00
parent 6c15ba7776
commit 4fc078f7a3
7 changed files with 156 additions and 54 deletions

View File

@@ -6,8 +6,9 @@ set -euo pipefail
ISO="${1:?Usage: $0 <path-to-iso>}"
TIMEOUT_K8S=${TIMEOUT_K8S:-300}
TIMEOUT_PVC=${TIMEOUT_PVC:-120}
TIMEOUT_PVC=${TIMEOUT_PVC:-180}
API_PORT=6443
KC_PORT=8080
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
@@ -21,14 +22,19 @@ SERIAL_LOG=$(mktemp /tmp/kubesolo-storage-XXXXXX.log)
QEMU_PID=""
EXTRACT_DIR=""
KUBECTL="kubectl --server=https://localhost:${API_PORT} --insecure-skip-tls-verify"
KUBECONFIG_FILE=""
cleanup() {
# Clean up K8s resources
$KUBECTL delete pod test-storage --grace-period=0 --force 2>/dev/null || true
$KUBECTL delete pvc test-pvc 2>/dev/null || true
[ -n "$KUBECONFIG_FILE" ] && [ -f "$KUBECONFIG_FILE" ] && {
kubectl --kubeconfig="$KUBECONFIG_FILE" --insecure-skip-tls-verify \
delete pod test-storage --grace-period=0 --force 2>/dev/null || true
kubectl --kubeconfig="$KUBECONFIG_FILE" --insecure-skip-tls-verify \
delete pvc test-pvc 2>/dev/null || true
}
[ -n "$QEMU_PID" ] && kill "$QEMU_PID" 2>/dev/null || true
rm -f "$DATA_DISK" "$SERIAL_LOG"
[ -n "$KUBECONFIG_FILE" ] && rm -f "$KUBECONFIG_FILE"
[ -n "$EXTRACT_DIR" ] && rm -rf "$EXTRACT_DIR"
}
trap cleanup EXIT
@@ -51,14 +57,23 @@ qemu-system-x86_64 \
-initrd "$INITRAMFS" \
-drive "file=$DATA_DISK,format=raw,if=virtio" \
-net "nic,model=virtio" \
-net "user,hostfwd=tcp::${API_PORT}-:6443" \
-net "user,hostfwd=tcp::${API_PORT}-:6443,hostfwd=tcp::${KC_PORT}-:8080" \
-serial "file:$SERIAL_LOG" \
-append "console=ttyS0,115200n8 kubesolo.data=/dev/vda" \
-append "console=ttyS0,115200n8 kubesolo.data=/dev/vda kubesolo.debug" \
&
QEMU_PID=$!
# Wait for boot + fetch kubeconfig
echo " Waiting for boot..."
wait_for_boot "$SERIAL_LOG" "$QEMU_PID" 180 || exit 1
KUBECONFIG_FILE=$(mktemp /tmp/kubesolo-kubeconfig-XXXXXX.yaml)
fetch_kubeconfig "$KC_PORT" "$KUBECONFIG_FILE" || exit 1
KUBECTL="kubectl --kubeconfig=$KUBECONFIG_FILE --insecure-skip-tls-verify"
# Wait for K8s API
echo " Waiting for K8s API..."
echo " Waiting for K8s node Ready..."
ELAPSED=0
while [ "$ELAPSED" -lt "$TIMEOUT_K8S" ]; do
if $KUBECTL get nodes 2>/dev/null | grep -q "Ready"; then