-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pattern): Kubecost with AWS CUR Report (#1862)
Co-authored-by: Rodrigo Bersa <[email protected]>
- Loading branch information
1 parent
66207c8
commit 5296f9a
Showing
9 changed files
with
628 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
crawler-cfn.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Kubecost with AWS Cloud Billing Integration | ||
|
||
This pattern demostrates how to install and configure Kubecost with AWS CUR report. | ||
The terraform code was created following the official Kubecost documentation for [aws cloud billing integration](https://docs.kubecost.com/install-and-configure/install/cloud-integration/aws-cloud-integrations). | ||
|
||
## Prerequisites | ||
|
||
You need a valid Kubecost token. To generate one, follow the instructions [here](https://www.kubecost.com/install#show-instructions). | ||
|
||
|
||
# Deploy | ||
``` | ||
terraform init | ||
terraform apply -target="module.vpc" -auto-approve | ||
terraform apply -target="module.eks" -auto-approve | ||
terraform apply -auto-approve --var="kubecost_token=<your-kubecost-token>" | ||
``` | ||
|
||
Once all of the resources have successfully been provisioned, the following command can be used to update the `kubeconfig` on your local machine and allow you to interact with your EKS Cluster using `kubectl`. | ||
|
||
``` | ||
aws eks --region <REGION> update-kubeconfig --name <CLUSTER_NAME> | ||
``` | ||
|
||
This command will create a S3 bucket with prefix `kubecost-` and a Cost and Usage Report (CUR). Within 24h The CUR will generate a CloudFormation teamplate file called `crawler-cfn.yml` in the S3 bucket. Once that file is generated, navigate to: | ||
|
||
``` | ||
cd run-me-in-24h/ | ||
``` | ||
To download and apply the CloudFormation template, run: | ||
``` | ||
terraform init | ||
terraform apply --auto-approve | ||
``` | ||
|
||
## Kubecost UI | ||
To access the Kubecost UI run: | ||
``` | ||
echo http://$(kubectl -n kubecost get svc cost-analyzer-cost-analyzer -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'):9090/ | ||
``` | ||
and navigate to the output URL. | ||
|
||
Navigate to Settings -> Diagnostics -> View Full Diagnostics | ||
|
||
Expected result: | ||
![screenshot](static/screenshot.png) | ||
|
||
> [!NOTE] | ||
> Spot Data Feed is included in Savings Plan, Reserved Instance, and Out-Of-Cluster. | ||
## Destroy | ||
First destroy the CloudFormation template: | ||
``` | ||
cd run-me-in-24h/ | ||
terraform destroy --auto-approve | ||
``` | ||
|
||
``` | ||
cd .. | ||
terraform destroy -target="module.eks_blueprints_addon" --var="kubecost_token=<your-kubecost-token>" -auto-approve | ||
terraform destroy -target="module.eks_blueprints_addons" | ||
terraform destroy -target="module.eks" -auto-approve | ||
terraform destroy -auto-approve | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
kubecostToken: ${kubecostToken} | ||
|
||
global: | ||
grafana: | ||
enabled: false | ||
proxy: false | ||
|
||
serviceAccount: | ||
create: true | ||
name: ${service-account} | ||
annotations: | ||
eks.amazonaws.com/role-arn: ${iam-role-arn} | ||
|
||
service: | ||
type: LoadBalancer | ||
port: 9090 | ||
targetPort: 9090 | ||
labels: {} | ||
annotations: {} | ||
sessionAffinity: | ||
enabled: false # Makes sure that connections from a client are passed to the same Pod each time, when set to `true`. You should set it when you enabled authentication through OIDC or SAML integration. | ||
timeoutSeconds: 10800 | ||
|
||
kubecostProductConfigs: | ||
projectID: ${projectID} | ||
spotLabel: eks.amazonaws.com/capacityType | ||
spotLabelValue: SPOT | ||
athenaProjectID: ${athenaProjectID} | ||
athenaBucketName: ${athenaBucketName} | ||
athenaRegion: ${athenaRegion} | ||
athenaDatabase: ${athenaDatabase} | ||
athenaTable: ${athenaTable} |
Oops, something went wrong.