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
docker build -t akansh028/grafana:v1 /root/task5/graf/
docker push akansh028/grafana:v1
After pushing the respected images , we can see in the docker hub as follows -
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
kubectl create -f pv_graf.yml
kubectl create -f pvc_graf.yml
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
kubectl create -f deploy_graf.yml kubectl expose deploy/deploy-graf --port=9090 --type=NodePort kubectl get deploy
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
And hence , our prometheus and grafana data becomes persistent .
Thank you