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,6 +1,12 @@
#!/bin/sh
# 50-network.sh — Configure networking
# Priority: persistent config > cloud-init > DHCP fallback
# Priority: cloud-init (stage 45) > saved config > DHCP fallback
# If cloud-init already configured networking, skip this stage
if [ "$CLOUDINIT_APPLIED" = "1" ]; then
log "Network already configured by cloud-init — skipping"
return 0
fi
# Check for saved network config (from previous boot or cloud-init)
if [ -f "$DATA_MOUNT/network/interfaces.sh" ]; then
@@ -9,15 +15,6 @@ if [ -f "$DATA_MOUNT/network/interfaces.sh" ]; then
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"