Kubecost needs access to the Microsoft Azure Billing Rate Card API to access accurate pricing data for your Kubernetes resources.
You can also get this functionality plus external costs by completing the full Azure billing integration.
Creating a custom Azure role
Start by creating an Azure role definition. Below is an example definition, replace YOUR_SUBSCRIPTION_ID with the Subscription ID where your Kubernetes cluster lives:
az ad sp create-for-rbac --name "KubecostAccess" --role "KubecostRole" --scope "/subscriptions/YOUR_SUBSCRIPTION_ID" --output json
Keep this information which is used in the service-key.json below.
Supplying Azure service principal details to Kubecost
Option 1: Via a Kubernetes Secret (Recommended)
Create a file called service-key.json and update it with the Service Principal details from the above steps:
{"subscriptionId":"<Azure Subscription ID>","serviceKey": {"appId":"<Entra ID App ID>","displayName":"KubecostAccess","password":"<Entra ID Client Secret>","tenant":"<Entra Tenant ID>" }}
Next, create a Secret for the Azure Service Principal
When managing the service account key as a Kubernetes Secret, the secret must reference the service account key JSON file, and that file must be named service-key.json.
Finally, set the kubecostProductConfigs.serviceKeySecretName Helm value to the name of the Kubernetes secret you created. We use the value azure-service-key in our examples.
Azure billing region, offer durable ID, and currency
Kubecost supports querying the Azure APIs for cost data based on the region, offer durable ID, and currency defined in your Microsoft Azure offer.
Those properties are configured with the following Helm values:
kubecostProductConfigs.azureBillingRegion
kubecostProductConfigs.azureOfferDurableID
kubecostProductConfigs.currencyCode
Be sure to verify your billing information with Microsoft and update the above Helm values to reflect your bill to country, subscription offer durable ID/number, and currency.
See also
The following Microsoft documents are a helpful reference: