Installing On-Premises (on-prem)
OpenCost may be installed on-prem and provides default pricing that may be overridden.
You will need to install Prometheus, create your OpenCost namespace, configure your cluster pricing and cloud costs, and then install OpenCost.
Install Prometheus
Prometheus is a prerequisite for OpenCost installation. OpenCost requires Prometheus for scraping metrics and data storage. For the installation of Prometheus please use the following command:
helm install prometheus --repo https://prometheus-community.github.io/helm-charts prometheus \
--namespace prometheus-system --create-namespace \
--set prometheus-pushgateway.enabled=false \
--set alertmanager.enabled=false \
-f https://raw.githubusercontent.com/opencost/opencost/develop/kubernetes/prometheus/extraScrapeConfigs.yaml
This will install Prometheus in the prometheus-system
namespace with default settings for use with OpenCost.
If you wish to use a different Prometheus installation or work with another compatible technology, please refer to the Prometheus installation page.
Create the OpenCost Namespace
Create the opencost
namespace for your installation:
kubectl create namespace opencost
Alternate namespaces may be used if necessary.
On-Prem Configuration
On-prem cluster pricing is supported in OpenCost by providing default prices for node data via the default.json. Here are the include default prices:
{
"provider": "custom",
"description": "Default prices based on GCP us-central1",
"CPU": "0.031611",
"spotCPU": "0.006655",
"RAM": "0.004237",
"spotRAM": "0.000892",
"GPU": "0.95",
"storage": "0.00005479452",
"zoneNetworkEgress": "0.01",
"regionNetworkEgress": "0.01",
"internetNetworkEgress": "0.12"
}
Custom pricing using the OpenCost Helm Chart
Custom pricing may be applied by updating your local OpenCost Helm values file. Any values not overridden will default to the values provided by the Helm chart, which match those in the default.json.
opencost:
customPricing:
enabled: true
costModel:
description: Modified prices based on your internal pricing
CPU: 1.25
RAM: 0.50
storage: 0.25
The values in the example above will be reflected in the OpenCost with substantially higher CPU, RAM, and PV costs compared to the default pricing.
On-Prem Cloud Costs
*** Cloud Costs are not currently supported for on-prem, but you may configure OpenCost to view costs associated with other cloud service providers.***
You may refer to the Cloud Costs documentation for configuring Cloud Costs for multiple accounts and cloud service providers.
Install OpenCost
Helm is the preferred installation method for OpenCost.
Using the OpenCost Helm Chart
You may check out the source for the OpenCost Helm Chart or you may install the Helm chart directly to your Kubernetes cluster. Review the values.yaml for the settings available for customization. With your custom settings in the Helm values file local.yaml
, install OpenCost:
helm install opencost --repo https://opencost.github.io/opencost-helm-chart opencost \
--namespace opencost -f local.yaml
Updating OpenCost via Helm
Upgrading the Helm chart version or updating settings may be done with the following:
helm upgrade opencost --repo https://opencost.github.io/opencost-helm-chart opencost \
--namespace opencost -f local.yaml
Installing with the OpenCost Manifest
Installing from the OpenCost manifest is supported for on-prem.
For basic Kubernetes Cost Allocations without Cloud Costs or any customizations you may use the OpenCost manifest. Prometheus is still required and the Helm chart installation is recommended for anything beyond this simple use case.
kubectl apply --namespace opencost -f https://raw.githubusercontent.com/opencost/opencost/develop/kubernetes/opencost.yaml