Prometheus-Grafana on K8s

Shrut Shah
3 min readJun 20, 2020

--

Integrate Prometheus and Grafana and perform in following way:

1. Deploy them as pods on top of Kubernetes by creating resources Deployment, ReplicaSet, Pods or Services

2. And make their data to be remain persistent

3. And both of them should be exposed to outside world

Step 1

Dockerfile for Prometheus:

To build the image for launch of the container command is :

docker build -t shrutshah/prometheus:v1

For storing metrics data , prom_data folder is created.

Step 2

Persistent Volume (PV) is created to make the data generated and stored by prometheus persistent or permanent.

Step 3

Create Persistent Volume Claim(PVC)

Step 4

Deployment

Step 5

EXPOSE the deployment

Step 6

Dockerfile for Grafana

Step 6

Persistent Volume(PV) for grafana.

Step 7

Persistent Volume Claim(PVC) for grafana.

like Prometheus in Grafana we make /mnt/sda1/data/grafana folder persistent or permanent.

Step 8

Deployment for grafana

Step 9

EXPOSE deployment for external world to use.

Step 10

ask minikube for IP

Step 11

Use this IP with Port exposed for Prometheus and Grafana both.

192.168.99.100:30086

192.168.99.100:30246

Now if the pods get crashed then also the data is preserved and hence our objective is completed.

--

--