WorkloadPolicy Guide¶
WorkloadPolicy automates workload discovery and classification within a namespace. It scans for Deployments and StatefulSets, fetches their metrics, and classifies each as Active or Idle.
Quick Start¶
| workloadpolicy.yaml | |
|---|---|
After the first scan, check results:
Output:
NAME MODE DISCOVERED ACTIVE IDLE PROJECTED COST PROJECTED SAVINGS
staging-policy suggest 12 10 2 $340.00 $89.00
Modes¶
suggest (default)¶
Discovery only. The policy scans and classifies workloads, populates status.discovered, and reports summary metrics. No ManagedWorkloads are created.
Use this mode to:
- Audit a namespace for cost optimization opportunities
- Review classifications before enabling management
- Feed the
kubectl hybernate exportplugin
auto-manage¶
Automatically creates ManagedWorkload CRs for idle workloads using the policy's default settings. Active workloads are left alone.
| workloadpolicy.yaml | |
|---|---|
Warning
Start with dryRun: true when using auto-manage. This creates the ManagedWorkloads but they won't take action until you set dryRun: false on each one individually.
Forecast engine starts fresh
When you switch from suggest to auto-manage, newly created ManagedWorkloads have no forecast history. The Holt-Winters engine begins in its Observing phase and needs time to learn the workload's demand patterns before it can confirm idle detection or wake workloads ahead of demand. In suggest mode, no forecast engines run because no ManagedWorkloads exist. Plan for a warm-up period after switching modes.
Classification Thresholds¶
| Classification | Condition |
|---|---|
| Idle | CPU usage < cpuIdleThreshold% of request AND memory usage < memoryIdleThreshold% of request |
| Active | Everything else |
Utilization is calculated as (usage / request) x 100%. A workload requesting 1000m CPU but using 50m has 5% CPU utilization.
Projected savings are the compute cost of the idle workloads: what pausing them would save. Storage is excluded, since PVCs persist while paused.
Default Policies¶
WorkloadPolicy sets defaults for ManagedWorkloads it creates (in auto-manage mode) or exports (via kubectl plugin):
| workloadpolicy.yaml | |
|---|---|
These are all configurable. They serve as sensible defaults that you can override per-workload.
Excluding Workloads¶
To prevent a workload from being discovered, add the ignore label:
Ignored workloads appear in status.discovered with ignored: true but are skipped by auto-manage and export.
Viewing Discovered Workloads¶
Full details per workload:
Each entry includes:
name,kind,classificationcpuUsageMillis,cpuRequestMillis,cpuUtilizationPercentmemoryUsageBytes,memoryRequestBytesstorageBytesestimatedMonthlyCost,estimatedPotentialSavingsmanaged(already has a ManagedWorkload)ignored(has thehybernate.io/ignorelabel)
Results are capped at 500 entries, sorted by estimated savings descending.
Spec Reference¶
| Field | Type | Default | Description |
|---|---|---|---|
targetKinds |
list | [Deployment, StatefulSet] |
Which kinds to scan |
mode |
suggest or auto-manage |
suggest |
Reporting only or auto-create ManagedWorkloads |
scanInterval |
duration | 10m |
How often to re-scan |
cpuIdleThreshold |
int (percent) | 10 |
CPU utilization % of request below which workload is Idle (0-100) |
memoryIdleThreshold |
int (percent) | 10 |
Memory utilization % of request below which workload is Idle (0-100) |
dryRun |
bool | true |
Default dryRun for auto-created ManagedWorkloads |
rates |
CostRates | AWS defaults | Cost rates for savings estimates |