Cross-cloud cost allocation models for Kubernetes workloads https://kubecost.com

Thomas Evans c7706a4fb2 Renamed Kubecost Github reference to OpenCost 3 år sedan
.circleci e4fda39d08 add workflow 7 år sedan
.github c7706a4fb2 Renamed Kubecost Github reference to OpenCost 3 år sedan
cmd c7706a4fb2 Renamed Kubecost Github reference to OpenCost 3 år sedan
configs 6acae00e93 add test file 4 år sedan
kubernetes 4dfe2cf90e Added CORS headers to cmd/costmodel/main.go. 5 år sedan
pkg c7706a4fb2 Renamed Kubecost Github reference to OpenCost 3 år sedan
spec 8e70918ad1 Update opencost-specv01.md 4 år sedan
test c7706a4fb2 Renamed Kubecost Github reference to OpenCost 3 år sedan
ui 8ad90aee6b add module type 4 år sedan
.dockerignore 93dcd24356 Docker Ignore 5 år sedan
.gitignore 307528ace1 Update gitignore for costmodel binary 4 år sedan
CODE_OF_CONDUCT.md fe4762018e Update CODE_OF_CONDUCT.md 4 år sedan
CONTRIBUTING.md c7706a4fb2 Renamed Kubecost Github reference to OpenCost 3 år sedan
Dockerfile c7706a4fb2 Renamed Kubecost Github reference to OpenCost 3 år sedan
LICENSE e21bf66dc1 Add LICENSE 7 år sedan
PROMETHEUS.md 0c81c7a798 read and use gpu count 5 år sedan
README.md c7706a4fb2 Renamed Kubecost Github reference to OpenCost 3 år sedan
ROADMAP.md ccabcc2439 Add the concept of conformance tests to roadmap 4 år sedan
allocation-dashboard.png 4f9b246c1e Add files via upload 7 år sedan
allocation-drilldown.gif 87d607a9c6 Add files via upload 5 år sedan
deploying-as-a-pod.md c7706a4fb2 Renamed Kubecost Github reference to OpenCost 3 år sedan
go.mod c7706a4fb2 Renamed Kubecost Github reference to OpenCost 3 år sedan
go.sum 8ab25511ea Lexer and Parser for AllocationFilter v2 language 3 år sedan
kubecost-exporter.md 4dfe2cf90e Added CORS headers to cmd/costmodel/main.go. 5 år sedan
opencost-header.png c9a4dff062 opencost readme 4 år sedan

README.md

OpenCost — your favorite open source cost monitoring tool for Kubernetes

OpenCost models give teams visibility into current and historical Kubernetes spend and resource allocation. These models provide cost transparency in Kubernetes environments that support multiple applications, teams, departments, etc.

OpenCost was originally developed and open sourced by Kubecost. This project combines a specification as well as a Golang implementation of these detailed requirements.

OpenCost allocation UI

To see the full functionality of OpenCost you can view OpenCost features. Here is a summary of features enabled:

  • Real-time cost allocation by Kubernetes service, deployment, namespace, label, statefulset, daemonset, pod, and container
  • Dynamic asset pricing enabled by integrations with AWS, Azure, and GCP billing APIs
  • Supports on-prem k8s clusters with custom pricing sheets
  • Allocation for in-cluster resources like CPU, GPU, memory, and persistent volumes.
  • Allocation for AWS & GCP out-of-cluster resources like RDS instances and S3 buckets with key (optional)
  • Easily export pricing data to Prometheus with /metrics endpoint (learn more)
  • Free and open source distribution (Apache2 license)

Getting Started

You can deploy OpenCost on any Kubernetes 1.8+ cluster in a matter of minutes, if not seconds!

Visit the full documentation for recommended install options. Compared to building from source, installing from Helm is faster and includes all necessary dependencies.

Usage

Contributing

We :heart: pull requests! See CONTRIBUTING.md for information on buiding the project from source and contributing changes.

Community

If you need any support or have any questions on contributing to the project, you can reach us on Slack or via email at team@kubecost.com.

FAQ

How do you measure the cost of CPU/RAM/GPU/storage for a container, pod, deployment, etc.

The OpenCost cost model collects pricing data from major cloud providers, e.g. GCP, Azure and AWS, to provide the real-time cost of running workloads. Based on data from these APIs, each container/pod inherits a cost per CPU-hour, GPU-hour, Storage Gb-hour and cost per RAM Gb-hour based on the node where it was running or the class of storage provisioned. This means containers of the same size, as measured by the max of requests or usage, could be charged different resource rates if they are scheduled in separate regions, on nodes with different usage types (on-demand vs preemptible), etc.

For on-prem clusters, these resource prices can be configured directly with custom pricing sheets (more below).

Measuring the CPU/RAM/GPU cost of a deployment, service, namespace, etc is the aggregation of its individual container costs.

How do you determine RAM/CPU/GPU costs for a node when this data isn’t provided by a cloud provider?

When explicit RAM, CPU or GPU prices are not provided by your cloud provider, the OpenCost model falls back to the ratio of base CPU, GPU and RAM price inputs supplied. The default values for these parameters are based on the marginal resource rates of the cloud provider, but they can be customized within OpenCost.

These base RAM/CPU/GPU prices are normalized to ensure the sum of each component is equal to the total price of the node provisioned, based on billing rates from your provider. When the sum of RAM/CPU/GPU costs is greater (or less) than the price of the node, then the ratio between the input prices is held constant.

As an example, let's imagine a node with 1 GPU, 1 CPU and 1 Gb of RAM that costs $35/mo. If your base GPU price is $30, base CPU price is $30 and RAM Gb price is $10, then these inputs will be normalized to $15 for GPU, $15 for CPU and $5 for RAM so that the sum equals the cost of the node. Note that the price of a GPU, as well as the price of a CPU remain 3x the price of a Gb of RAM.

NodeHourlyCost = NORMALIZED_GPU_PRICE * # of GPUS + NORMALIZED_CPU_PRICE * # of CPUS + NORMALIZED_RAM_PRICE * # of RAM Gb

How do you allocate a specific amount of RAM/CPU to an individual pod or container?

Resources are allocated based on the time-weighted maximum of resource Requests and Usage over the measured period. For example, a pod with no usage and 1 CPU requested for 12 hours out of a 24 hour window would be allocated 12 CPU hours. For pods with BestEffort quality of service (i.e. no requests) allocation is done solely on resource usage.

How do I set my AWS Spot estimates for cost allocation?

Modify spotCPU and spotRAM in default.json to the level of recent market prices. Allocation will use these prices, but it does not take into account what you are actually charged by AWS. Alternatively, you can provide an AWS key to allow access to the Spot data feed. This will provide accurate Spot price reconciliation.

Do I need a GCP billing API key?

We supply a global key with a low limit for evaluation, but you will want to supply your own before moving to production.