Policies
Policies can be set by creating new Custom Resource. The Policy CR must be created in the scaleops-system namespace.
Example:
apiVersion: analysis.scaleops.sh/v1alpha1
kind: Policy
metadata:
name: your-policy # name of the policy
namespace: scaleops-system
spec:
type: Optimize
policyOptimize:
rightSizePolicy:
ephemeralStorageOptimizationEnabled: true # Enable ephemeral storage optimization
windowByResource:
cpu: 24h # History window to maintain for CPU data samples
memory: 24h # History window to maintain for Memory data samples
ephemeral-storage: 48h
requestsConfigs:
cpu:
headroomPercentage: 5 # The percent of headroom to add to the recommendation
percentilePercentage: 85 # The percentile of the usage to base the recommendation on
memory:
headroomPercentage: 5 # The percent of headroom to add to the recommendation
percentilePercentage: 90 # The percentile of the usage to base the recommendation on
ephemeral-storage:
headroomPercentage: 5
percentilePercentage: 90
limitConfigs:
cpu:
keepLimit: true
memory:
keepLimit: true
ephemeral-storage:
keepLimit: true
autoHealing:
enabledByResource:
ephemeral-storage: true # Currently supports only ephemeral storage, CPU and memory is not supported yet by this field
updatePolicy:
updateByTypeMode:
daemonSet: OnCreate # Update strategy for DaemonSets, allowed values are OnCreate or Ongoing
deployment: Ongoing # Update strategy for Deployments, allowed values are OnCreate or Ongoing
job: OnCreate # Update strategy for Jobs, allowed values are OnCreate or Ongoing
statefulSet: OnCreate # Update strategy for StatefulSets, allowed values are OnCreate or OngoingPolicy Structure
Top-Level Fields
| Field | Type | Description |
|---|---|---|
spec.type | string | Policy type. Use Optimize for workload rightsizing. |
spec.policyOptimize | object | Request/limit calculation and burst reaction settings. |
spec.updatePolicy | object | How and when ScaleOps applies optimizations (rollout strategy, schedules). |
spec.autoHealing | object | Auto-healing for CPU stress, OOM, and disk evictions. |
spec.policySchedule | object | Optional schedule-based policy switching. |
spec.autoDetectionRules | object | Rules for auto-detecting workloads. |
Right-Size Policy
Under spec.policyOptimize.rightSizePolicy, configure how requests and limits are calculated per resource. Supported resource keys are cpu, memory, and ephemeral-storage.
windowByResource
History window (duration) used for recommendations per resource. Examples: 24h, 48h, 168h (7 days).
| Key | Description |
|---|---|
cpu | History window for CPU recommendations. |
memory | History window for memory recommendations. |
ephemeral-storage | History window for ephemeral storage (requires ephemeral storage optimization enabled). |
requestsConfigs
Per-resource request calculation settings.
| Field | Type | Description |
|---|---|---|
headroomPercentage | integer | Extra buffer percentage added on top of the recommendation (e.g., 5). |
percentilePercentage | integer | Percentile of usage histogram used for the recommendation (e.g., 90). |
minAllowed | string (quantity) | Minimum allowed request (e.g., "10m" for CPU, "20Mi" for memory, "10Mi" for ephemeral storage). |
maxAllowed | string (quantity) | Maximum allowed request. Use "0" or empty for no maximum. |
keepRequest | boolean | If true, preserve the workload’s original request for this resource. |
limitConfigs
Under spec.policyOptimize.rightSizePolicy.limitConfigs.<cpu | memory | ephemeral-storage>:
Per-resource limit strategy.
| Field | Type | Description |
|---|---|---|
keepLimit | boolean | Preserve the workload’s original limit. |
noLimit | boolean | Remove the limit (no cap). |
setLimit | string (quantity) | Set a fixed limit. |
keepLimitRequestRatio | boolean | Maintain original limit/request ratio. |
setLimitRequestRatio | float | Set limit as a multiplier of the recommendation (e.g., 2). |
minLimit | string (quantity) | Optional. Minimum hard bound for the limit (e.g., "1Gi"). Applies only with keepLimitRequestRatio or setLimitRequestRatio. The limit will never be set below this value. |
maxLimit | string (quantity) | Optional. Maximum hard bound for the limit (e.g., "10Gi"). Applies only with keepLimitRequestRatio or setLimitRequestRatio. The limit will never exceed this value. |
maxRecommendedLimitToOriginalLimitRatio | float | Optional. Caps the limit as a multiple of the original limit (e.g., 3 means the limit will not exceed 3× the original). Applies only with keepLimitRequestRatio or setLimitRequestRatio. If both maxLimit and maxRecommendedLimitToOriginalLimitRatio are set, the smaller effective value is used. |
Other Right-Size Fields
| Field | Type | Description |
|---|---|---|
ephemeralStorageOptimizationEnabled | boolean | Enable ephemeral storage optimization. Default: true. |
nodeCappingPolicy.nodeCappingAuto | boolean | Cap recommendations by node allocatable. |
cpuInteger | boolean | Round CPU requests to integers. |
initContainers.enabled | boolean | Enable init container optimization. |
Auto-Healing
Under spec.autoHealing:
| Field | Type | Description |
|---|---|---|
enabledV2 | boolean | Master toggle for auto-healing. |
enabledByResource | map | Per-resource auto-healing. Keys: cpu, memory, ephemeral-storage. |
Update Policy
Under spec.updatePolicy:
| Field | Type | Description |
|---|---|---|
updateByTypeMode | object | Rollout strategy per workload type. Keys: deployment, statefulSet, daemonSet, job, deploymentConfig, argoRollout. Values: Ongoing or OnCreate. |
minReplicas | integer | Minimum replicas to ensure during optimization. |
evictionSchedule | object | Cron expressions for when to allow evictions (scaleDown, scaleUp). |
podMinReadySeconds | integer | Buffer for pods to become ready. |
requiredWindowCoveragePercentage | integer | Required data coverage before applying changes. |
binPackUnEvictablePods | boolean | Bin-pack unevictable pods for better consolidation. |
Resource Keys Summary
Use these keys in windowByResource, requestsConfigs, and limitConfigs:
| Key | Resource |
|---|---|
cpu | CPU requests and limits |
memory | Memory requests and limits |
ephemeral-storage | Ephemeral storage (disk). Requires ephemeralStorageOptimizationEnabled: true. |
For ephemeral storage auto-healing (disk evictions), set spec.autoHealing.enabledByResource["ephemeral-storage"]: true. See Ephemeral Storage for more details.