MCPcopy Index your code
hub / github.com/robusta-dev/krr

github.com/robusta-dev/krr @v1.28.0 sqlite

repository ↗ · DeepWiki ↗ · release v1.28.0 ↗
406 symbols 1,641 edges 76 files 108 documented · 27%
README

![Product Name Screen Shot][product-screenshot]

Kubernetes Resource Recommendations Based on Historical Data

Get recommendations based on your existing data in Prometheus/Coralogix/Thanos/Mimir and more!

<a href="#installation"><strong>Installation</strong></a>
.
<a href="#how-krr-works"><strong>How KRR works</strong></a>
.
<a href="#free-krr-ui-on-robusta-saas"><strong>Free KRR UI</strong></a>



<a href="#usage">Usage</a>
·
<a href="https://github.com/robusta-dev/krr/issues">Report Bug</a>
·
<a href="https://github.com/robusta-dev/krr/issues">Request Feature</a>
·
<a href="#support">Support</a>






<a href="https://trendshift.io/repositories/7087" target="_blank"><img src="https://trendshift.io/api/badge/repositories/7087" alt="robusta-dev%2Fkrr | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>

About The Project

Robusta KRR (Kubernetes Resource Recommender) is a CLI tool for optimizing resource allocation in Kubernetes clusters. It gathers pod usage data from Prometheus and recommends requests and limits for CPU and memory. This reduces costs and improves performance.

Auto-Apply Mode

New: Put right-sizing on auto-pilot by applying recommendations automatically. Request beta access.

Data Integrations

Used to send data to KRR

View Instructions for: Prometheus, Thanos, Victoria Metrics, Google Managed Prometheus, Amazon Managed Prometheus, Azure Managed Prometheus, Coralogix,Grafana Cloud and Grafana Mimir

Reporting Integrations

Used to receive information from KRR

View instructions for: Seeing recommendations in a UI, Sending recommendations to Slack, Setting up KRR as a k9s plugin, Azure Blob Storage Export with Teams Notification

Features

  • No Agent Required: Run a CLI tool on your local machine for immediate results. (Or run in-cluster for weekly Slack reports.)
  • Prometheus Integration: Get recommendations based on the data you already have
  • Explainability: Understand how recommendations were calculated with explanation graphs
  • Extensible Strategies: Easily create and use your own strategies for calculating resource recommendations.
  • Free SaaS Platform: See why KRR recommends what it does, by using the free Robusta SaaS platform.
  • Future Support: Upcoming versions will support custom resources (e.g. GPUs) and custom metrics.

How Much Can I Expect to Save with KRR?

According to a recent Sysdig study, on average, Kubernetes clusters have:

  • 69% unused CPU
  • 18% unused memory

By right-sizing your containers with KRR, you can save an average of 69% on cloud costs.

Read more about how KRR works

Difference with Kubernetes VPA

Feature 🛠️ Robusta KRR 🚀 Kubernetes VPA 🌐
Resource Recommendations 💡 ✅ CPU/Memory requests and limits ✅ CPU/Memory requests and limits
Installation Location 🌍 ✅ Not required to be installed inside the cluster, can be used on your own device, connected to a cluster ❌ Must be installed inside the cluster
Workload Configuration 🔧 ✅ No need to configure a VPA object for each workload ❌ Requires VPA object configuration for each workload
Immediate Results ⚡ ✅ Gets results immediately (given Prometheus is running) ❌ Requires time to gather data and provide recommendations
Reporting 📊 ✅ Json, CSV, Markdown, Web UI, and more! ❌ Not supported
Extensibility 🔧 ✅ Add your own strategies with few lines of Python :warning: Limited extensibility
Explainability 📖 See graphs explaining the recommendations ❌ Not supported
Custom Metrics 📏 🔄 Support in future versions ❌ Not supported
Custom Resources 🎛️ 🔄 Support in future versions (e.g., GPU) ❌ Not supported
Autoscaling 🔀 🔄 Support in future versions ✅ Automatic application of recommendations
Default History 🕒 14 days 8 days
Supports HPA 🔥 ✅ Enable using --allow-hpa flag ❌ Not supported

Installation

Requirements

KRR requires Prometheus 2.26+, kube-state-metrics & cAdvisor.

Which metrics does KRR need?

No setup is required if you use kube-prometheus-stack or Robusta's Embedded Prometheus.

If you have a different setup, make sure the following metrics exist:

  • container_cpu_usage_seconds_total
  • container_memory_working_set_bytes
  • kube_replicaset_owner
  • kube_pod_owner
  • kube_pod_status_phase

Note: If one of last three metrics is absent KRR will still work, but it will only consider currently-running pods when calculating recommendations. Historic pods that no longer exist in the cluster will not be taken into consideration.

Installation Methods

Brew (Mac/Linux)

  1. Add our tap:
brew tap robusta-dev/homebrew-krr
  1. Install KRR:
brew install krr
  1. Check that installation was successful:
