Cloud Costs (Out of Cluster Costs)
The Cloud Cost functionality allows Kubernetes admins to allocate out of cluster costs to Kubernetes environments.
Out of cluster costs e.g. costs for cloud services like S3, RDS or Lambda can be allocated to individual Kubernetes artefacts like Namespaces as well as Labels.
The ability to allocate out of cluster costs to Kubernetes artefacts provides a more accurate picture of the costs of that Kubernetes artefact and by extension of the entire Kubernetes environment.
The Cloud Cost functionality supports AWS and Azure services as of now. Additionally, out of cluster costs can be allocated to Kubernetes Namespaces and Labels. Support for other cloud providers and allocating costs to other Kubernetes artefacts like clusters, deployments, services etc is on the roadmap.
Below we will walkthrough the process of allocating cloud service costs for both AWS and Azure to Kubernetes Namespaces and Labels.
Let's start off with AWS.

Allocating AWS Service Costs

To allocate AWS service costs you first need to add AWS billing credentials to your Replex account. Follow this guide to add billing credentials for AWS. Please add the following permission to the policy:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor1", "Effect": "Allow", "Action": [ ... "ce:GetTags" ], "Resource": "*" }, ...
In addition, the following permission must be added for the AWS cost allocation tags to work: CostExplorer Permission: ce:GetTags
Once the billing integration is complete we are ready to allocate AWS service costs to Kubernetes Namespaces and Labels.

Allocating AWS Service Costs to Namespaces

Below we walkthrough an example of tagging S3 on AWS and allocating it's costs to a Namespace in our Kubernetes environment. Costs for other AWS services like RDS, Lambda and ElasticCache can also be allocated by following the steps outlined below.
For more advanced tagging practices please refer to this AWS tagging guide.

Tag Resources/Services

To enable the allocation of external AWS service costs to Kubernetes artefacts the cloud cost functionality utilizes the AWS tagging mechanism.
To apply the relevant tag, browse to the S3 dashboard on your AWS console and click on the bucket name you want to add the tag to. Next click on the Properties tab in the S3 bucket screen, scroll down to the Tag section and click Edit.
On the next screen click Add Tag.
Enter the following value in the tag Key field:
CLOUDCOST_TAG_KEY_NAMESPACE
Enter the name of the Namespace you want to add the S3 costs to in the tag Value field.
Click Save changes.

Enable User Defined Cost Allocation Tags

The tags applied in the previous step need to be activated in the AWS console. To do this browse to the AWS Billing & Cost Management Dashboard.
Click on Cost allocation tags in the panel on the left hand side. In the next screen, under the User-defined cost allocation tags section, choose the tag added in the previous step and click on Activate.
Please be aware that tags added in the previous step may take several hours to populate in the User-defined cost allocation tags section.

Allocating AWS Service Costs to Labels

In this section we walkthrough an example of tagging S3 on AWS and allocating its costs to a Label in our Kubernetes environment.
Follow the steps outlined in the Namespaces example above to navigate to the "Edit Bucket Tagging" screen for the S3 bucket you want to allocate costs for.
Enter the following in the tag Key field:
CLOUDCOST_TAG_KEY_LABEL_<K8s_Label_Key>
and
<K8s_Label_Value>
in the tag Value field.
K8s_Label_Key and K8s_Label_Value in the example above depend on the Kubernetes Label that you want to allocate the costs to.
The following tag Key and Value will be used for the Kubernetes Label "app" : "postgres":
Tag Key: CLOUDCOST_TAG_KEY_LABEL_app
Tag Value: postgres
Similarly for "tier" : "frontend" the following tag Key and Value will be used:
Tag Key: CLOUDCOST_TAG_KEY_LABEL_tier
Tag Value: frontend
For our example we use the "app" : "postgres" label.
Click Save changes.
Next activate the tag we just added by navigating to the User-defined cost allocation tags section of the AWS Billing & Cost Management Dashboard.

Allocating Azure Service Costs

As with AWS, the first step in allocating Azure service costs is to add Azure billing credentials to your Replex account. Follow this guide to add billing credentials for Azure.
Once the billing integration is complete we are ready to allocate Azure service costs to Kubernetes Namespaces and Labels.

Allocating Azure Service Costs to Namespaces

Below we walkthrough an example of tagging an Azure SQL database and allocating it's costs to a Namespace in our Kubernetes environment. Costs for other Azure services can also be allocated by following the steps outlined below.

Tag Resources/Services

Navigate to the relevant SQL database on your Azure console and click on the database name you want to add the tag to.
Next click on tags in the left hand panel and enter the following in the Name field:
CLOUDCOST_TAG_KEY_NAMESPACE
Enter the name of the Namespace you want to allocate the SQL costs to in the tag Value field.
Click Apply.
Tag SQL Database

Activate Azure Tag

The tags applied in the previous step need to be activated in the Azure console. To do this navigate to the Azure Cost Management + Billing service.
In the Azure Cost Management + Billing dashboard click on Cost Management in the left hand panel. In the next screen, scroll down to the Settings section and click on Configuration.
In the next screen click on Tags and add the tag we created in the previous step.
Click Apply.
Activate Azure Tag

Allocating Azure Service Costs to Kubernetes Labels

In this section we walkthrough an example of tagging an Azure SQL database and allocating its costs to a Label in our Kubernetes environment.
Follow the steps outlined in the example above to navigate to the Tags section of the SQL database you want to allocate costs for.
Enter the following in the tag Key field:
CLOUDCOST_TAG_KEY_LABEL_<K8s_Label_Key>
and
<K8s_Label_Value>
in the tag Value field.
Click Apply.
Activate the tag we just added by navigating to the Configuration section of the Azure Cost Management + Billing dashboard.

Viewing Allocated Cloud Costs

Once tagged the costs for the Kubernetes Namespaces or Labels will populate in the Replex UI.
External cloud costs can be viewed in the Namespaces Overview screen of the Cluster Dashboard.
External cloud costs are accumulated in both the Allocated Cost Combined and Allocated Cost Detailed charts of the Namespaces Overview.
Additionally cloud costs for each namespace are provided in the Cost Details section of the Namespace Overview in a separate External Cost column.
External Cloud Costs Namespace Overview
The Detailed Namespace View also provides a cost breakdown for individual out of cluster resources allocated to a Namespace. It outlines both the Resource Type as well as its cost for the time period chosen.
Cost breakdowns for out of cluster resources can be viewed by clicking on Show External Resources in the Detailed Namespace View.
Cost Breakdown for Out of Cluster Resources
External cloud costs can also be viewed on the Teams Dashboard. Each individual Team dashboard outlines external cloud costs under the External tab.
The External tab breaks down cloud costs by Resource Type as well as the Namespace/Label they are assigned to.
External Cloud Costs Teams Dashboard
Copy link
On this page
Allocating AWS Service Costs
Allocating Azure Service Costs
Viewing Allocated Cloud Costs