Skip to content

Commit

Permalink
fix: Copy Kubecost assets to generated site directory, update formati…
Browse files Browse the repository at this point in the history
…ng for mkdocs rendering# Description (#1923)
  • Loading branch information
bryantbiggs committed Apr 24, 2024
1 parent f7ed1ea commit 835a4d1
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 25 deletions.
13 changes: 12 additions & 1 deletion .github/scripts/mkdocs-hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
from pprint import pprint

def on_page_markdown(markdown, **kwargs):
return markdown.replace('../../patterns/targeted-odcr/', './')
markdown.replace('../../patterns/targeted-odcr/', './')
markdown.replace('../../patterns/kubecost/', './')

return markdown

def on_files(files, config, **kwargs):
# Add targeted-odcr screenshots to the generated build
Expand All @@ -18,4 +20,13 @@ def on_files(files, config, **kwargs):
)
)

files.append(
File(
src_dir='./patterns/kubecost/assets/',
dest_dir=os.path.join(config.site_dir, 'patterns/kubecost/assets/'),
path='screenshot.png',
use_directory_urls=True
)
)

return files
7 changes: 0 additions & 7 deletions docs/patterns/sso-iam-identity-center-cam.md

This file was deleted.

File renamed without changes.
48 changes: 32 additions & 16 deletions patterns/kubecost/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ The terraform code was created following the official Kubecost documentation for

You need a valid Kubecost token. To generate one, follow the instructions [here](https://www.kubecost.com/install#show-instructions).

## Deploy

# Deploy
```
```sh
terraform init
terraform apply -target="module.vpc" -auto-approve
terraform apply -target="module.eks" -auto-approve
Expand All @@ -18,44 +18,60 @@ 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>
```sh
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 template file called `crawler-cfn.yml` in the S3 bucket. Once that file is generated, navigate to:

```
```sh
cd run-me-in-24h/
```

To download and apply the CloudFormation template, run:
```

```sh
terraform init
terraform apply --auto-approve
```

## Kubecost UI

To access the Kubecost UI run:

```sh
echo http://$(kubectl -n kubecost get svc cost-analyzer-cost-analyzer \
-o jsonpath='{.status.loadBalancer.ingress[0].hostname}'):9090/
```
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.

and then 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.
---

<div align="center">
<img
src="./assets/screenshot.png"
width="70%"
alt="Kubecost diagnostics screenshot"
/>
</div>

---

!!! note
Spot Data Feed is included in Savings Plan, Reserved Instance, and Out-Of-Cluster.

## Destroy

First destroy the CloudFormation template:
```

```sh
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"
Expand Down
File renamed without changes
1 change: 0 additions & 1 deletion patterns/sso-iam-identity-center/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ configure_sso_admin = <<EOT
# aws eks --region us-west-2 update-kubeconfig --name iam-identity-center --profile EKSClusterAdmin
EOT
```

Expand Down

0 comments on commit 835a4d1

Please sign in to comment.