OpenCost Plugin
Overview
Section titled “Overview”The opencost plugin reads Kubernetes allocation cost over HTTP from an
OpenCost endpoint and serves it to FinFocus. It
reports what the cluster actually spent per namespace, controller, pod, or
node, so it is the source for Kubernetes actual cost.
It needs a reachable OpenCost allocation API. It does not read cloud provider
credentials. With the default opencost profile it sends no token.
Using Kubecost
Section titled “Using Kubecost”There is no separate Kubecost plugin. To read a Kubecost endpoint, install
opencost and select the kubecost profile:
export OPENCOST_PROFILE=kubecostexport KUBECOST_BASE_URL=https://kubecost.example.comexport KUBECOST_API_TOKEN=...The kubecost profile calls GET /model/allocation and sends the token as a
bearer token when one is set. It has not been verified against a live Kubecost
yet; its responses are contract fixtures. Prefer the default opencost profile
when you can run OpenCost.
Features
Section titled “Features”- Actual Costs:
totalCostfrom the allocation rows that match the resource and the request window. A matching row with zero cost returns zero. No matching row isNotFound. - Projected Costs: A 30-day trailing average projected to a 730-hour
month. The response says so in
billing_detail. - Pricing Specs, Estimate, and Batch:
GetPricingSpecuses the same 30-day data.EstimateCostand batch cost are also available. See the plugin README for how each profile answers them. - Budgets:
GetBudgetsis available for thekubecostprofile. - Caching and Limits: A successful allocation query is reused for 30 seconds by default, and outbound requests are rate limited.
Installation
Section titled “Installation”finfocus plugin install opencost
# Or from the repository pathfinfocus plugin install github.com/rshade/finfocus-plugin-opencostfinfocus setup does not install this plugin by default.
Configuration
Section titled “Configuration”Point the plugin at your allocation API and, optionally, a config file:
export KUBECOST_BASE_URL=http://localhost:9003export OPENCOST_CONFIG=/path/to/config.yaml| Setting | Environment variable | Default | Effect |
|---|---|---|---|
baseUrl |
KUBECOST_BASE_URL |
empty | Origin of the allocation API. Queries need it. |
profile |
OPENCOST_PROFILE |
opencost |
opencost or kubecost. |
currency |
OPENCOST_CURRENCY |
empty | ISO 4217 code when the data names no single one. |
timeout |
KUBECOST_TIMEOUT |
15s |
HTTP client timeout. |
tlsSkipVerify |
KUBECOST_TLS_SKIP_VERIFY |
false |
Skips certificate checks. Leave it off on shared clusters. |
The API token is read only from KUBECOST_API_TOKEN and is never written to
logs. See the
plugin README
for every key.
Supported Providers
Section titled “Supported Providers”The registry lists provider kubernetes.
Supported Resource Types
Section titled “Supported Resource Types”| Resource Type | Resource id |
|---|---|
kubernetes:core/v1:Namespace |
namespace/<name> |
kubernetes:apps/v1:Deployment, StatefulSet, DaemonSet, ReplicaSet, kubernetes:batch/v1:Job, CronJob |
controller/<namespace>/<name> |
kubernetes:core/v1:Pod |
pod/<namespace>/<name> |
kubernetes:core/v1:Node |
node/<name> |
The short types k8s-namespace, k8s-pod, k8s-node, and k8s-controller
also work. kubernetes:core/v1:Service is not supported.
finfocus cost actual --pulumi-state state.jsonfinfocus cost projected --pulumi-json plan.jsonLimitations
Section titled “Limitations”- Needs a Backend: Without a reachable OpenCost endpoint there are no results.
- Trailing Average: Projected cost extends the last 30 days of observed spend. It does not model a planned change.
- Kubecost Profile Not Yet Verified: Its responses are contract fixtures and are not verified against a live Kubecost.
- No Allocation Service: The plugin does not implement
AllocatorService. - Idle and Shared Cost: Requests exclude idle and shared cost.
See the plugin README for per-method details.