Node CRD Reference
The Node Custom Resource Definition (CRD) represents individual physical machines in the homelab autoscaler system.
API Version
- Group:
infra.homecluster.dev - Version:
v1alpha1 - Kind:
Node
Specification
NodeSpec
| Field | Type | Required | Description |
|---|---|---|---|
powerState | PowerState | Yes | Desired power state: on or off (see FSM Architecture for formal state management) |
startupPodSpec | MinimalPodSpec | Yes | Pod specification for startup operations |
shutdownPodSpec | MinimalPodSpec | Yes | Pod specification for shutdown operations |
kubernetesNodeName | string | Yes | Name of the corresponding Kubernetes node |
pricing | PricingSpec | Yes | Cost information for the node |
PowerState
type PowerState string
const (
PowerStateOn PowerState = "on"
PowerStateOff PowerState = "off"
)
MinimalPodSpec
| Field | Type | Required | Description |
|---|---|---|---|
image | string | Yes | Container image for the operation |
command | []string | No | Command to execute |
args | []string | No | Arguments for the command |
volumes | []VolumeMountSpec | No | Volume mounts for secrets/configmaps |
serviceAccount | *string | No | ServiceAccount for the pod |
VolumeMountSpec
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Volume name |
mountPath | string | Yes | Path to mount the volume |
secretName | string | No | Secret to mount (mutually exclusive with configMapName) |
configMapName | string | No | ConfigMap to mount (mutually exclusive with secretName) |
PricingSpec
| Field | Type | Required | Description |
|---|---|---|---|
hourlyRate | float64 | Yes | Cost per hour when running |
podRate | float64 | Yes | Cost per pod scheduled on the node |
NodeStatus
| Field | Type | Description |
|---|---|---|
conditions | []metav1.Condition | Standard Kubernetes conditions |
health | string | Health status: healthy, offline, unknown |
powerState | PowerState | Current power state: on or off |
progress | Progress | Current operation progress |
lastStartupTime | *metav1.Time | Last successful startup time |
lastShutdownTime | *metav1.Time | Last successful shutdown time |
Progress
type Progress string
const (
ProgressShuttingDown Progress = "shuttingdown"
ProgressShutdown Progress = "shutdown"
ProgressStartingUp Progress = "startingup"
ProgressReady Progress = "ready"
)
Example
apiVersion: infra.homecluster.dev/v1alpha1
kind: Node
metadata:
name: worker-01
namespace: homelab-autoscaler-system
labels:
group: worker-nodes
node-type: worker
zone: homelab
spec:
powerState: on
kubernetesNodeName: worker-01
startupPodSpec:
image: homelab/power-manager:latest
command: ["/bin/sh"]
args: ["-c", "wake-on-lan 00:11:22:33:44:55"]
volumes:
- name: credentials
mountPath: /etc/credentials
secretName: power-credentials
serviceAccount: power-manager
shutdownPodSpec:
image: homelab/power-manager:latest
command: ["/bin/sh"]
args: ["-c", "ssh root@worker-01 'shutdown -h now'"]
volumes:
- name: ssh-keys
mountPath: /root/.ssh
secretName: ssh-keys
serviceAccount: power-manager
pricing:
hourlyRate: 0.05
podRate: 0.001
status:
health: healthy
powerState: on
progress: ready
lastStartupTime: "2025-01-01T12:00:00Z"
conditions:
- type: Available
status: "True"
reason: NodeReady
message: "Node is powered on and ready"
lastTransitionTime: "2025-01-01T12:00:00Z"
Power Management
Startup Process
- Trigger:
spec.powerStateset toon - Job Creation: Node controller creates Job from
startupPodSpec - Progress Tracking: Status updated to
startingup - Completion: Node joins cluster, status becomes
ready
Shutdown Process
- Trigger:
spec.powerStateset tooff - Node Drain: Pods evicted from Kubernetes node (⚠️ Not implemented)
- Job Creation: Node controller creates Job from
shutdownPodSpec - Progress Tracking: Status updated to
shuttingdown - Completion: Node leaves cluster, status becomes
shutdown