KubeCon EUBooth 1151, Amsterdam. March 23-26
Pulumi

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

ParameterTypeRequiredDescription
namestringYesUnique name for the policy
descriptionstringNoHuman-readable description
cpuVerticalScalingVerticalScalingArgsNoCPU vertical scaling configuration
memoryVerticalScalingVerticalScalingArgsNoMemory vertical scaling configuration
horizontalScalingHorizontalScalingArgsNoHorizontal scaling configuration
actionTriggersstring[]NoWhen to act: "on_detection", "on_schedule"
detectionTriggersstring[]NoWhat 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

ParameterTypeRequiredDescription
enabledboolYesWhether vertical scaling is active
targetPercentilefloatNoUsage percentile to target (e.g. 0.95)
minRequestintNoMinimum request value (millicores for CPU, MiB for memory)
maxRequestintNoMaximum request value
maxScaleUpPercentfloatNoMaximum upward scaling as a multiplier (e.g. 1.5 = 150%)
maxScaleDownPercentfloatNoMaximum downward scaling as a multiplier (e.g. 0.5 = 50%)
overheadMultiplierfloatNoSafety margin multiplier applied to recommendations
limitsAdjustmentEnabledboolNoWhether to adjust limits alongside requests
limitMultiplierfloatNoLimits 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

ParameterTypeRequiredDescription
namestringYesUnique name for the target
policyIdstringYesID of the WorkloadPolicy to attach
clusterIdsstring[]YesList of cluster IDs to apply the policy to
kindFilterstring[]NoWorkload kinds to include (see below)
namespaceFilterstring[]NoNamespaces to include
enabledboolNoWhether 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

On this page