Skip to content

Learn how to set up Prometheus and Grafana on Minikube for monitoring Kubernetes clusters. This beginner-friendly guide covers installation, service exposure, and dashboard visualization for real-time cluster insights. πŸš€πŸ“Š

Notifications You must be signed in to change notification settings

moshclouds/Monitoring-K8s-with-Prometheus-and-Grafana

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Monitoring Kubernetes with Prometheus and Grafana on Minikube

Image

πŸ”₯ Introduction

Kubernetes is a powerful orchestration tool, but monitoring its performance is crucial for ensuring smooth operations. This is where Prometheus and Grafana come into play. Prometheus is a leading open-source monitoring solution, while Grafana is a visualization tool that helps make sense of the collected data.

In this guide, we’ll walk through setting up Prometheus and Grafana on Minikube, a local Kubernetes cluster, to monitor and visualize cluster metrics. This tutorial is beginner-friendly and will help you get hands-on experience with Kubernetes monitoring.


βœ… Prerequisites

Before we start, ensure you have the following installed:

To verify Minikube is installed, run:

minikube version

βš™οΈ Step 1: Start Minikube

First, start your Minikube cluster:

minikube start

Check the status:

minikube status

πŸ“¦ Step 2: Create a Namespace for Monitoring

It's a good practice to keep monitoring components in a separate namespace.

kubectl create namespace monitoring

πŸ“‘ Step 3: Deploy Prometheus

1️⃣ Add the Prometheus Helm repository:

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

2️⃣ Install Prometheus:

helm install prometheus prometheus-community/prometheus -n monitoring

3️⃣ Verify the installation:

kubectl get pods -n monitoring

4️⃣ Check the running ports of the Prometheus pod:

kubectl describe pod <your-prometheus-pod-name> -n monitoring

5️⃣ Expose the Prometheus service:

kubectl expose service prometheus-server --type=NodePort --target-port=9090 --name=prometheus-server-exp -n monitoring

6️⃣ Verify the exposed service:

kubectl get svc -n monitoring

7️⃣ Access Prometheus in the browser:

minikube service prometheus-server-exp -n monitoring
Image

πŸ“Š Step 4: Deploy Grafana

1️⃣ Add the Grafana Helm repository:

helm repo add grafana https://grafana.github.io/helm-charts

2️⃣ Install Grafana:

helm install grafana grafana/grafana -n monitoring

3️⃣ Get the default Grafana admin password:

kubectl get secret --namespace monitoring grafana -o jsonpath="{.data.admin-password}"

πŸ”‘ Decode the base64-encoded password using a third-party tool or command-line utility.

Image

4️⃣ Check the running ports of the Grafana pod:

kubectl describe pod <your-grafana-pod-name> -n monitoring

5️⃣ Expose the Grafana service:

kubectl expose service grafana --type=NodePort --target-port=3000 --name=grafana-exp -n monitoring

6️⃣ Access Grafana in the browser:

minikube service grafana-exp -n monitoring
Image

πŸ› οΈ Step 5: Add Prometheus as a Data Source in Grafana

1️⃣ In Grafana, navigate to Settings β†’ Data Sources β†’ Add Data Source.

Image
2️⃣ Select **Prometheus**. Image
3️⃣ Use the following URL:
http://<your-minikube-ip>:<grafana-port-address>
Image

4️⃣ Click Save & Test to confirm the connection.

Image

πŸ“ˆ Step 6: Import Kubernetes Dashboards in Grafana

Grafana provides pre-built dashboards for Kubernetes monitoring:

1️⃣ Go to Dashboards β†’ Import.

Image

2️⃣ Enter Dashboard ID: 3662.

Image

3️⃣ Select the Prometheus data source and click Import.

Image

You should now see real-time metrics from your Minikube cluster! As shown belowπŸŽ‰

Image

🎯 Conclusion

Congratulations! You have successfully set up Prometheus and Grafana on Minikube. You can now:

  • Monitor CPU, memory, and network usage.
  • Visualize real-time metrics with Grafana dashboards.
  • Set up alerts using Alertmanager.

To further improve your monitoring setup, consider configuring Alertmanager for notifications and exploring custom dashboards.

πŸš€ Next Steps:

  • Learn more about Prometheus Query Language (PromQL).
  • Customize Grafana dashboards to fit your needs.
  • Set up monitoring for real-world Kubernetes clusters using kube-prometheus.

πŸ”— Useful Links:

About

Learn how to set up Prometheus and Grafana on Minikube for monitoring Kubernetes clusters. This beginner-friendly guide covers installation, service exposure, and dashboard visualization for real-time cluster insights. πŸš€πŸ“Š

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published