Skip to Content

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 Ongoing

Policy Structure

Top-Level Fields

FieldTypeDescription
spec.typestringPolicy type. Use Optimize for workload rightsizing.
spec.policyOptimizeobjectRequest/limit calculation and burst reaction settings.
spec.updatePolicyobjectHow and when ScaleOps applies optimizations (rollout strategy, schedules).
spec.autoHealingobjectAuto-healing for CPU stress, OOM, and disk evictions.
spec.policyScheduleobjectOptional schedule-based policy switching.
spec.autoDetectionRulesobjectRules 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).

KeyDescription
cpuHistory window for CPU recommendations.
memoryHistory window for memory recommendations.
ephemeral-storageHistory window for ephemeral storage (requires ephemeral storage optimization enabled).

requestsConfigs

Per-resource request calculation settings.

FieldTypeDescription
headroomPercentageintegerExtra buffer percentage added on top of the recommendation (e.g., 5).
percentilePercentageintegerPercentile of usage histogram used for the recommendation (e.g., 90).
minAllowedstring (quantity)Minimum allowed request (e.g., "10m" for CPU, "20Mi" for memory, "10Mi" for ephemeral storage).
maxAllowedstring (quantity)Maximum allowed request. Use "0" or empty for no maximum.
keepRequestbooleanIf true, preserve the workload’s original request for this resource.

limitConfigs

Under spec.policyOptimize.rightSizePolicy.limitConfigs.<cpu | memory | ephemeral-storage>:

Per-resource limit strategy.

FieldTypeDescription
keepLimitbooleanPreserve the workload’s original limit.
noLimitbooleanRemove the limit (no cap).
setLimitstring (quantity)Set a fixed limit.
keepLimitRequestRatiobooleanMaintain original limit/request ratio.
setLimitRequestRatiofloatSet limit as a multiplier of the recommendation (e.g., 2).
minLimitstring (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.
maxLimitstring (quantity)Optional. Maximum hard bound for the limit (e.g., "10Gi"). Applies only with keepLimitRequestRatio or setLimitRequestRatio. The limit will never exceed this value.
maxRecommendedLimitToOriginalLimitRatiofloatOptional. 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

FieldTypeDescription
ephemeralStorageOptimizationEnabledbooleanEnable ephemeral storage optimization. Default: true.
nodeCappingPolicy.nodeCappingAutobooleanCap recommendations by node allocatable.
cpuIntegerbooleanRound CPU requests to integers.
initContainers.enabledbooleanEnable init container optimization.

Auto-Healing

Under spec.autoHealing:

FieldTypeDescription
enabledV2booleanMaster toggle for auto-healing.
enabledByResourcemapPer-resource auto-healing. Keys: cpu, memory, ephemeral-storage.

Update Policy

Under spec.updatePolicy:

FieldTypeDescription
updateByTypeModeobjectRollout strategy per workload type. Keys: deployment, statefulSet, daemonSet, job, deploymentConfig, argoRollout. Values: Ongoing or OnCreate.
minReplicasintegerMinimum replicas to ensure during optimization.
evictionScheduleobjectCron expressions for when to allow evictions (scaleDown, scaleUp).
podMinReadySecondsintegerBuffer for pods to become ready.
requiredWindowCoveragePercentageintegerRequired data coverage before applying changes.
binPackUnEvictablePodsbooleanBin-pack unevictable pods for better consolidation.

Resource Keys Summary

Use these keys in windowByResource, requestsConfigs, and limitConfigs:

KeyResource
cpuCPU requests and limits
memoryMemory requests and limits
ephemeral-storageEphemeral 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.