feat: add cloud-init Go parser (Phase 2)

Implement a lightweight cloud-init system for first-boot configuration:
- Go parser for YAML config (hostname, network, KubeSolo settings)
- Static/DHCP network modes with DNS override
- KubeSolo extra flags and API server SAN configuration
- Portainer Edge Agent and air-gapped deployment support
- New init stage 45-cloud-init.sh runs before network/hostname stages
- Stages 50/60 skip gracefully when cloud-init has already applied
- Build script compiles static Linux/amd64 binary (~2.7 MB)
- 17 unit tests covering parsing, validation, and example files
- Full documentation at docs/cloud-init.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-11 10:39:05 -06:00
parent e372df578b
commit d900fa920e
17 changed files with 1217 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
.PHONY: all fetch rootfs initramfs iso disk-image \
.PHONY: all fetch build-cloudinit rootfs initramfs iso disk-image \
test-boot test-k8s test-persistence test-deploy test-storage test-all \
test-cloudinit \
dev-vm dev-vm-shell quick docker-build shellcheck \
kernel-audit clean distclean help
@@ -27,7 +28,11 @@ fetch:
# =============================================================================
# Build stages
# =============================================================================
rootfs: fetch
build-cloudinit:
@echo "==> Building cloud-init binary..."
$(BUILD_DIR)/scripts/build-cloudinit.sh
rootfs: fetch build-cloudinit
@echo "==> Preparing rootfs..."
$(BUILD_DIR)/scripts/extract-core.sh
$(BUILD_DIR)/scripts/inject-kubesolo.sh
@@ -78,6 +83,11 @@ test-storage: iso
test-all: test-boot test-k8s test-persistence
# Cloud-init Go tests
test-cloudinit:
@echo "==> Testing cloud-init parser..."
cd cloud-init && go test ./... -v -count=1
# Full integration test suite (requires more time)
test-integration: test-k8s test-deploy test-storage
@@ -148,6 +158,7 @@ help:
@echo ""
@echo "Build targets:"
@echo " make fetch Download Tiny Core ISO, KubeSolo, dependencies"
@echo " make build-cloudinit Build cloud-init Go binary"
@echo " make rootfs Extract + prepare rootfs with KubeSolo"
@echo " make initramfs Repack rootfs into kubesolo-os.gz"
@echo " make iso Create bootable ISO (default target)"
@@ -161,6 +172,7 @@ help:
@echo " make test-persist Reboot disk image, verify state persists"
@echo " make test-deploy Deploy nginx pod, verify Running"
@echo " make test-storage Test PVC with local-path provisioner"
@echo " make test-cloudinit Run cloud-init Go unit tests"
@echo " make test-all Run core tests (boot + k8s + persistence)"
@echo " make test-integ Run full integration suite"
@echo ""