Deploying a robust Kubernetes cluster monitoring solution(node-exporter,prometheus & grafana) with Helm
Published: 2023-09-11 06:26:07



### Introduction

Monitoring your AWS Elastic Kubernetes Service (EKS) cluster is crucial for ensuring its health and performance. In this tutorial, I'll walk you through the process of deploying a robust monitoring solution using Helm, Prometheus, Node Exporter, and Grafana.

**Article by Noble Mutuwa Mulaudzi**

### Architecture Diagram

![Architecture Diagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/382zbkv7j8x9wk6kiqqe.png)

### Prerequisites

Before you begin, make sure you have the following prerequisites in place:

- An AWS EKS cluster up and running.
- `kubectl` installed and configured to connect to your EKS cluster.
- Helm installed on your local machine.
- Basic knowledge of Kubernetes concepts.
- eksctl installed on your local machine

#### Setting Up the Cluster

If you don't have an EKS cluster, follow these steps to configure your cluster:

**source code** : [Noble Mutuwa K8s monitoring files](https://github.com/Mutuwa99/EFK_monitoring).

1. Clone the repo and navigate to the application's folder

2. Apply the `cluster.yaml`, `deployment.yaml`, and `service.yaml` files:

```bash
eksctl create cluster -f cluster.yaml
kubectl apply -f deployment.yaml
kubectl apply -f deployment.yaml
```

> Retrieve the service and access your application via the load balancer:

```bash
kubectl get svc
```
Here is our application running on an EKS cluster

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lng3qb3eh4urbmf5xl1f.png)

### Setting Up Prometheus, Node Exporter, and Grafana

To set up Prometheus, Grafana, and Node Exporter as a monitoring stack for your Kubernetes cluster, you can use Helm to simplify the deployment process. Here are the steps to install the Prometheus stack on your Kubernetes cluster using Helm:

**1. Install Helm (if not already installed):**

If you haven't already installed Helm on your Windows machine using Chocolatey or any other method, please follow the instructions provided earlier.

**2. Add Helm Chart Repositories:**

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

**3. Create a Namespace for Monitoring (Optional):**

```bash
kubectl create namespace monitoring
```

**4. Install Prometheus using Helm:**

```bash
helm install prometheus-stack prometheus-community/kube-prometheus-stack -n monitoring
```

### Exposing Prometheus and Grafana Services

To access Prometheus and Grafana, edit the services within the monitoring namespace, and change the service type to LoadBalancer:

![LoadBalancer Services](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r8mr8x5ho0nbiw5xzjmh.png)

### Accessing Grafana

- Copy the LoadBalancer URL of the Grafana service and paste it into your web browser.

- Use the following credentials to log in:
  - Username: admin
  - Password: prom-operator

### Set Up Data Sources and Dashboards in Grafana

Configure data sources and import dashboards in Grafana to start visualizing your Kubernetes cluster metrics. You can find various Kubernetes-related dashboards in the Grafana dashboard marketplace.

Here's a dashboard I've configured to monitor my cluster's health:

![Cluster Health Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t0eyzy3ml1j0pcaaaauh.png)

Congratulations! You've successfully deployed a robust monitoring solution for your AWS EKS cluster. With Prometheus, Node Exporter, and Grafana in place, you can monitor and visualize metrics, helping you keep your Kubernetes environment healthy and efficient.

**Article by Noble Mutuwa Mulaudzi**

**Thank you!**