Skip to main content

OpenCost Setup

OpenCost requires a Kubernetes cluster to be deployed. Users should be running Kubernetes 1.20+ and Kubernetes 1.28 is officially supported as of v1.105.

OpenCost requires Prometheus for scraping metrics and data storage. Follow the steps below to install OpenCost.

Quick Start Installation

These commands will get you started immediately with OpenCost.

Install Prometheus

helm install my-prometheus --repo prometheus \
--namespace prometheus --create-namespace \
--set prometheus-pushgateway.enabled=false \
--set alertmanager.enabled=false \

Install OpenCost

kubectl apply --namespace opencost -f

That is all that is required for most initial installations.

Integrating Cloud Costs

If you want more accurate results or Cloud Costs from your provider's bill please refer to the Cloud Service Provider Configuration page. You will need to manage your deployment with the Helm chart to configure this.


The Cloud Costs feature is not in the current stable release yet. Please use the OpenCost image and the OpenCost UI image to access this beta feature.


Once your OpenCost has been installed, wait for the pod to be ready and port forward with:

kubectl port-forward --namespace opencost service/opencost 9003 9090

To verify that the UI and server are running, you may access the OpenCost UI at http://localhost:9090.

To verify that the server is running, access http://localhost:9003/allocation/compute?window=60m

Testing with Kubectl Cost Plugin

For a curated, command line output, we recommend installing kubectl cost plugin:

kubectl cost --service-port 9003 --service-name opencost --kubecost-namespace opencost --allocation-path /allocation/compute  \
namespace \
--window 5m \


| | opencost | 18.295200 | 0.231010 |
| | prometheus | 17.992800 | 0.000000 |
| | kube-system | 11.383200 | 0.033410 |
| SUMMED | | 47.671200 | |

Testing with OpenCost API

You can see here more API Examples

Updating OpenCost

To update your OpenCost to the most recent version, using a previously unmodified opencost.yaml manifest, enter the following command. This will update OpenCost to the latest version.

kubectl -n opencost rollout restart deployment

To check logs to verify the version of your OpenCost:

$  kubectl logs -n opencost deployment/opencost | head
2022-09-02T18:20:34.327989163Z ??? Log level set to info
2022-09-02T18:20:34.328206357Z INF Starting cost-model (git commit "x.xx.x")

Sidegrading OpenCost

If you wish to modify OpenCost to a previous version, start with the following command in order to modify the opencost.yaml manifest:

In the line, change latest to the desired version number in the format prod-x.xx.x. Then enter the following command to apply the updated opencost.yaml manifest:

$ kubectl apply -f opencost.yaml -n opencost
namespace/opencost unchanged
serviceaccount/opencost unchanged unchanged unchanged
deployment.apps/opencost configured
service/opencost unchanged

Finally, check the logs to verify the version of your OpenCost has successfully been changed:

$  kubectl logs -n opencost deployment/opencost | head
2022-09-02T18:20:34.327989163Z ??? Log level set to info
2022-09-02T18:20:34.328206357Z INF Starting cost-model (git commit "x.xx.x")

Deleting OpenCost

To delete OpenCost, enter the following command:

kubectl delete -f


If you get an error like this, check your Prometheus target is correct in the OpenCost deployment.

Error: failed to query allocation API: failed to port forward query: received non-200 status code 500 and data: {"code":500,"status":"","data":null,"message":"Error: error computing allocation for ...

Negative values for idle: ensure you added the scrape target (above) for OpenCost.

Enabling Debugging

With the v1.100 release you can temporarily set the log level of the OpenCost container without restarting the Pod. You can send a POST request to /logs/level with one of the valid log levels. This does not persist between Pod restarts, Helm deployments, etc. Here's an example:

curl -X POST \
'http://localhost:9003/logs/level' \
-d '{"level": "debug"}'

A GET request can be sent to the same endpoint to retrieve the current log level.


Please let us know if you run into any issues, we are here to help!

Join us on CNCF Slack in the #opencost channel if you have questions or contact us via email (

Documentation Distributed under CC BY 4.0.  The Linux Foundation® (TLF) has registered trademarks and uses trademarks. For a list of TLF trademarks, see: Trademark Usage.