8.1 KiB
Wild Cloud Service Management
This document explains the architecture and design of Wild Cloud's infrastructure service system, including how it supports GitOps workflows.
Unified Package System
Infrastructure services (MetalLB, Traefik, cert-manager, etc.) and applications (Gitea, Immich, etc.) share a unified package system. Both use the same manifest format, directory layout, and API endpoints. Services are distinguished by category: infrastructure in their manifests.
Services live in the Wild Directory alongside apps and are managed through the unified /apps API with ?category=infrastructure filtering.
Service Installation State Machine
Wild Cloud uses a multi-phase state machine for service installation. This design separates concerns and enables GitOps workflows by allowing operators to control each phase independently.
State Machine Phases
Available → Add → Compile → Deploy → Deployed
↑ ↓ ↓ ↓
└────────┴───────┴────────┘
(Can re-run any phase independently)
Phase 1: Add
Purpose: Copy package files from Wild Directory to instance directory and merge config.
Files copied:
manifest.yaml- Package metadata, dependencies, and default configurationinstall.sh- Deployment script (optional, for infrastructure services)- Resource templates (
*.yaml) - Kustomize manifests with gomplate variables
Result: Package files exist in instance directory at:
instances/{instance}/apps/{service}/
├── manifest.yaml
├── install.sh (if present)
├── kustomization.yaml
└── *.yaml (compiled manifests)
Configuration from defaultConfig is merged into config.yaml at apps.{service}.*.
API Endpoint: POST /api/v1/instances/{instance}/apps with {"name": "service-name"}
Phase 2: Compile
Purpose: Process gomplate templates with instance config and secrets to generate deployment-ready Kubernetes manifests.
Process:
- Read templates from the package directory
- Load
config.yamlandsecrets.yamlfrom instance directory - Process templates with gomplate, resolving
defaultConfigvariables - Output compiled manifests to the package directory
API Endpoint: POST /api/v1/instances/{instance}/apps/{service}/compile
Phase 3: Deploy
Purpose: Apply compiled Kubernetes manifests to the cluster.
Method:
- Runs
install.shscript (if present) withKUBECONFIGenvironment variable set - For packages without
install.sh, useskubectl apply -k
Result: Service running in Kubernetes cluster.
API Endpoint: POST /api/v1/instances/{instance}/apps/{service}/deploy
Fetch (Re-fetch from Source)
Purpose: Re-fetch package files from Wild Directory, useful for getting upstream updates.
API Endpoint: POST /api/v1/instances/{instance}/apps/{service}/fetch
CLI Examples
# Install a service (add + deploy)
wild service install metallb
# Fresh fetch from Wild Directory and deploy
wild service install metallb --fetch
# Add and compile only, don't deploy yet
wild service install metallb --no-deploy
# List infrastructure services
wild service list
# Get service status
wild service status metallb
GitOps Integration
Wild Cloud is designed around Infrastructure-as-Code and GitOps principles. The entire instance configuration lives in WILD_API_DATA_DIR, which is intended to be a Git repository.
What Gets Tracked in Git
Tracked (committed to Git):
instances/{instance}/
├── config.yaml # Instance configuration (apps.{service}.*)
├── apps/
│ ├── {service}/ # Infrastructure services
│ │ ├── manifest.yaml
│ │ ├── install.sh # Deployment script (if present)
│ │ ├── kustomization.yaml
│ │ └── *.yaml # Compiled manifests
│ └── {app}/ # Applications
│ ├── manifest.yaml
│ ├── kustomization.yaml
│ └── *.yaml
Ignored (not tracked):
.gitignore contains:
- secrets.yaml # Contains sensitive data
- kubeconfig # Cluster credentials
- talosconfig # Node credentials
- operations/ # Ephemeral operation logs
- backups/ # Backup data
Why Compiled Manifests Are Tracked
Key Design Decision: Compiled manifests are tracked in Git.
Rationale:
- Auditability: See exact manifests deployed at any point in history
- Diff-ability:
git diffshows actual Kubernetes resource changes - Reproducibility: Can re-apply exact same manifests without re-compiling
- Transparency: No hidden template processing - what you see in Git is what runs in cluster
- GitOps reconciliation: Standard GitOps tools can watch package directories
GitOps Workflows
Workflow 1: Review Before Deploy
# 1. Add service (compiles templates, doesn't deploy)
wild service install metallb --no-deploy
# 2. Review changes
cd $WILD_API_DATA_DIR
git diff
# 3. Commit if satisfied
git add instances/my-cloud/apps/metallb/
git commit -m "Add MetalLB load balancer"
# 4. Deploy when ready
wild service install metallb
Workflow 2: Configuration Changes
# 1. Edit config directly
vim instances/my-cloud/config.yaml
# 2. Recompile templates
wild service install traefik --no-deploy
# 3. Review generated manifests
git diff instances/my-cloud/apps/traefik/
# 4. Commit and deploy
git commit -am "Update traefik ingress config"
wild service install traefik
Workflow 3: Disaster Recovery
# 1. Clone your wild-data repo to fresh system
git clone https://git.example.com/my-wild-cloud.git /var/lib/wild-central
# 2. Bootstrap new cluster
talosctl bootstrap --nodes <node-ip>
# 3. Deploy everything from Git
for pkg in $(ls instances/my-cloud/apps/); do
wild app deploy $pkg
done
# All services and apps restored from version-controlled state
State Machine + GitOps = Declarative Infrastructure
Git Repository (Desired State) Kubernetes Cluster (Actual State)
↓ ↑
[config.yaml] ──gomplate──> [manifests] ──kubectl apply──> [Running Pods]
↓ ↓
[git commit] [git commit]
↓ ↓
[Auditability] [Reproducibility]
Wild Cloud implements "GitOps with manual sync" - you maintain declarative config in Git, but retain control over when changes are applied. This is ideal for personal cloud environments where you want to review changes before deployment.
Configuration Model
Infrastructure services use the same configuration model as apps:
- Package-owned config: Stored at
apps.{service}.*inconfig.yaml - Cross-package references: Via
requiresdependencies and{{ .apps.{dep}.* }}indefaultConfig - Global config:
cloud.*,operator.*,cluster.*remain at their current paths
Example: MetalLB Configuration
# manifest.yaml
name: metallb
category: infrastructure
defaultConfig:
ipAddressPool: "192.168.1.240-192.168.1.250"
loadBalancerIp: "192.168.1.240"
Stored in config.yaml as:
apps:
metallb:
ipAddressPool: "192.168.1.240-192.168.1.250"
loadBalancerIp: "192.168.1.240"
Referenced by dependent services:
# traefik/manifest.yaml
requires:
- name: metallb
defaultConfig:
loadBalancerIp: "{{ .apps.metallb.loadBalancerIp }}"
Key Design Principles
- Unified system: Services and apps use the same manifest format, API, and lifecycle
- Separation of Concerns: Each phase has a single, well-defined responsibility
- Explicit Control: Operator controls which phases run via flags
- Git as Source of Truth: All configuration and manifests tracked in Git
- Auditability: Full history of what was deployed and when
- Reproducibility: Can recreate cluster from Git repo alone
- Transparency: Compiled manifests visible, no hidden transformations