krr --help
  1. Run KRR (first launch might take a little longer):
krr simple

Windows

You can install using brew (see above) on WSL2, or install from source (see below).

Docker image, binaries, and airgapped installation (offline environments)

You can download pre-built binaries from Releases or use the prebuilt Docker container. For example, the container for version 1.8.3 is:

us-central1-docker.pkg.dev/genuine-flight-317411/devel/krr:v1.8.3

We do not recommend installing KRR from source in airgapped environments due to the headache of installing Python dependencies. Use one of the above methods instead and contact us (via Slack, GitHub issues, or email) if you need assistance.

In-Cluster

Apart from running KRR as a CLI tool you can also run KRR inside your cluster. We suggest installing KRR via the Robusta Platform . It gives you a free UI with some features like the following * View application usage history graphs on which recommendations are based. * Get application, namespace and cluster level recommendations. * YAML configuration to apply the suggested recommendation and more

You can also run KRR in-cluster as a Kubernetes Job, if you don't want to view results easily in a UI.

kubectl apply -f https://raw.githubusercontent.com/robusta-dev/krr/refs/heads/main/docs/krr-in-cluster/krr-in-cluster-job.yaml

From Source

  1. Make sure you have Python 3.9 (or greater) installed
  2. Clone the repo:
git clone https://github.com/robusta-dev/krr
  1. Navigate to the project root directory (cd ./krr)
  2. Install requirements:
pip install -r requirements.txt
  1. Run the tool:
python krr.py --help

Notice that using source code requires you to run as a python script, when installing with brew allows to run krr. All above examples show running command as krr ..., replace it with python krr.py ... if you are using a manual installation.

Additional Options

Environment-Specific Instructions

Setup KRR for... - Google Cloud Managed Prometheus - Azure Managed Prometheus - Amazon Managed Prometheus - Coralogix Managed Prometheus - Grafana Cloud Managed Prometheus - Grafana Mimir

(back to top)

Trusting custom Certificate Authority (CA) certificate:

If your llm provider url uses a certificate from a custom CA, in order to trust it, base-64 encode the certificate, and store it in an environment variable named CERTIFICATE

Free KRR UI on Robusta SaaS

We highly recommend using the free Robusta SaaS platform. You can:

  • Understand individual app recommendations with app usage history
  • Sort and filter recommendations by namespace, priority, and more
  • Give devs a YAML snippet to fix the problems KRR finds
  • Analyze impact using KRR scan history

Usage

Basic usage

krr simple

Tweak the recommendation algorithm (strategy)

Most helpful flags:

  • --cpu-min Sets the minimum recommended cpu value in millicores
  • --mem-min Sets the minimum recommended memory value in MB
  • --history_duration The duration of the Prometheus history data to use (in hours)

More specific information on Strategy Settings can be found using

krr simple --help

Giving an Explicit Prometheus URL

If your Prometheus is not auto-connecting, you can use kubectl port-forward for manually forwarding Prometheus.

For example, if you have a Prometheus Pod called `kub

Core symbols most depended-on inside this repo

get
called by 89
enforcer/model.py
get
called by 24
robusta_krr/utils/object_like_dict.py
items
called by 23
robusta_krr/utils/object_like_dict.py
format
called by 16
robusta_krr/core/models/result.py
undefined
called by 12
robusta_krr/core/abstract/strategies.py
_list_all_groupedjobs
called by 9
robusta_krr/core/integrations/kubernetes/__init__.py
add_resource_value
called by 8
enforcer/patch_manager.py
custom_print
called by 7
robusta_krr/core/runner.py

Shape

Method 221
Function 112
Class 68
Route 5

Languages

Python100%

Modules by API surface

robusta_krr/core/integrations/kubernetes/__init__.py38 symbols
robusta_krr/core/runner.py26 symbols
robusta_krr/core/models/config.py20 symbols
robusta_krr/core/integrations/prometheus/metrics_service/prometheus_metrics_service.py15 symbols
robusta_krr/core/abstract/strategies.py15 symbols
robusta_krr/core/integrations/prometheus/metrics/base.py14 symbols
tests/test_grouped_jobs.py13 symbols
robusta_krr/core/models/objects.py12 symbols
enforcer/resources/owner_store.py12 symbols
robusta_krr/core/models/result.py11 symbols
enforcer/enforcer_main.py11 symbols
robusta_krr/strategies/simple_limit.py10 symbols

Dependencies from manifests, versioned

PyYAML6.0.1 · 1×
about-time4.2.1 · 1×
alive-progress3.1.5 · 1×
boto31.42.19 · 1×
botocore1.42.19 · 1×
cachetools5.3.3 · 1×
certifi2024.2.2 · 1×
charset-normalizer3.3.2 · 1×
click8.1.7 · 1×
colorama0.4.6 · 1×
commonmark0.9.1 · 1×
contourpy1.2.0 · 1×

For agents

$ claude mcp add krr \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact