Skip to content

Commit 90f0d88

Browse files
Merge pull request #156 from anveshmuppeda/feature/docs_update
Adding new guides: node viewer and kubecost
2 parents 990659d + 447c12a commit 90f0d88

File tree

7 files changed

+888
-1
lines changed

7 files changed

+888
-1
lines changed

docs/eks-guides/006-eks-auto-mode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
// filepath: /Users/anveshmuppeda/Desktop/anvesh/tech/git/kubernetes/docs/eks/006-eks-auto-mode.md
33
sidebar_label: "EKS Auto Mode"
4-
sidebar_position: 5
4+
sidebar_position: 6
55
---
66
# Amazon EKS Auto Mode: A Hands-On Guide
77
#### *Automate compute, networking, and storage in your Kubernetes clusters with step-by-step instructions.*

docs/eks-guides/007-kubecost.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
---
2+
// filepath: /Users/anveshmuppeda/Desktop/anvesh/tech/git/kubernetes/docs/eks/007-kubecost.md
3+
sidebar_label: "Kubecost"
4+
sidebar_position: 7
5+
---
6+
7+
# Amazon EKS Kubecost: A Hands-On Guide
8+
#### *Monitor and optimize your Kubernetes costs with step-by-step instructions.*
9+
10+
Here’s a concise guide covering what Kubecost is, why you’d use it, and exactly how to install, access, and uninstall it on Amazon EKS (without mentioning specific version numbers).
11+
12+
![Kubecost](./img/kubecost.gif)
13+
14+
### **Summary**
15+
[Kubecost](https://github.com/kubecost) is an open‑core tool that provides real‑time visibility into your Kubernetes spending—breaking down costs by cluster, namespace, pod, node, and label—to help teams allocate, optimize, and continuously reduce cloud costs. You can deploy it on Amazon EKS either as an AWS‑managed add‑on or via Helm, then port‑forward or expose its dashboard to visualize and manage your spend. When you’re done, you can remove it cleanly with a single CLI command or Helm uninstall sequence.
16+
17+
## What is Kubecost and Why Use It
18+
19+
Kubecost provides real‑time cost visibility and insights for teams running Kubernetes, helping you continuously reduce your cloud spend by surfacing where costs occur and suggesting optimizations.
20+
It breaks down your bill by cluster, namespace, pod, node, persistent volume, and custom labels—enabling charge‑back, show‑back, and right‑sizing across teams or projects.
21+
22+
## Installing Kubecost
23+
24+
### 1. As an Amazon EKS Add‑on
25+
26+
**Prerequisites**
27+
28+
* Subscribe to “[Kubecost – Amazon EKS cost monitoring](https://aws.amazon.com/marketplace/seller-profile?id=983de668-2731-4c99-a7e2-74f27d796173)” in the AWS Marketplace.
29+
* Have `kubectl`, the AWS CLI, and access to your EKS cluster.
30+
31+
**Install using AWS CLI**
32+
33+
```bash
34+
aws eks create-addon \
35+
--addon-name kubecost_kubecost \
36+
--cluster-name YOUR_CLUSTER_NAME \
37+
--region YOUR_REGION
38+
```
39+
![Kubecost EKS Add-on](./img/kubecost-addon.png)
40+
41+
**Install using CFT**
42+
43+
Use the [AWS CloudFormation template - Kubecost](./cloudformation/eks-kubecost.yaml) to deploy the
44+
IBM Kubecost - Amazon EKS cost monitoring add‑on.
45+
46+
47+
This deploys the AWS‑optimized Kubecost bundle, complete with built‑in Prometheus and kube‑state‑metrics.
48+
49+
### 2. With Helm
50+
51+
**Prerequisites**
52+
53+
* Install `kubectl`, Helm 3+, and access to your EKS cluster (plus the Amazon EBS CSI driver).
54+
55+
**Install**
56+
57+
1. Add the Kubecost Helm repo
58+
59+
```bash
60+
helm repo add kubecost https://kubecost.github.io/cost-analyzer/
61+
helm repo update
62+
```
63+
2. Install the Kubecost Helm chart
64+
65+
```bash
66+
helm install kubecost kubecost/cost-analyzer -n kubecost --create-namespace \
67+
--set kubecostToken="aGVsbUBrdWJlY29zdC5jb20=xm343yadf98"
68+
```
69+
kubecostToken, it is generated at http://kubecost.com/install, used for alerts tracking and free trials.
70+
Or you can use the following command to install the latest version of Kubecost:
71+
72+
```bash
73+
helm upgrade -i kubecost \
74+
oci://public.ecr.aws/kubecost/cost-analyzer \
75+
--namespace kubecost --create-namespace \
76+
-f https://raw.githubusercontent.com/kubecost/cost-analyzer-helm-chart/develop/cost-analyzer/values-eks-cost-monitoring.yaml
77+
```
78+
79+
This drops in Kubecost along with its required dependencies; you can further customize via additional Helm values.
80+
81+
## Using Kubecost
82+
83+
1. **Verify pods are running**
84+
85+
```bash
86+
> kubectl get pods -n kubecost
87+
NAME READY STATUS RESTARTS AGE
88+
kubecost-cost-analyzer-ff44d778f-lsgrh 4/4 Running 0 5m16s
89+
kubecost-forecasting-56475fdf55-jwb26 1/1 Running 0 5m16s
90+
kubecost-prometheus-server-bb875b789-zd6d9 1/1 Running 0 5m16s
91+
```
92+
2. **Expose the dashboard**
93+
94+
```bash
95+
> kubectl port-forward --namespace kubecost deployment/kubecost-cost-analyzer 9090
96+
Forwarding from 127.0.0.1:9090 -> 9090
97+
Forwarding from [::1]:9090 -> 9090
98+
Handling connection for 9090
99+
Handling connection for 9090
100+
```
101+
3. **Browse the UI**
102+
Open [http://localhost:9090](http://localhost:9090) in your browser to view cost allocations, asset spend, and efficiency insights .
103+
104+
## Uninstalling Kubecost
105+
106+
### Remove the EKS Add‑On
107+
108+
```bash
109+
aws eks delete-addon \
110+
--addon-name kubecost_kubecost \
111+
--cluster-name YOUR_CLUSTER_NAME \
112+
--region YOUR_REGION
113+
```
114+
115+
### Remove the CloudFormation Stack
116+
117+
```bash
118+
aws cloudformation delete-stack \
119+
--stack-name YOUR_STACK_NAME
120+
```
121+
This removes the Kubecost add‑on and all associated resources.
122+
123+
### Uninstall the Helm Release
124+
```bash
125+
helm uninstall kubecost --namespace kubecost
126+
kubectl delete namespace kubecost
127+
```
128+
129+
---
130+
131+
With this guide, you can quickly set up Kubecost for cost visibility in your EKS clusters, explore your spending through a live dashboard, and remove it cleanly when it’s no longer needed.
132+
133+
---
134+
## Additional Resources
135+
* [Kubecost Documentation](https://docs.kubecost.com/)
136+
* [Kubecost GitHub](https://github.com/kubecost)
137+
* [Kubecost on AWS Marketplace](https://aws.amazon.com/marketplace/seller-profile?id=983de668-2731-4c99-a7e2-74f27d796173)
138+
* [Kubecost on AWS Blog](https://docs.aws.amazon.com/eks/latest/userguide/cost-monitoring-kubecost.html)
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
---
2+
// filepath: /Users/anveshmuppeda/Desktop/anvesh/tech/git/kubernetes/docs/eks/008-eks-node-viewer.md
3+
sidebar_label: "EKS Node Viewer"
4+
sidebar_position: 8
5+
---
6+
7+
# EKS Node Viewer: A Hands-On Guide
8+
#### *Visualize and optimize your EKS node usage with this open-source CLI tool.*
9+
10+
![EKS Node Viewer](./img/eks-node-viewer.gif)
11+
12+
## Summary
13+
EKS Node Viewer is an open‑source CLI tool for visualizing scheduled pod resource requests against a node’s allocatable capacity in Amazon EKS clusters, originally built at AWS to showcase workload consolidation with Karpenter. It helps identify under‑ and over‑utilized nodes, driving cost and performance optimization. Installation is straightforward via Homebrew or a Go install, and its rich flag set lets you tailor context, resource types, labels, sorting, and even on‑the‑fly pricing lookups. Key use‑cases include rightsizing clusters, validating consolidation strategies, and enhancing SRE visibility into node utilization.
14+
15+
---
16+
17+
## Introduction
18+
19+
EKS Node Viewer is a CLI tool for visualizing dynamic node usage within a Kubernetes cluster by comparing scheduled pod resource requests to each node’s allocatable capacity, without measuring actual consumption .
20+
It was originally developed as an internal AWS tool to demonstrate consolidation capabilities in Karpenter before being open‑sourced .
21+
22+
---
23+
24+
## Why Use EKS Node Viewer
25+
26+
1. **Immediate Utilization Insights**
27+
Quickly spot nodes that are under‑utilized (wasting resources) or over‑utilized (risking performance issues) by viewing request vs. capacity .
28+
29+
2. **Optimize Cost and Performance**
30+
By identifying consolidation opportunities, you can safely reduce node counts or reclaim unused capacity, complementing Karpenter’s autoscaling and spot instance workflows.
31+
32+
3. **Enhanced SRE Visibility**
33+
Provides a clear, real‑time overview of cluster footprint, aiding incident response and capacity planning.
34+
35+
---
36+
37+
## What It Is & Key Use Cases
38+
39+
* **Visualization of Scheduled Requests**: Shows CPU, memory (and optionally other resources) requests on each node versus what’s allocatable .
40+
* **Consolidation Validation**: Confirm that Karpenter’s consolidation logic places pods optimally and safely drains nodes when needed.
41+
* **Cost Auditing**: With optional pricing lookups, estimate the cost impact of node usage in real‑time (can be disabled if AWS credentials aren’t available) .
42+
43+
---
44+
45+
## Installation
46+
47+
### Homebrew
48+
49+
```bash
50+
brew tap aws/tap
51+
brew install eks-node-viewer
52+
```
53+
54+
This installs the latest stable version via the AWS Homebrew tap .
55+
56+
### Manual (Go)
57+
58+
```bash
59+
go install github.com/awslabs/eks-node-viewer/cmd/eks-node-viewer@latest
60+
```
61+
62+
By default this places the binary in your `GOBIN` (e.g., `~/go/bin`) .
63+
64+
---
65+
66+
## Usage
67+
68+
Run without arguments to inspect all nodes in your current context:
69+
70+
```bash
71+
eks-node-viewer
72+
```
73+
74+
### Key Flags
75+
76+
```bash
77+
Usage of ./eks-node-viewer:
78+
-attribution
79+
Show the Open Source Attribution
80+
-context string
81+
Name of the kubernetes context to use
82+
-disable-pricing
83+
Disable pricing lookups
84+
-extra-labels string
85+
A comma separated set of extra node labels to display
86+
-kubeconfig string
87+
Absolute path to the kubeconfig file (default "~/.kube/config")
88+
-node-selector string
89+
Node label selector used to filter nodes, if empty all nodes are selected
90+
-node-sort string
91+
Sort order for the nodes, either 'creation' or a label name. The sort order can be controlled by appending =asc or =dsc to the value. (default "creation")
92+
-resources string
93+
List of comma separated resources to monitor (default "cpu")
94+
-style string
95+
Three color to use for styling 'good','ok' and 'bad' values. These are also used in the gradients displayed from bad -> good. (default "#04B575,#FFFF00,#FF0000")
96+
-v Display eks-node-viewer version
97+
-version
98+
Display eks-node-viewer version
99+
```
100+
101+
### Examples
102+
103+
```bash
104+
# Standard usage
105+
eks-node-viewer
106+
# Karpenter nodes only
107+
eks-node-viewer --node-selector karpenter.sh/nodepool
108+
# Display both CPU and Memory Usage
109+
eks-node-viewer --resources cpu,memory
110+
# Display extra labels, i.e. AZ
111+
eks-node-viewer --extra-labels topology.kubernetes.io/zone
112+
# Sort by CPU usage in descending order
113+
eks-node-viewer --node-sort=eks-node-viewer/node-cpu-usage=dsc
114+
# Specify a particular AWS profile and region
115+
AWS_PROFILE=myprofile AWS_REGION=us-west-2
116+
```
117+
118+
#### Computed Labels
119+
120+
Use built‑in computed labels to display node metadata:
121+
122+
- `eks-node-viewer/node-age`
123+
- `eks-node-viewer/node-cpu-usage`
124+
- `eks-node-viewer/node-memory-usage`
125+
- `eks-node-viewer/node-pods-usage`
126+
- `eks-node-viewer/node-ephemeral-storage-usage`
127+
128+
#### Default Options
129+
130+
Create a `~/.eks-node-viewer` file to persist your preferred flags:
131+
132+
```text
133+
# select only Karpenter managed nodes
134+
node-selector=karpenter.sh/nodepool
135+
136+
# display both CPU and memory
137+
resources=cpu,memory
138+
139+
# show the zone and nodepool name by default
140+
extra-labels=topology.kubernetes.io/zone,karpenter.sh/nodepool
141+
142+
# sort so that the newest nodes are first
143+
node-sort=creation=asc
144+
145+
# change default color style
146+
style=#2E91D2,#ffff00,#D55E00
147+
```
148+
149+
---
150+
151+
## Troubleshooting
152+
153+
NoCredentialProviders: no valid providers in chain. Deprecated.
154+
This CLI relies on AWS credentials to access pricing data if you don't use the `--disable-pricing` option. You must have credentials configured via `~/aws/credentials`, `~/.aws/config`, environment variables, or some other credential provider chain.
155+
156+
---
157+
158+
## References
159+
* [GitHub - eks-node-viewer](https://github.com/awslabs/eks-node-viewer)
160+
* [Containers from the Couch: Workload Consolidation with Karpenter](https://www.youtube.com/watch?v=BnksdJ3oOEs)
161+
* [AWS re:Invent 2022 - Kubernetes virtually anywhere, for everyone](https://www.youtube.com/watch?v=OB7IZolZk78)
162+

0 commit comments

Comments
 (0)