Skip to main content

Command Palette

Search for a command to run...

k8s-cost-analyzer project initial setup

Published
•2 min read•View as Markdown
H

I am Tech enthusiastic from India. Learning and sharing about DevOps journey.

Of course! Let’s start step by step like we’re building a LEGO project. 🏗️


Step 1: Understanding the Project (Simple Terms)

We are building a Kubernetes Cost Analyzer that:
✔️ Reads how much CPU, RAM, and storage your applications are using
✔️ Calculates how much money they are costing (using cloud pricing APIs)
✔️ Finds waste (for example: an app requests 4 CPUs but only uses 0.5 CPU)
✔️ Shows this data in a dashboard so DevOps teams can save money
✔️ Sends alerts if the costs are too high

👀 Imagine this like a mobile bill tracker 📊, but for cloud servers instead of mobile data.


Step 2: What We Need to Learn?

🔹 Basic Go programming (if you're not familiar, I can guide you)
🔹 Kubernetes API (client-go) to fetch pod details
🔹 PostgreSQL to store cost data
🔹 Prometheus to collect metrics
🔹 React for the dashboard (later, for visualization)

Right now, let's start with the basics in Go before jumping into Kubernetes.


Step 3: Setting Up Go on Your System

👉 First, install Go if you haven't already:

🔹 For macOS (which you're using)
Open your Warp terminal and run:

brew install go

🔹 To check if it's installed, run:

go version

It should show something like:

go version go1.21.0 darwin/arm64

Let me know if you get an error!


Step 4: Create a New Go Project

📁 Create a folder for your project:

mkdir k8s-cost-analyzer
cd k8s-cost-analyzer

Then initialize Go:

go mod init github.com/yourusername/k8s-cost-analyzer

This creates a Go module, which helps manage dependencies.


Step 5: Write Your First Go Program

Now, create a new Go file:

touch main.go

Open it in VS Code (or your preferred editor) and paste this:

package main

import "fmt"

func main() {
    fmt.Println("Hello, Kubernetes Cost Analyzer!")
}

Save it, then run:

go run main.go

You should see:

Hello, Kubernetes Cost Analyzer!

This means Go is working fine. 🎉


Step 6: Next Steps

✅ Get Go installed & set up
✅ Run the first Go program
⬜ Next, install client-go and fetch Kubernetes data

More from this blog

Untitled Publication

24 posts