Workload Policies
Configure workload rightsizing policies and attach them to clusters.
Workload Policies
WorkloadPolicy defines how workloads should be rightsized -- CPU and memory vertical scaling, horizontal scaling, and the triggers that activate them. WorkloadPolicyTarget attaches a policy to one or more clusters with optional namespace and workload kind filters.
WorkloadPolicy
Example
import { resources, types } from "@devzero/pulumi-devzero";
const policy = new resources.WorkloadPolicy("cost-saving-policy", {
name: "cost-saving-policy",
description: "Aggressively rightsize non-critical workloads",
cpuVerticalScaling: {
enabled: true,
targetPercentile: 0.95,
minRequest: 50,
maxRequest: 4000,
maxScaleUpPercent: 1.5,
maxScaleDownPercent: 0.5,
overheadMultiplier: 1.1,
limitsAdjustmentEnabled: true,
limitMultiplier: 2.0,
},
memoryVerticalScaling: {
enabled: true,
targetPercentile: 0.95,
minRequest: 64,
maxRequest: 8192,
overheadMultiplier: 1.15,
limitsAdjustmentEnabled: true,
limitMultiplier: 1.5,
},
actionTriggers: ["on_detection"],
detectionTriggers: ["pod_creation", "pod_update"],
});from pulumi_devzero.resources import WorkloadPolicy, WorkloadPolicyArgs
from pulumi_devzero.resources.types import VerticalScalingArgs
policy = WorkloadPolicy("cost-saving-policy", args=WorkloadPolicyArgs(
name="cost-saving-policy",
description="Aggressively rightsize non-critical workloads",
cpu_vertical_scaling=VerticalScalingArgs(
enabled=True,
target_percentile=0.95,
min_request=50,
max_request=4000,
max_scale_up_percent=1.5,
max_scale_down_percent=0.5,
overhead_multiplier=1.1,
limits_adjustment_enabled=True,
limit_multiplier=2.0,
),
memory_vertical_scaling=VerticalScalingArgs(
enabled=True,
target_percentile=0.95,
min_request=64,
max_request=8192,
overhead_multiplier=1.15,
limits_adjustment_enabled=True,
limit_multiplier=1.5,
),
action_triggers=["on_detection"],
detection_triggers=["pod_creation", "pod_update"],
))Arguments
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique name for the policy |
description | string | No | Human-readable description |
cpuVerticalScaling | VerticalScalingArgs | No | CPU vertical scaling configuration |
memoryVerticalScaling | VerticalScalingArgs | No | Memory vertical scaling configuration |
horizontalScaling | HorizontalScalingArgs | No | Horizontal scaling configuration |
actionTriggers | string[] | No | When to act: "on_detection", "on_schedule" |
detectionTriggers | string[] | No | What triggers detection: "pod_creation", "pod_update", "pod_reschedule" |
Python uses snake_case: cpu_vertical_scaling, memory_vertical_scaling, horizontal_scaling, action_triggers, detection_triggers.
VerticalScalingArgs
| Parameter | Type | Required | Description |
|---|---|---|---|
enabled | bool | Yes | Whether vertical scaling is active |
targetPercentile | float | No | Usage percentile to target (e.g. 0.95) |
minRequest | int | No | Minimum request value (millicores for CPU, MiB for memory) |
maxRequest | int | No | Maximum request value |
maxScaleUpPercent | float | No | Maximum upward scaling as a multiplier (e.g. 1.5 = 150%) |
maxScaleDownPercent | float | No | Maximum downward scaling as a multiplier (e.g. 0.5 = 50%) |
overheadMultiplier | float | No | Safety margin multiplier applied to recommendations |
limitsAdjustmentEnabled | bool | No | Whether to adjust limits alongside requests |
limitMultiplier | float | No | Limits are set to request * limitMultiplier |
Python uses snake_case: target_percentile, min_request, max_request, max_scale_up_percent, max_scale_down_percent, overhead_multiplier, limits_adjustment_enabled, limit_multiplier.
WorkloadPolicyTarget
WorkloadPolicyTarget attaches a WorkloadPolicy to one or more clusters. You can optionally filter by workload kind and namespace.
Example
import { resources } from "@devzero/pulumi-devzero";
const target = new resources.WorkloadPolicyTarget("production-target", {
name: "production-target",
policyId: policy.id,
clusterIds: [cluster.id],
kindFilter: ["Deployment", "StatefulSet"],
namespaceFilter: ["default", "app"],
enabled: true,
});from pulumi_devzero.resources import WorkloadPolicyTarget, WorkloadPolicyTargetArgs
target = WorkloadPolicyTarget("production-target", args=WorkloadPolicyTargetArgs(
name="production-target",
policy_id=policy.id,
cluster_ids=[cluster.id],
kind_filter=["Deployment", "StatefulSet"],
namespace_filter=["default", "app"],
enabled=True,
))Arguments
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique name for the target |
policyId | string | Yes | ID of the WorkloadPolicy to attach |
clusterIds | string[] | Yes | List of cluster IDs to apply the policy to |
kindFilter | string[] | No | Workload kinds to include (see below) |
namespaceFilter | string[] | No | Namespaces to include |
enabled | bool | No | Whether the target is active (default: true) |
Python uses snake_case: policy_id, cluster_ids, kind_filter, namespace_filter.
Supported kind filter values: Pod, Deployment, StatefulSet, DaemonSet, Job, CronJob, ReplicaSet, ReplicationController, Rollout