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>
This commit is contained in:
64
init/lib/50-network.sh
Executable file
64
init/lib/50-network.sh
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
# 50-network.sh — Configure networking
|
||||
# Priority: persistent config > cloud-init > DHCP fallback
|
||||
|
||||
# Check for saved network config (from previous boot or cloud-init)
|
||||
if [ -f "$DATA_MOUNT/network/interfaces.sh" ]; then
|
||||
log "Applying saved network configuration"
|
||||
. "$DATA_MOUNT/network/interfaces.sh"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Check for cloud-init network config
|
||||
CLOUDINIT_FILE="${KUBESOLO_CLOUDINIT:-$DATA_MOUNT/etc-kubesolo/cloud-init.yaml}"
|
||||
if [ -f "$CLOUDINIT_FILE" ]; then
|
||||
log "Cloud-init found: $CLOUDINIT_FILE"
|
||||
# Phase 1: simple parsing — extract network stanza
|
||||
# TODO: Replace with proper cloud-init parser (Go binary) in Phase 2
|
||||
log_warn "Cloud-init network parsing not yet implemented — falling back to DHCP"
|
||||
fi
|
||||
|
||||
# Fallback: DHCP on first non-loopback interface
|
||||
log "Configuring network via DHCP"
|
||||
|
||||
# Bring up loopback
|
||||
ip link set lo up
|
||||
ip addr add 127.0.0.1/8 dev lo
|
||||
|
||||
# Find first ethernet interface
|
||||
ETH_DEV=""
|
||||
for iface in /sys/class/net/*; do
|
||||
iface="$(basename "$iface")"
|
||||
case "$iface" in
|
||||
lo|docker*|veth*|br*|cni*) continue ;;
|
||||
esac
|
||||
ETH_DEV="$iface"
|
||||
break
|
||||
done
|
||||
|
||||
if [ -z "$ETH_DEV" ]; then
|
||||
log_err "No network interface found"
|
||||
return 1
|
||||
fi
|
||||
|
||||
log "Using interface: $ETH_DEV"
|
||||
ip link set "$ETH_DEV" up
|
||||
|
||||
# Run DHCP client (BusyBox udhcpc)
|
||||
if command -v udhcpc >/dev/null 2>&1; then
|
||||
udhcpc -i "$ETH_DEV" -s /usr/share/udhcpc/default.script \
|
||||
-t 10 -T 3 -A 5 -b -q 2>/dev/null || {
|
||||
log_err "DHCP failed on $ETH_DEV"
|
||||
return 1
|
||||
}
|
||||
elif command -v dhcpcd >/dev/null 2>&1; then
|
||||
dhcpcd "$ETH_DEV" || {
|
||||
log_err "DHCP failed on $ETH_DEV"
|
||||
return 1
|
||||
}
|
||||
else
|
||||
log_err "No DHCP client available (need udhcpc or dhcpcd)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
log_ok "Network configured on $ETH_DEV"
|
||||
Reference in New Issue
Block a user