Skip to content

feat(k8s): size every container from Prometheus history with KRR #4992

Done

Description

@dan-petty

Problem or Motivation

Each limit in the cluster is fixed today after a kill (#4116, #4149, #2806, #1815, #2391, #4939). 24 containers have no memory limit, ollama-48gib included. Some requests are far above use: argocd-repo-server uses about 178 MiB of its 4Gi limit, and the llm Valkey uses about 17 MiB of 2Gi. The scheduler sees these requests as used room. This item is rank 3 of the cluster integration plan #4989.

Proposed Solution & Architectural Design

Phase 1 (S), this issue:

  1. Run KRR (robusta-dev/krr, MIT, v1.31.3 or later) from a workstation against the Prometheus ingress and the kubeconfig, with the cluster label set and JSON output. KRR writes nothing to the cluster and needs no pod.
  2. Leave out the runner and stage Jobs. feat(roadmap): size the runner Job resources from the plan #3193 sizes them from the plan.
  3. Policy:
    • Memory limit at least 1.5 times the 7 d peak. KRR simple gives the peak plus 15 %, which is thin for a slow leak.
    • CPU request from KRR.
    • Keep a CPU limit on every container. KRR recommends none, but the project sets one.
  4. Give the 24 containers with no memory limit a limit, ollama-48gib included.
  5. Lower the requests that are far above use (argocd-repo-server, valkey), so the scheduler sees the free room. Read the Valkey rows together with maxmemory and ValkeyMemoryNearBound.
  6. Put the KRR table in a comment on this issue, and set the values in git in one pull request.

Phase 2 (M) is a later issue, after #4566: a CronWorkflow in argo-workflows with a read-only ClusterRole and a NetworkPolicy path to prometheus-server. The JSON report is the Workflow output. A pull-request step can follow.

Evidence

KRR reads only data that Prometheus already holds: cAdvisor CPU and memory, kube_pod_owner, kube_replicaset_owner, kube_job_owner, and the requests and limits. git grep finds no right-sizing tool or VPA in k8s/. Phase 1 needs no pod, so it does not wait for #4566.

Target Subsystem

Kubernetes & Minikube Automation.

Existing Tool Considered

KRR (MIT). The Vertical Pod Autoscaler recommender gives the same sizing, but needs a pod, 3 CRDs and about 40 objects in git, and keeps 8 d of history by default. It was rejected.

Acceptance Criteria

  • A comment on this issue holds the KRR table and the policy values.
  • One pull request sets the values. Each container, except the runner and stage Jobs, has a memory limit and a CPU limit.
  • No memory limit is below 1.5 times its 7 d peak.

Dependencies

#4991: run KRR after it merges, so that the report covers the other containers.

Source: #4989

Alternatives check of 2026-11-21: covers.
Tool: robusta-dev/krr (https://github.com/robusta-dev/krr), MIT, last activity 2026-11-11, maintained.
Reason: The issue already names KRR as its considered tool, and the facts confirm an open CLI that reads Prometheus history and recommends CPU and memory for every container with no cluster write, which is the whole Phase 1 need.

Covers:

  • Reads cAdvisor and kube-state history from Prometheus only
  • Sizes memory and CPU request per container
  • Memory buffer flag yields 1.5 times the 7 d peak
  • JSON report feeds the issue table and change folder

Lacks:

  • No CPU limit recommendation; it advises no limits
  • Writes nothing to git; a person sets the values
  • No scheduled in-cluster run for Phase 2
  • Valkey maxmemory ratio and its alert stay outside the report

Proposed design

Problem statement

Each limit in the cluster is fixed after a kill. 24 containers have no memory limit, ollama-48gib included. Some requests sit far above use, so the scheduler counts room that no container uses. The sizing needs a KRR report from the cluster Prometheus and a change to the environment tree, which this repository refuses. This change adds the offline check that keeps each Valkey --maxmemory at most three quarters of its container memory limit. The sizing is deferred to a new issue.

Acceptance criteria

Requirement: A Valkey bound above three quarters of its limit

The k8s row of devops ci SHALL report each container that runs valkey-server with a --maxmemory value above three quarters of its memory limit.

Scenario: A bound above three quarters of the limit

  • WHEN The test passes the check a rendered Deployment object whose valkey container sets --maxmemory 512mb and a memory limit of 512Mi.
  • THEN The check returns one finding that names the container valkey, its bound and its memory limit.

Requirement: A Valkey bound at exactly three quarters

The check SHALL report no finding for a bound at exactly three quarters of the memory limit.

Scenario: A bound at exactly three quarters

  • WHEN The test passes the check a rendered Deployment object whose valkey container sets --maxmemory 768mb and a memory limit of 1Gi.
  • THEN The check returns no finding.

Requirement: A Valkey with no bound is no ratio finding

The check SHALL ignore each container that runs valkey-server with no --maxmemory value.

Scenario: A Valkey with no bound

  • WHEN The test passes the check a rendered Deployment object whose valkey container sets no --maxmemory.
  • THEN The check returns no finding.

Requirement: Each Valkey bound of the tree stays under three quarters of its limit

Each container of the environment tree that runs valkey-server with --maxmemory SHALL keep that bound at most three quarters of its memory limit.

Scenario: The Valkeys of the environment tree

  • WHEN The check runs uv run devops ci --check --only k8s.
  • THEN The row reports no finding of a Valkey bound above three quarters of its memory limit.

Existing Tool Considered

KRR (robusta-dev/krr, MIT, https://github.com/robusta-dev/krr), verdict covers, as the alternatives check in the issue body records; the Covers: and Lacks: lists of its block say what the tool covers and lacks. The Lacks: list says that the Valkey --maxmemory ratio stays outside the report, so this change adds the offline check of that ratio in the k8s row. The sizing itself is deferred, because no krr binary is present and this repository refuses a change to an environment path.

Key questions

  • The alternatives check found that https://github.com/robusta-dev/krr covers this item. Adopt the tool, or keep the item and give the reason.: Adopt KRR. A reply to the check says to set the memory limit of an Ollama tier when the KRR report sizes it and to remove its annotation, so the item relies on the report. KRR is open, MIT and maintained, and it reads Prometheus history with no cluster write. (best practice) [sources: docs/guidelines/kubernetes.md:4, k8s/llm/profiles/ollama-profiles.yaml:221]
    • Chosen: Adopt KRR. The verdict is covers, the tool is MIT and maintained, and a reply to the check relies on its report.
    • Rejected: Keep the item and write a script of the project. The block lists no gap that a script closes, and the guideline puts an open tool before a script of the project.
  • Which part of the item can this repository build?: The offline check of the Valkey --maxmemory ratio in the k8s row. Each manifest of the sizing is an environment path, and uv run devops ci --check --only k8s refuses a change to an environment path. (best practice) [sources: tests/gate/k8s_checks/environment_freeze.py, openspec/specs/llm-valkey/spec.md:9, k8s/llm/valkey-devops.yaml]
    • Chosen: Add the ratio check to the k8s row. The check lives in tests/gate/k8s_checks/, outside the environment tree, and it holds the three-quarters rule that no check holds today.
    • Rejected: Edit the target manifests here. The freeze check marks each target manifest as an environment path, and the k8s row refuses the change.
    • Rejected: Add the Prometheus rule here. k8s/monitoring/prometheus-values.yaml is an environment path too, and the rule needs a live cluster to prove.
  • Where does the check read the bound and the memory limit?: From the rendered manifests of the k8s row. The row renders each application of the environment tree once, and the rendered container holds its command and its memory limit. (best practice) [sources: tests/gate/k8s_checks/environment_freeze.py, k8s/llm/valkey-devops.yaml]
    • Chosen: The rendered manifests of the k8s row. The row already builds each path source, and the build holds the command and the limit.
    • Rejected: A pytest test that reads the manifest files. A test asserts no value of a manifest, so the row is the proof.
  • How does the check compare a bound in mb with a limit in Mi?: It reads the mb, gb and kb suffix of --maxmemory as 1024-based bytes, and the Mi, Gi and Ki suffix of the limit as 1024-based bytes. The project already reads --maxmemory 256mb against memory: 384Mi as two thirds. (best practice) [sources: k8s/llm/valkey-devops.yaml, k8s/README.md:283, openspec/specs/llm-valkey/spec.md:9]
    • Chosen: 1024-based bytes for both suffixes. k8s/README.md:283 reads 1536 MiB as three quarters of 2048Mi, so the project treats mb as Mi.
    • Rejected: Decimal bytes for the Valkey suffix. The project's own reading of the cache Valkey uses 1024-based bytes.
  • What does the check do with a valkey container that sets no --maxmemory?: It reports no finding. The check covers only a bound that the container sets, and the item sets no rule for a Valkey with no bound. (best practice) [sources: k8s/README.md:283, k8s/llm/valkey-runs.yaml]
    • Chosen: Report no finding. The item sets no rule for a Valkey with no bound, and the run index has no exporter.
    • Rejected: Report a missing bound as a finding. The row would fail on a manifest that the item does not size, and it adds a rule that the project did not decide.
  • Why is the sizing deferred to a new issue?: The target manifests are environment paths, and uv run devops ci --check --only k8s refuses a change to an environment path. A person must run KRR v1.31.3 from a workstation with the cluster kubeconfig and the Prometheus ingress, and dan-petty/homelab#109 tracks the Ollama tier limits in the homelab repo. [sources: tests/gate/k8s_checks/environment_freeze.py, k8s/llm/profiles/ollama-profiles.yaml:221]
  • What does the change do with the six Ollama tier annotations?: The deferred issue removes each ignore-check.kube-linter.io/unset-memory-requirements annotation when the KRR report sizes the tier. kube-linter then guards the limit with no ignore marker. (best practice) [sources: k8s/llm/profiles/ollama-profiles.yaml:221, .kube-linter.yaml:14]
    • Chosen: Remove the annotation with the limit. The annotation hides the check, and the reply to the alternatives check asks for its removal.
    • Rejected: Keep the annotation. The limit then has no guard.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Moved to new items

dan-petty/homelab#375

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/feature
    scope/k8s
    status/new
    value/high
    effort/low
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Alternatives check: covers

    Reason: Searches and the repository facts point to KRR (robusta-dev/krr, MIT, maintained, v1.31.3), a read-only recommender that derives container CPU/memory requests and limits from Prometheus usage history and owner metrics, which is exactly the Phase 1 sizing this issue plans. It does not recommend CPU limits, and applying the values in git and the later CronWorkflow stay with the project.

    Tool: robusta-dev/krr (https://github.com/robusta-dev/krr)

    • License: MIT
    • Last activity: 2026-11-11
    • Maintained: yes

    Covers:

    • Reads Prometheus cAdvisor CPU/memory history plus pod/replicaset/job owner metrics and existing requests and limits
    • Produces per-container right-sizing recommendations with no cluster writes and no pod, runnable from a workstation with a kubeconfig and Prometheus URL
    • Supports a cluster label and JSON output, so the report can be posted as the issue comment

    Lacks:

    • Recommends no CPU limit, while the project keeps a CPU limit on every container
    • Its simple memory recommendation (peak plus about 15 %) is below the issue's 1.5x-peak limit policy, so the buffer has to be raised or a custom strategy used
    • Does not write the values into git; the single pull request that sets them is project work
    • Does not interpret the Valkey rows against maxmemory and ValkeyMemoryNearBound; that reading is manual
    • Does not run itself as the Phase 2 in-cluster CronWorkflow; that workflow, ClusterRole and NetworkPolicy are project work

    Tools considered:

    Searches run:

    • KRR Kubernetes Resource Recommender Prometheus right-sizing, results: 5
    • open source tool recommend Kubernetes CPU memory requests limits from Prometheus history, results: 5
    • krr prometheus resource recommendations kubernetes, results: 5
    • robusta-dev krr github, results: 5
    • "Kubernetes Resource Recommender" KRR, results: 5
    • Goldilocks VPA recommendations dashboard kubernetes requests limits, results: 5
    • krr robusta prometheus, results: 5
    • vertical pod autoscaler recommender vs krr, results: 5
    • krr --memory-buffer-percentage --history-duration prometheus-url json output, results: 5

    Sources:

    Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.

  6. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Owner question: Should the item adopt KRR (robusta-dev/krr), which the alternatives check of 2026-11-15 finds covers the item, or keep the item and give the reason? (a person decides)

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  7. dan-petty commented on Nov 17, 2026

    @dan-petty
    OwnerAuthor

    Pull request #6112 (for #6068) runs kube-linter unset-memory-requirements in CI. The Ollama tiers ollama-24gib, ollama-32gib, ollama-48gib, ollama-72gib, ollama-96gib and ollama-128gib set no memory limit on the container ollama. Each holds the annotation ignore-check.kube-linter.io/unset-memory-requirements with this item as the reason. When the KRR report sizes a tier, set its limit and remove its annotation.

  8. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at c58b592 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

  9. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Owner question: A person must run KRR v1.31.3 from a workstation with the cluster kubeconfig and the Prometheus ingress and commit the JSON report, because the runner pod mounts no Kubernetes token.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  10. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Owner question: See Suspected block and Watched files in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  11. 5 remaining items

  12. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  13. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor

    Returning #4992 to New: this leaf item cannot be built in devops-cli as specified.

    Evidence from origin/main and this workspace:

    • The item requires running KRR (v1.31.3) from a workstation with cluster kubeconfig and Prometheus ingress to write openspec/changes/<issue>-<slug>/krr-report.json and live PromQL checks against cluster Prometheus. In this environment command -v krr is absent, no openspec/changes/*4992* report exists, and the design notes runner pods set automountServiceAccountToken: false.
    • Every target manifest (k8s/llm/profiles/ollama-profiles.yaml, k8s/llm/valkey-devops.yaml, k8s/llm/valkey-runs.yaml, k8s/monitoring/prometheus-values.yaml, etc.) is outside k8s/devops/ and k8s/overlays/homelab/devops/, so tests/gate/k8s_checks/environment_freeze.py:38-75 (is_environment_path("k8s/llm/profiles/ollama-profiles.yaml") == True) rejects edits there in devops ci --check --only k8s.
    • Open dan-petty/homelab#109 already tracks setting the Ollama tier memory limits in dan-petty/homelab.
  14. added
    status/new
    and removed
    status/ready
    on Nov 25, 2026
  15. added
    status/ready
    and removed
    status/new
    on Nov 25, 2026
  16. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.

  17. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 25, 2026
  18. removed
    status/in-review
    on Nov 25, 2026
  19. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor
  20. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-25 17:09 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/k8ssource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions