Hibernation Lifecycle¶
This guide walks through the complete lifecycle of a HibernatePlan from creation to steady-state operation.
Creating a Plan¶
1. Set Up Connectors¶
Before creating a plan, ensure your connectors are ready:
# Verify CloudProvider is ready
kubectl get cloudprovider -n hibernator-system
# NAME TYPE READY AGE
# aws-production aws true 5d
# Verify K8SCluster is ready (if using Karpenter/WorkloadScaler)
kubectl get k8scluster -n hibernator-system
# NAME TYPE READY AGE
# eks-production eks true 5d
2. Apply the Plan¶
apiVersion: hibernator.ardikabs.com/v1alpha1
kind: HibernatePlan
metadata:
name: dev-offhours
namespace: hibernator-system
spec:
schedule:
timezone: "Asia/Jakarta"
offHours:
- start: "20:00"
end: "06:00"
daysOfWeek: ["MON", "TUE", "WED", "THU", "FRI"]
execution:
strategy:
type: Sequential
targets:
- name: dev-database
type: rds
connectorRef:
kind: CloudProvider
name: aws-production
parameters:
selector:
instanceIds: ["dev-db"]
snapshotBeforeStop: true
3. Verify Creation¶
Monitoring a Cycle¶
Watch Phase Transitions¶
You'll see transitions like:
Check Execution Details¶
kubectl get hibernateplan dev-offhours -n hibernator-system \
-o jsonpath='{.status.executions[*]}' | jq
Example output:
[
{
"target": "rds/dev-database",
"executor": "rds",
"state": "Completed",
"startedAt": "2026-02-01T13:00:00Z",
"finishedAt": "2026-02-01T13:02:30Z",
"attempts": 1,
"message": "Successfully stopped RDS instance"
}
]
View Runner Logs¶
# List runner jobs
kubectl get jobs -n hibernator-system -l hibernator.ardikabs.com/plan=dev-offhours
# View logs from the most recent runner
kubectl logs -n hibernator-system -l hibernator.ardikabs.com/plan=dev-offhours --tail=50
Phase Flow¶
Shutdown Flow¶
- Active → Hibernating: Controller detects the schedule window has started
- Controller creates runner Jobs for each target (ordered by execution strategy)
- Each runner executes the
Shutdownoperation on its target - Restore metadata is captured and stored in ConfigMaps
- Hibernating → Hibernated: All targets successfully shut down
Wakeup Flow¶
- Hibernated → WakingUp: Controller detects the schedule window has ended
- Controller creates runner Jobs in reverse execution order
- Each runner reads restore metadata and executes the
WakeUpoperation - WakingUp → Active: All targets successfully restored
Checking Restore Data¶
Restore metadata is stored in a ConfigMap:
Keys follow the format {executor}_{target-name}:
Execution History¶
The plan status maintains a history of recent execution cycles:
kubectl get hibernateplan dev-offhours -n hibernator-system \
-o jsonpath='{.status.executionHistory}' | jq
Up to 5 recent cycles are retained, each with shutdown and wakeup operation summaries.
Next Steps¶
- Execution Strategies — Configure how targets are ordered
- Error Recovery — Handle failures during execution