kube-foresight
Right-size your Kubernetes deployments, forecast resource trends, and estimate the multi-cloud cost impact — in one tool, with kubectl-ready patches.
What it does
Most teams over-provision Kubernetes by 40–70% out of fear of outages — and fixing it usually means stitching several tools together: one to recommend new resources, another to apply them, another to watch for future breaches, another to price the change.
kube-foresight runs that whole loop in a single CLI and dashboard:
recommendation → kubectl-ready patch → breach forecast → multi-cloud cost
It reads live usage from your Metrics API or Prometheus, recommends right-sized requests and limits, emits a patch you review and kubectl apply, predicts when usage will breach current limits, and prices the reclaimed capacity across AWS / GCP / Azure.
Status: Alpha — under active development. Analysis is read-only (the CLI never changes your cluster), so it's safe to evaluate against real workloads; validate recommendations before applying them at scale. Production deployment reports, issues, and PRs especially welcome.
Install
pip install "kube-foresight[dashboard]" # Python 3.10+
Prefer a container? See Deployment.
Use it on your cluster
kube-foresight reads usage from the Kubernetes Metrics API (via metrics-server) or Prometheus. It never edits workloads itself — it writes patch files you apply on your own terms.
# 1. Find over-provisioned deployments
kube-foresight analyze -n production --mode k8s
kube-foresight recommend -n production --mode prometheus -p http://prometheus:9090
# 2. Generate kubectl-ready patches — review, then apply
kube-foresight patch -n production --mode k8s -o ./patches
kubectl apply -f ./patches/api-gateway-patch.yaml
# 3. Forecast when usage will breach current limits
kube-foresight forecast -n production --mode k8s
Preview without a cluster
See the full pipeline and dashboard against representative sample workloads — no cluster, RBAC, or metrics-server required:
kube-foresight demo # full pipeline, sample data
kube-foresight dashboard --demo # web UI at http://localhost:8080
Why trust the recommendations
Right-sizing is only useful if it doesn't cause the outages teams over-provision to avoid. kube-foresight is built defensively:
- It never auto-applies. It recommends and generates patches; every change to your cluster is one you trigger (
kubectl apply, or the dashboard's apply action). - Sizes on real demand. Recommendations use p95 / p99 of observed usage with configurable headroom, computed on raw data so demand spikes aren't discarded — under-provisioning is the dangerous error, so it errs toward the tail.
- Per-resource. CPU and memory are sized independently; a CPU-wasteful workload pinned at its memory limit gets its CPU cut without touching memory.
- HPA-aware. It refuses to recommend changes that would fight a HorizontalPodAutoscaler.
- Backtested. Recommendations are validated against a public production trace (Alibaba 2018) with a held-out train/test split. The methodology and results are in
benchmarks/.
What's in the box
- Three collectors — Kubernetes Metrics API, Prometheus, or mock (demo / CI)
- Statistical right-sizing — p95 / p99 / max strategies (p99 default), CPU and memory sized independently with configurable headroom
- Forecasting — linear-regression breach-time prediction with risk classification
- Multi-cloud cost estimation — prices reclaimable CPU/memory at approximate on-demand rates for AWS / GCP / Azure
- Patch generator — strategic-merge YAML you can
kubectl apply - Web dashboard — FastAPI + HTMX + Chart.js (overview, recommendations, cost comparison)
- Production plumbing — Dockerfile, Helm chart, health probes, structured JSON logs, optional Slack alerts
How costs are calculated: figures reflect reclaimable capacity — the difference between current and recommended requests, priced at approximate blended on-demand rates for the selected provider. Translating reclaimed capacity into billing changes depends on node consolidation by the cluster autoscaler; pair with Kubecost/OpenCost for allocation-accurate spend.
Where it fits
Several tools cover individual pieces of this well:
- KRR — Prometheus-based right-sizing recommendations.
- Goldilocks — surfaces VPA recommendations across a cluster.
- VPA — in-cluster vertical autoscaling that can apply changes automatically.
- Kubecost / OpenCost — allocation-accurate cost monitoring and spend reporting.
kube-foresight's niche is bringing right-sizing, breach forecasting, kubectl patch output, and side-by-side multi-cloud pricing into one workflow. If KRR already covers your recommendations and Kubecost your spend, you may not need it — it's for teams who'd rather run one loop than wire several tools together.
CLI reference
| Command | Purpose |
|---|---|
demo |
Full pipeline with sample data — no cluster required |
analyze |
Identify over-provisioned deployments |
collect |
Snapshot metrics into SQLite for trend analysis |
recommend |
Right-sizing recommendations + cost estimates |
patch |
Generate kubectl-applyable YAML patches |
forecast |
Predict resource trends and breach timelines |
dashboard |
Launch the web UI |
Common flags: --namespace/-n, --mode/-m {mock,k8s,prometheus}, --prometheus-url/-p, --strategy/-s {p95,p99,max}, --headroom 0.20, --top 10, --lookback 168.
Deployment
Docker
# Pull the published image (GitHub Container Registry)
docker run -p 8080:8080 ghcr.io/pallaprolus/kube-foresight:latest \
dashboard --host 0.0.0.0 --port 8080 --demo
# …or build from source
docker build -t kube-foresight .
docker run -p 8080:8080 kube-foresight dashboard --host 0.0.0.0 --port 8080 --demo
Helm
helm install kube-foresight charts/kube-foresight \
--set collector.mode=k8s \
--set collector.namespaces=production \
--set scheduler.enabled=true
See charts/kube-foresight/values.yaml for persistence, ingress, alerting, and authentication options.
Configuration
All settings are environment variables prefixed KF_:
| Variable | Purpose | Default |
|---|---|---|
KF_MODE |
Collector mode (mock, k8s, prometheus) |
k8s |
KF_NAMESPACES |
Comma-separated namespaces | default |
KF_CLOUD_PROVIDER |
Pricing source: aws, gcp, azure |
aws |
KF_SCHEDULER_ENABLED |
Background collect/analyze loop | false |
KF_COLLECT_INTERVAL |
Collection interval (seconds) | 300 |
KF_ANALYSIS_INTERVAL |
Analysis interval (seconds) | 900 |
KF_SLACK_WEBHOOK_URL |
Slack alerts for at-risk deployments | — |
KF_LOG_FORMAT |
text or json |
text |
Development
git clone https://github.com/pallaprolus/kube-foresight && cd kube-foresight
pip install -e ".[k8s,dashboard,dev]"
pytest tests/ -v --tb=short # 251 tests
ruff check .
helm lint charts/kube-foresight
For codebase layout, conventions, and the data-flow diagram, see docs/architecture.md.
Contributing
Issues and PRs are very welcome — particularly: real-world deployment reports, additional pricing providers, and validation of forecast accuracy on production traces. See CONTRIBUTING.md once filed.
License
Apache License 2.0
Metadata
Release files for kube-foresight 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| kube_foresight-0.3.1.tar.gz | 76.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kube_foresight-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 171.1 kB
Release files / kube_foresight-0.3.1.tar.gz
| Download URL | kube_foresight-0.3.1.tar.gz |
|---|---|
| Size | 76.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93a4643d6629946408877ebcb8d6287f54f22db49f8f8ee78c058eab4756983c
|
|
BLAKE2b-256 checksum How to use checksums |
f48b2eb0bbd17192bf1e38ffb46ebccd69b459702c8f85ff87ae95e5229d1824
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 14, 2026.
Transparency logRelease files / kube_foresight-0.3.1-py3-none-any.whl
| Download URL | kube_foresight-0.3.1-py3-none-any.whl |
|---|---|
| Size | 94.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d226c7a17355b5993396f5cd403d6db4f34104d6dfc55d70f0750682399e325e
|
|
BLAKE2b-256 checksum How to use checksums |
942f5b5d18b412065f2b8689dca2e06728f5ec4ae9fc7fe7c6799dd6805cfb6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 14, 2026.
Transparency logSecurity for kube-foresight 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for kube_foresight-0.3.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.