Skip to content
Docs
Release candidateThese docs are for Napwake 0.2.0-rc.9, a release candidate, and may change before it's released. Read the docs for the latest release.

Guides

ManagedWorkload guide

The ManagedWorkload is Napwake's core resource. Each one names a Deployment or StatefulSet whose lifecycle Napwake manages.

View .mdAsk Claude (opens claude.ai)Ask ChatGPT (opens chatgpt.com)
  1. Name the target.

    managedworkload.yaml
    apiVersion: napwake.dev/v1alpha1
    kind: ManagedWorkload
    metadata:
    name: my-api
    namespace: staging
    spec:
    target:
    kind: Deployment
    name: my-api

    Only target is required, and the rest takes its defaults. Napwake watches it, tracks its cost and learns its forecast, but pauses it only when you ask, with kubectl napwake pause.

  2. Add an idle policy, and what else you need.

    managedworkload.yaml
    apiVersion: napwake.dev/v1alpha1
    kind: ManagedWorkload
    metadata:
    name: my-api
    namespace: staging
    spec:
    target:
    kind: Deployment
    name: my-api
    idlePolicy:
    idleAfter: 1h
    activity:
    cpuThreshold: 10
    prometheus:
    - promQL: 'sum(rate(nginx_ingress_controller_requests{exported_namespace="staging", exported_service="my-api"}[5m]))'
    autoResume: true
    wake:
    mode: Request
    maxWait: 2m
    page: true
    prediction:
    mode: balanced
    costTracking:
    rates:
    cpuPerHour: "0.031"
    memoryPerHour: "0.004"
    storagePerMonth: "0.08"
    dryRun: false

    With an idlePolicy, Napwake pauses it on its own. Each field’s type, default and limits are in the API reference.

Once my-api has had no activity for idleAfter, Napwake pauses it. A request to its Service wakes it.

Field What it does
target The workload, in the same namespace. It can’t change once set, since a paused target would be left at zero. The API server refuses the edit. Create another ManagedWorkload for another workload
idlePolicy When it’s idle, and pauses. Deploys and the napwake.dev/last-activity and napwake.dev/active-until annotations always count as activity. See Idle detection and Prometheus activity
dependsOn Up to 20 workloads this one needs. They aren’t paused while it’s awake, and waking it wakes them. See Dependencies
wake What wakes it through the doorman while paused. mode: Request is any request, and mode: Ask only a person’s click. See Wake on request
prediction How soon the forecast acts. Leave it out, or write prediction: {}, for the default. See Forecast setting and Forecasting
costTracking Your own rates, in place of the nodes’ list price. None may be negative. See Cost tracking
dryRun Measures without pausing, waking the workload if it was paused. See Dry run

Settings with more than one value aren’t annotations. Set them on the label’s ManagedWorkload, such as with kubectl patch, and Napwake keeps them.

The annotations own these. Edits are overwritten Yours, and kept
dryRun, idlePolicy (idleAfter, activity.cpuThreshold, autoResume, pauseEarly), the workloads dependsOn lists, wake idlePolicy.activity.prometheus, waitForReady on a listed dependency, costTracking, and prediction, whose confidence percentage overrides napwake.dev/forecast

A paused workload scaled up by anything else, such as kubectl scale or a deploy, wakes. Whoever did it wants it running. status.lastScaledUp records when, and what did it. For GitOps, see GitOps tools. While it runs, Napwake leaves its replicas to its team or HPA.

Only one ManagedWorkload can manage a Deployment or StatefulSet. A newer one for the same target gets a DuplicateTarget condition naming the other. It does nothing until the older one is gone.