Integrating Prometheus and Grafana on top of Kubernetes

Integrating Prometheus and Grafana on top of Kubernetes

Problem Statement -

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

Solution-

Step 1: -

Before getting started , We need to create a Dockerfile of Prometheus and Grafana and upload it into the DockerHub which is further used when we launch the pods on Kubernetes.

docker build -t akansh028/prometheus:v1 /root/task5/prom/

docker push akansh028/prometheus:v1

No alt text provided for this image
docker build -t akansh028/grafana:v1 /root/task5/graf/

docker push akansh028/grafana:v1

No alt text provided for this image

After pushing the respected images , we can see in the docker hub as follows -

No alt text provided for this image

Step 2:-

After creating a Dockerfile , we need to create a persistent volume (PV) and the persistent volume claim (PVC) for the respected images of prometheus and grafana using the yml files.

kubectl create -f pv_prom.yml

kubectl create -f pvc_prom.yml

No alt text provided for this image
kubectl create -f pv_graf.yml


kubectl create -f pvc_graf.yml

No alt text provided for this image

Step 3 :-

After creating the pv and the pvc , this is the time for the deployment which creates the respected k8s pods for the images of the prometheus and grafana . And after creating the pods we need to expose each pods.

kubectl create -f deploy_prom.yml

kubectl expose deploy/deploy-prom --port=9090 --type=NodePort

kubectl get deploy

No alt text provided for this image
kubectl create -f deploy_graf.yml

kubectl expose deploy/deploy-graf --port=9090 --type=NodePort

kubectl get deploy
No alt text provided for this image

Step 4 :-

We need to get the service and open the respective dashboards of the prometheus and grafana.

minikube service list

minikube service deploy-prom

minikube service deploy-graf

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

And hence , our prometheus and grafana data becomes persistent .

Thank you



要查看或添加评论,请登录

Akansh Agarwal的更多文章

社区洞察

其他会员也浏览了