A Kubernetes clusters lifecycle management agent for the Fulcrum Core platform.
This agent manages the complete lifecycle of Kubernetes clusters provisioned on Proxmox virtual machines using Kamaji for tenant control planes. The agent communicates with the Fulcrum Core API to receive jobs, manages VM infrastructure via Proxmox, and configures Kubernetes tenant clusters using Kamaji.
- Go 1.27.3 or higher (includes required standard-library security fixes)
- Access to a running Fulcrum Core API
- Agent type and provider registered in Fulcrum Core
# Build the agent
go build -o fulcrum-kube-agent ./cmd/fulcrum-kube-agentThe agent can be configured using a combination of a configuration file and environment variables.
Create a JSON configuration file (e.g., config.json):
{
"fulcrumApiToken": "YOUR_AGENT_TOKEN",
"fulcrumApiUrl": "http://localhost:3000",
"jobPollInterval": "5s",
"metricReportInterval": "30s",
"proxmoxApiUrl": "https://proxmox.example.com:8006/api2/json",
"proxmoxApiToken": "YOUR_PROXMOX_TOKEN",
"proxmoxTemplate": 100,
"proxmoxHost": "pve",
"proxmoxStorage": "local-lvm",
"kubeApiUrl": "https://kubernetes.example.com",
"kubeApiToken": "YOUR_KUBERNETES_TOKEN",
"skipTlsVerify": false
}The agent uses the following default values if not specified:
| Parameter | Default Value | Description |
|---|---|---|
fulcrumApiToken |
(empty) | Must be provided |
fulcrumApiUrl |
"http://localhost:3000" | URL of the Fulcrum Core API |
jobPollInterval |
5s | How often to poll for jobs |
metricReportInterval |
30s | How often to report metrics |
skipTlsVerify |
false | Whether to skip TLS verification |
Configuration can be provided or overridden using environment variables. The agent automatically prepends FULCRUM_AGENT_ to the field names:
FULCRUM_AGENT_API_URL: URL of the Fulcrum Core APIFULCRUM_AGENT_API_TOKEN: Secret token of the agent
FULCRUM_AGENT_JOB_POLL_INTERVAL: How often to poll for jobsFULCRUM_AGENT_METRIC_REPORT_INTERVAL: How often to report metrics
FULCRUM_AGENT_PROXMOX_API_URL: Proxmox API URLFULCRUM_AGENT_PROXMOX_API_SECRET: Proxmox API tokenFULCRUM_AGENT_PROXMOX_TEMPLATE: VM template IDFULCRUM_AGENT_PROXMOX_HOST: Proxmox hostFULCRUM_AGENT_PROXMOX_STORAGE: Proxmox storage
FULCRUM_AGENT_KUBE_API_URL: Kubernetes API URLFULCRUM_AGENT_KUBE_API_SECRET: Kubernetes API token
FULCRUM_AGENT_SKIP_TLS_VERIFY: Skip TLS certificate validation
# Run with default configuration (requires FULCRUM_AGENT_API_TOKEN to be set)
./fulcrum-kube-agent
# Run with a configuration file
./fulcrum-kube-agent -config config.json
# Run with mock clients for development/testing
./fulcrum-kube-agent -mockThe agent handles SIGINT and SIGTERM signals for graceful shutdown. Simply press Ctrl+C to stop it cleanly.
The agent generates the following metrics for running services:
| Metric | Description |
|---|---|
VM CPU Usage |
CPU utilization percentage for each VM node |
VM Memory Usage |
Memory utilization for each VM node |
The agent processes the following job types from Fulcrum Core:
| Job Type | Description |
|---|---|
create |
Creates a tenant control plane and stopped worker VMs |
update |
Adds/removes nodes; applies node On/Off changes only when the service is running |
start |
Starts worker VMs whose configured status is On |
stop |
Stops worker VMs whose configured status is On |
delete |
Deletes worker VMs and the tenant control plane |
Aligned with Fulcrum Core 3212fc7 (no legacy API compatibility):
job.paramscontains desired properties forcreateandupdate;service.propertiescontains the applied configuration.service.statusis a lifecycle state. Updates and metrics useserviceType.lifecycleSchema.runningStates, not a fixedStartedlabel. Update jobs fetch the service separately because pending jobs do not include its service type.- Job completion sends
agentInstanceIdandagentInstanceData(cluster endpoint, kubeconfig and node-to-VM mapping). Metrics useagentInstanceIdtoo. - Core owns state transitions and applies update params after completion. Unknown actions or missing job/instance data fail rather than being silently completed.
- Core errors retain HTTP status, message and field-level validation details. Service listing sends the requested page as a query parameter.
- Local configuration remains authoritative for this agent; Core-managed configuration and vault resolution are not implemented by this change.
Existing limitations: changing a node's size is unsupported; infrastructure operations are not transactional or automatically rolled back. Do not blindly retry partially provisioned clusters.
test/rest/agent_kube.http is a versioned VS Code REST Client scenario. It creates its own service type/lifecycle, agent type, participants and agent instead of depending on fixed IDs. Export FULCRUM_TEST_ADMIN_TOKEN to the REST Client process; never commit credentials or response exports.
Use a disposable Core instance. Ensure Resource metric types vm.cpu.usage and vm.memory.usage exist, run setup, then configure the agent with the generated agent token. Wait for each asynchronous job to complete before the next request. POST /services/{id}/delete requests deletion; there is no generic /retry endpoint. The .DS_Store files in test/ remain ignored.
Warning: without -mock, this scenario creates and deletes real infrastructure. -mock mocks Proxmox/Kamaji/SSH only: it still connects to Core.
The project includes a configuration file for Air (.air.toml), which provides hot reloading during development:
# Install Air
go install github.com/cosmtrek/air@latest
# Run with Air for development
airThis will automatically rebuild and restart the agent when source files change.
The agent includes comprehensive unit tests:
# Run unit and local HTTP contract tests (never contact real infrastructure)
INTEGRATION_TEST=false go test ./...
INTEGRATION_TEST=false go test -race ./...
go vet ./...
# Run the cluster lifecycle tests with mock infrastructure
go test -v ./internal/agent
# Live infrastructure tests are opt-in; use only disposable resources.
# INTEGRATION_TEST=true go test ./...Run the vulnerability scan with the Go version required by go.mod (or a newer patched toolchain):
go version
go mod verify
go run golang.org/x/vuln/cmd/govulncheck@v1.9.0 -show verbose ./...The security update uses golang.org/x/crypto v0.58.0 and golang.org/x/net v0.62.0, plus their required x/sys, x/term and x/text updates. Kubernetes libraries remain at v0.33.0.
Verification of this update with Go 1.27.3 found no vulnerabilities in called code or imported packages. The scan still reported the module-only advisory GO-2026-5932 for golang.org/x/crypto/openpgp: the agent does not import OpenPGP, directly or transitively. This is not a suppressed finding; reassess it if dependencies change. The stable x/crypto release is retained rather than switching to an unreleased pseudo-version solely to remove an unused package.
Rebuild and redeploy existing binaries to apply both dependency and standard-library fixes. Updating go.mod alone does not patch a running agent. With GOTOOLCHAIN=auto, Go selects a toolchain satisfying the module's minimum; otherwise install a compatible patched version before building.