resize-operator

module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2026 License: Apache-2.0

README

resize-operator (alpha)

Requirements

  • metrics-server (pod usage via metrics.k8s.io)
  • Kubernetes cluster with in-place Pod resize support (pods/resize subresource). The operator checks capability and degrades gracefully if unsupported.

Fast install

helm install resize-operator oci://ghcr.io/iamhalje/charts/resize-operator -n resize-operator-system --create-namespace

How it works

On each reconcile loop the operator:

  • selects candidate Pods (namespace selector + pod label selector)
  • fetches PodMetrics from metrics.k8s.io
  • computes desired requests based on the policy
  • executes pods/resize (dry-run + apply)
  • writes annotations and emits Resized events
%%{init: {'flowchart': {'nodeSpacing': 60, 'rankSpacing': 80}}}%%
flowchart TB

  subgraph METRICS["Metrics API"]
    MS[metrics-server]
  end

  subgraph OPERATOR["Resize Operator"]
    SEL[Select candidate Pods]
    CALC[Compute desired requests]
    REC[Write annotations<br/>and emit Resized events]
  end

  subgraph CONTROL_PLANE["Kubernetes Control Plane"]
    APIS[kube-apiserver]
    SCHED[scheduler]
  end

  subgraph NODE["Node"]
    KUBELET[kubelet]
  end

  SEL -->|fetch PodMetrics| MS
  MS -->|PodMetrics| CALC
  CALC -->|pods/resize<br/>dry-run + apply| APIS
  APIS --> KUBELET
  KUBELET -->|resource update| SCHED
  APIS --> REC

Resize logic

The operator computes new requests based on the current resource usage from metrics.k8s.io, using headroomPercent.

  • Target: target = usage * (1 + headroomPercent/100)
  • Rounding: CPU is rounded to 50m steps, memory to 64Mi steps
  • Small changes are skipped based on:
    • relative thresholds upPercent / downPercent
    • absolute minimum change minChangeCPU / minChangeMemory
  • Bounds: computed requests are clamped to configured min/max
  • Limits behavior is controlled by limitsMode:
    • Unchanged: keep limits as-is
    • EqualRequests: set limits equal to requests
  • Anti-thrash:
    • stabilizationWindow: the desired target must stay stable before apply
    • cooldown: skip pods shortly after a resize

Observability

More docs

Directories

Path Synopsis
api
v1alpha1
Package v1alpha1 contains API Schema definitions for the resize v1alpha1 API group.
Package v1alpha1 contains API Schema definitions for the resize v1alpha1 API group.
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL