Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
K

kubectl-cost

> 编程语言
Open source

CLI for determining the cost of Kubernetes workloads

1.0K stars0 likes1 views
WebsiteGitHub

About

CLI for determining the cost of Kubernetes workloads

kubectl-cost

kubectl-cost is a kubectl plugin that provides easy CLI access to Kubernetes cost information, like historical cost and predicted future cost, via Kubecost's APIs. It allows developers, devops, and others to quickly determine the cost & efficiency of any Kubernetes workload.

Note: If you use OpenCost, most of kubectl cost works! See the OpenCost documentation for examples. Let us know how it goes, and open an issue if you encounter any problems!

‼️ New! Starting with Kubecost v1.100, kubectl cost can estimate the cost of undeployed changes! Try it now with kubectl cost predict -f your-deployment.yaml:

 OBJECT                        Δ QTY  RESOURCE UNIT   COST PER UNIT     Δ COST/MO  % CHANGE 
────────────────────────────────────────────────────────────────────────────────────────────
 kubecost1 deployment            -92  CPU millicores      0.023 USD     -2.14 USD   -92.00% 
 kubecost1-cost-analyzer                                                                    
                             -172.65  RAM MiB            0.0030 USD     -0.53 USD   -43.38% 

Installation

  1. Install Kubecost

    This software requires that you have a running deployment of Kubecost in your cluster. The recommend path is to use Helm but there are alternative install options.

    Helm 3

    helm repo add kubecost https://kubecost.github.io/cost-analyzer/
    helm upgrade -i --create-namespace kubecost kubecost/cost-analyzer --namespace kubecost --set kubecostToken="a3ViZWN0bEBrdWJlY29zdC5jb20=xm343yadf98"
  2. Install kubectl cost

    Krew

    If you have Krew, the kubectl plugin manager, installed:

    bash
    kubectl krew install cost

    The Krew manifest can be found here.

    Linux/MacOS

    bash
    os=$(uname | tr '[:upper:]' '[:lower:]') && \
    arch=$(uname -m | tr '[:upper:]' '[:lower:]' | sed -e s/x86_64/amd64/) && \
    curl -s -L https://github.com/kubecost/kubectl-cost/releases/latest/download/kubectl-cost-$os-$arch.tar.gz | tar xz -C /tmp && \
    chmod +x /tmp/kubectl-cost && \
    sudo mv /tmp/kubectl-cost /usr/local/bin/kubectl-cost

    Latest Release

    If you prefer to download from GitHub, or are on Windows, go to the releases page and download the appropriate binary for your system. Rename it to kubectl-cost and put it in your PATH.

    As long as the binary is still named kubectl-cost and is somewhere in your PATH, it will be usable. This is because kubectl automatically finds plugins by looking for executables prefixed with kubectl- in your PATH.

    Alternatively, you can view DEVELOPMENT.md if you would like to build from source.

Usage

There are several subcommands that focused on aggregation-based cost monitoring: namespace, deployment, controller, label, pod, and node. They display cost information aggregated by the name of the subcommand (see Examples). Each aggregation subcommand has two modes: rate and non-rate. Rate (the default) displays the projected monthly cost based on the activity during the window. Non-rate (--historical) displays the total cost for the duration of the window.

Starting with v1.100 installations of Kubecost, kubectl cost predict is available. It uses historical resource cost information in your cluster to predict the cost implications of undeployed changes. It currently supports Pod, Deployment, and StatefulSet workloads, with more support on the way. It accepts YAML-formatted data either in a file (-f your-file.yaml) or from STDIN (-f -).

There is also kubectl cost tui, which displays a TUI and is currently limited to monthly rate projections. It supports most of the above subcommands while in an experimental status.

See the built-in usage info with --help to learn more about specific flags available for each subcommand.

Examples

Show the projected monthly rate for each namespace with all cost components displayed.

bash
kubectl cost namespace --show-all-resources

Example output:

…

Predict the cost impact of a YAML spec based on its requests:

bash
read -r -d '' DEF  If you are running an old version of Kubecost, you may have to replace `tcp-model` with `model`

If that `curl` succeeds, `--use-proxy` flag in CLI or setting up environment variable `KUBECTL_COST_USE_PROXY` should work for you.

Otherwise:
- There may be an underlying problem with your Kubecost install, try `kubectl port-forward`ing the `kubecost-cost-analyzer` service, port 9090, and querying [one of our APIs](https://docs.kubecost.com/apis/apis-overview).
- Your problem could be a security configuration that is preventing the API server communicating with certain namespaces or proxying requests in general.
- If you're still having problems, hit us up on Slack (see below) or open an issue on this repo.

## Requirements
A cluster running Kubernetes version 1.8 or higher

Have questions? Join our [Slack community](https://join.slack.com/t/kubecost/shared_invite/enQtNTA2MjQ1NDUyODE5LWFjYzIzNWE4MDkzMmUyZGU4NjkwMzMyMjIyM2E0NGNmYjExZjBiNjk1YzY5ZDI0ZTNhZDg4NjlkMGRkYzFlZTU) or contact us via email at [[email protected]]([email protected])!

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Go

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言