Integrating Kubecost with your AWS data provides the ability to allocate out of cluster costs, e.g. RDS instances and S3 buckets, back to Kubernetes concepts like namespace and deployment as well as reconcile in cluster assets back to your billing data. The latter is especially helpful when teams are using Reserved Instances, Savings Plans, or Enterprise Discounts. All billing data remains on your cluster when using this functionality and is not shared externally.
The following guide provides the steps required for enabling out of cluster costs allocation and accurate pricing, e.g. Reserved Instance price allocation. In a multi-account organization, all of the following steps will need to be completed in the payer account.
Step 1: Create an AWS Cost and Usage Report and Integrate it with Kubecost
Step 2: Tag your resources
Kubecost utilizes AWS tagging to allocate the costs of AWS resources outside of the Kubernetes cluster to specific Kubernetes concepts, such as namespaces, pods, etc. These costs are then shown in a unified dashboard within the Kubecost interface.
To allocate external AWS resources to a Kubernetes concept, use the following tag naming scheme:
|Kubernetes Concept||AWS Tag Key||AWS Tag Value|
kubernetes_label_NAME tag key, the
NAME portion should appear exactly as the tag appears inside of Kubernetes. For example, for the tag
app.kubernetes.io/name, this tag key would appear as
To use an alternative or existing AWS tag schema, you may supply these in your values.yaml under the “kubecostProductConfigs.labelMappingConfigs.<aggregation>_external_label” . Also be sure to set kubecostProductConfigs.labelMappingConfigs.enabled = true
More on AWS tagging here.
Tags may take several hours to show up in the Cost Allocations Tags section described in the next step.
Step 3: Enable User-Defined Cost Allocation Tags
In order to make the custom Kubecost AWS tags appear on the cost and usage reports, and therefore in Kubecost, individual cost allocation tags must be enabled. Details on which tags to enable can be found in Step #2 of this doc.
Instructions for enabling user-defined cost allocation tags here
- Visit the Allocation view in the Kubecost product. If external costs are not shown, open your browser’s Developer Tools > Console to see any reported errors.
- Query Athena directly to ensure data is availble. Note: it can take up to 6 hours for data to be written.
- You may need to upgrade your AWS Glue if you are running an old version https://docs.aws.amazon.com/athena/latest/ug/glue-upgrade.html
- Finally, review pod logs from the
cost-modelcontainer in the
cost-analyzerpod and look for auth errors or Athena query results.