TL;DR: Kruize analyzes your Kubernetes workload metrics and automatically generates right-sizing recommendations for CPU, memory, and GPU resources β reducing costs and improving performance without manual tuning.
Kruize is an open-source optimization tool for Kubernetes that helps you achieve significant cost savings and optimal performance with minimal effort. It continuously monitors your applications and provides right-sizing recommendations for container and namespace resources like CPU and memory, as well as NVIDIA GPU MIG slices. Kruize serves as the powerful backend engine for the Resource Optimization Service within Red Hat Insights, a service now available to all OpenShift Container Platform (OCP) users.
Kruize connects to your monitoring stack (such as Prometheus or Thanos) and analyzes historical workload resource usage to generate actionable right-sizing recommendations. By continuously observing real usage patterns, it identifies over- and under-provisioned resources and provides right-sizing recommendations β improving performance for under-provisioned workloads and reducing costs for over-provisioned ones.
Recommendations are generated for:
-
Containers β CPU and Memory requests and limits
-
Namespaces β Resource quota limits for CPU and Memory
-
NVIDIA GPUs β Optimal MIG slice configurations for supported accelerators (e.g., A100, H100)
Kruize supports both predefined terms (short, medium, long) and custom terms, allowing recommendations to align with your desired observation window. You can also choose between performance-optimized or cost-optimized profiles based on your workload priorities.
Kruize can be installed via the Kruize operator which simplifies deployment and management of Kruize on Kubernetes and OpenShift clusters. It provides a declarative way to configure and deploy Kruize components including the core Kruize service and UI through Custom Resource Definitions (CRDs).
Here is the documentation for installing Kruize via Operator OCP_installation.md.
Kruize has a demos repo that enables users to get a quick start without worrying about the setup, and it's a great first-step for first time users. You can start by running the Local Monitoring demo.
We recommend you check out the kruize-demos repo in case you want to know more about VPA demo, GPU demo, HPO demo and a lot more!
This guide provides step-by-step instructions for manual setup. For automated setup, skip to the section below.
You need access to any Kubernetes environment like Kind, Minikube, or OpenShift with Prometheus running in the cluster.
To install Prometheus, use the following scripts for Kind or Minikube. OpenShift installs Prometheus by default.
Follow benchmarks installation instructions to install sysbench benchmark.
The following instructions assume that a Kubernetes cluster and Prometheus are installed on your machine, and the application for which you want to generate recommendations has been running for at least 30 minutes.
Clone the Kruize & Benchmarks repositories using the following commands:
git clone git@github.com:kruize/autotune.git
git clone git@github.com:kruize/benchmarks.git
cd autotuneKruize can be installed on kind, minikube, or OpenShift. In this guide, we use kind to show the installation process.
./deploy.sh -c kind -m crc
# For other cluster types, use: ./deploy.sh -c minikube or ./deploy.sh -c openshiftBefore proceeding :
- For OpenShift: Expose Kruize & UI service via routes
- For Kind/Minikube: Port-forward Kruize & UI services
Port-forward commands for Kind/Minikube:
kubectl port-forward svc/kruize -n monitoring 8080:8080 &
kubectl port-forward svc/kruize-ui-nginx-service -n monitoring 8081:80 &
export KRUIZE_URL="http://localhost:8080"Metadata Profile: Contains queries to collect namespace, workload and container data from your monitoring system. It tells Kruize how to fetch metrics from your specific environment (Prometheus/Thanos endpoints, query formats, cluster-specific labels). Without it, Kruize cannot retrieve data even if the metrics exist.
Install metadata profile:
curl -X POST http://${KRUIZE_URL}/createMetadataProfile \
-H "Content-Type: application/json" \
-d @manifests/autotune/metadata-profiles/bulk_cluster_metadata_local_monitoring.jsonMetric Profile: Defines what metrics to monitor (CPU, memory, response time) and optimization goals (minimize cost, maintain performance SLOs). It tells Kruize what "good performance" means for your application. Without it, Kruize cannot determine the right trade-offs between cost and performance.
Install metric profile:
curl -X POST http://${KRUIZE_URL}/createMetricProfile \
-H "Content-Type: application/json" \
-d @manifests/autotune/performance-profiles/resource_optimization_local_monitoring.jsonImport metadata: Imports metadata from your datasource to discover workloads running in your cluster.
curl -X POST http://${KRUIZE_URL}/dsmetadata \
-H 'Accept: application/json' \
--data 'copy paste below JSON' {
"version": "v1.0",
"datasource_name": "prometheus-1",
"metadata_profile": "cluster-metadata-local-monitoring",
"measurement_duration": "15min"
}- For container-level experiment
This is the Create Experiment JSON that has container-related details.
[{
"version": "v2.0",
"experiment_name": "monitor_sysbench",
"cluster_name": "default",
"performance_profile": "resource-optimization-local-monitoring",
"metadata_profile": "cluster-metadata-local-monitoring",
"mode": "monitor",
"target_cluster": "local",
"datasource": "prometheus-1",
"kubernetes_objects": [
{
"type": "deployment",
"name": "sysbench",
"namespace": "default",
"containers": [
{
"container_image_name": "quay.io/kruizehub/sysbench",
"container_name": "sysbench"
}
]
}
],
"trial_settings": {
"measurement_duration": "2min"
},
"recommendation_settings": {
"threshold": "0.1"
}
}]Command to create experiment:
curl -X POST http://${KRUIZE_URL}/createExperiment -d @container_experiment_sysbench.json- For namespace-level experiment
In the above JSON, change the experiment name & modify the Kubernetes object to :
"kubernetes_objects": [
{
"namespaces": {
"namespace": "default"
}
}
]Command to create namespace experiment:
curl -X POST http://${KRUIZE_URL}/createExperiment -d @namespace_experiment_sysbench.jsonWait for at least 2 data points to be collected (approx. 30 minutes with default settings), then:
# Generate recommendations for container experiment
curl -X POST "http://${KRUIZE_URL}/generateRecommendations?experiment_name=<experiment-name>"
# List recommendations
curl -X GET "http://${KRUIZE_URL}/listRecommendations?experiment_name=<experiment-name>"You can also take a look at the UI to better understand recommendations.
See the Kruize Architecture for more details on the architecture.
For complete API specifications and examples, see the Kruize API Documentation.
If you're exploring more around Kruize, here are related repositories you may find useful:
- kruize-demos - Demo scripts to showcase Kruize functionality
- benchmarks - Performance benchmarking workloads
- kruize-operator - Operator for deploying Kruize in your OpenShift or Kubernetes cluster.
- kruize-website - Source code for the official Kruize website
- kruize-ui - User Interface to interact with Kruize backend
- hpo - Hyperparameter Optimization framework
- kruize-vpa - Vertical Pod Autoscaler integration for Kruize
We welcome your contributions! See CONTRIBUTING.md for more details.
Join the Kruize Slack to connect with the community, ask questions, and collaborate!
Apache License 2.0, see LICENSE.
