Ad Code

✨🎆 Codex 1.0 PLACEMENT READY PROGRAM! 🎆✨

Get 75% Discount Early bird offer CLICK to JOIN CodeX 1.0 click

DevOps Monitoring Hands-On: Prometheus & Grafana on Kubernetes Kind Cluster Using Helm by Shiva Sir

This is simplest tutorial for DEVOPS Monitoring Tools:


follow this repository of github for source code and project

 Modern applications like Netflix, Hot star, and large-scale SaaS platforms survive because of real-time monitoring and observability. Without continuous visibility into traffic, CPU usage, memory, and failures, production systems become blind.

In this hands-on guide, we implement end-to-end Kubernetes monitoring using:

  • Prometheus – metrics scraping & storage

  • Grafana – visualization & dashboards

  • Kubernetes – orchestration platform

  • Helm – package management

  • Amazon EC2 – infrastructure

  • Kind (Kubernetes in Docker) – local cluster simulation

This setup mirrors real production practices while remaining cost-effective and beginner-friendly.


Why Monitoring & Observability Matter

Monitoring answers:

  • What is happening now?

Observability answers:

  • Why is it happening?

Using Prometheus + Grafana, we monitor:

  • Node health

  • Pod & container metrics

  • CPU, memory, disk, network

  • Application load

  • Kubernetes control-plane components


Architecture Overview

High-level flow:

  1. Node Exporter (DaemonSet) runs on every node

  2. kube-state-metrics collects cluster state

  3. Prometheus scrapes metrics

  4. Grafana visualizes metrics via dashboards

  5. Helm installs everything as a unified stack


Infrastructure Setup

Step 1: Launch EC2 Instance

  • Instance type: t2.large

  • OS: Ubuntu

  • Storage: Minimum 25 GB

  • Open inbound ports:

    • 9090 – Prometheus

    • 3000 – Grafana


Prerequisites Installation

We install everything using a shell script:

Required Tools

  • Docker

  • kubectl

  • Kind

  • Helm

chmod +x install.sh ./install.sh

Verify:

docker --version kubectl version --client kind version helm version

Creating Kubernetes Cluster Using Kind

Kind Configuration

  • 1 Control Plane

  • 3 Worker Nodes

  • Port mappings enabled

kind create cluster \ --name aim-cluster \ --config kind-config.yaml

Check:

kubectl get nodes docker ps

Installing Prometheus & Grafana Using Helm

Step 1: Create Monitoring Namespace

kubectl create namespace monitor

Step 2: Add Prometheus Helm Repository

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update

Step 3: Install Monitoring Stack

helm install prometheus-stack \ prometheus-community/kube-prometheus-stack \ --namespace monitor \ --set grafana.service.type=NodePort \ --set prometheus.service.type=NodePort

What Helm Deploys Automatically

ComponentPurpose
PrometheusMetrics storage
GrafanaVisualization
AlertmanagerAlert handling
Node ExporterNode metrics
kube-state-metricsCluster state
DaemonSetsOne exporter per node
StatefulSetsAlertmanager

Accessing Grafana & Prometheus

Retrieve Grafana Password

kubectl get secret \ --namespace monitor \ prometheus-stack-grafana \ -o jsonpath="{.data.admin-password}" | base64 --decode
  • Username: admin

  • Password: (decoded value)

Port Forwarding

kubectl port-forward svc/prometheus-stack-grafana 3000:80 -n monitor kubectl port-forward svc/prometheus-stack-kube-prometheus-prometheus 9090:9090 -n monitor

Access in browser:

  • Grafana → http://EC2-IP:3000

  • Prometheus → http://EC2-IP:9090


Grafana Dashboards

Grafana automatically includes:

  • Kubernetes cluster dashboards

  • Node performance

  • Pod resource usage

  • Network traffic

  • CPU & memory trends

You can also import dashboards using Grafana Dashboard IDs (e.g., 15661).


Deploying Sample Voting Application

To demonstrate real-time application monitoring, a microservices-based Voting App is deployed:

Stack Used

  • Frontend: Python / Node.js

  • Cache: Redis

  • Database: PostgreSQL

kubectl apply -f k8s-specifications/

Services:

  • Vote (NodePort)

  • Result (NodePort)

  • Redis & DB (ClusterIP)


Observing Real-Time Load

As users vote:

  • CPU spikes visible

  • Memory usage increases

  • Network traffic grows

  • Node-level metrics change in real time

This is exactly how production monitoring works.


Key Kubernetes Concepts Demonstrated

ConceptUsage
DaemonSetNode Exporter on every node
DeploymentApplication workloads
StatefulSetAlertmanager
NodePortExternal access
ClusterIPInternal services
NamespaceIsolation (monitor)

Why Helm Is Critical in Real Projects

Without Helm:

  • Hundreds of YAML files

  • Manual updates

  • High error risk

With Helm:

  • One command deployment

  • Version control

  • Rollbacks

  • Production-grade standardization


Cleanup & Cost Control

helm uninstall prometheus-stack -n monitor kind delete cluster --name aim-cluster

Important: Terminate EC2 instance to avoid AWS charges.



Post a Comment

0 Comments