Integrate Prometheus, Grafana & K8s

Problem Statement=>

Solution=>

Prometheus=>

Grafana=>

Kubernetes=>

Docker=>

we create Dockerfile of prometheus

FROM centos:8
RUN yum install wget -y
RUN wget https://github.com/prometheus/prometheus/releases/download/v2.19.0/prometheus-2.19.0.linux-amd64.tar.gz
RUN tar -xvf prometheus-2.19.0.linux-amd64.tar.gz
WORKDIR prometheus-2.19.0.linux-amd64/
EXPOSE 9090
CMD ./prometheus

Now We create a Docker file of Grafana

FROM centos:8
RUN yum install wget -y
RUN wget https://dl.grafana.com/oss/release/grafana-7.0.3.linux-amd64.tar.gz
RUN tar -zxvf grafana-7.0.3.linux-amd64.tar.gz
WORKDIR grafana-7.0.3/bin/
EXPOSE 3000
CMD ./grafana-serve
apiVersion: v1
kind: Service
metadata:
name: promo-service
labels:
env: prometheus
spec:
ports:
- port: 9090
selector:
env: prometheus
type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: prometheuspvc
labels:
env: prometheus
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: promo-deployment
labels:
env: prometheus
spec:
selector:
matchLabels:
env: prometheus
strategy:
type: Recreate
template:
metadata:
labels:
env: prometheus
spec:
containers:
- image: vimal13/prometheus:latest
name: prometheus
ports:
- containerPort: 9090
name: prometheus
volumeMounts:
- name: prometheus-mount
mountPath: /etc/prometheus/data
volumes:
- name: prometheus-mount
persistentVolumeClaim:
claimName: prometheuspvc

now promotheus run Successfully 😎😎👆👆🤘🤘

now we create one more yml file for Grafana

apiVersion: v1
kind: Service
metadata:
name: grafana-svc
labels:
env: grafana
spec:
ports:
- port: 3000
selector:
env: grafana
type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: grafana-pvc
labels:
env: grafana
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: grafana-deployment
labels:
env: grafana
spec:
selector:
matchLabels:
env: grafana
strategy:
type: Recreate
template:
metadata:
labels:
env: grafana
spec:
containers:
- image: princeprashantsaini/grafana:v1
name: grafana
ports:
- containerPort: 3000
name: grafana
volumeMounts:
- name: grafana-volume
mountPath: /var/lib/grafana
volumes:
- name: grafana-volume
persistentVolumeClaim:
claimName: grafana-pvc
now work successfully done 😎😎🤘🤘✔

Now check its volume is permanent or not for this check our PVC

🙏🙏Now all Task done Thanks for reading🙏🙏

Devops Engineer