Install Prometheus stack with Grafana to monitor K8s Cluster and resource - Prabhueswaran/K8s GitHub Wiki

Install Prometheus-stack with Grafana to monitor K8s Cluster and resource

Install Helm to deploy the Prometheus-stack

From Apt (Debian/Ubuntu):

curl https://baltocdn.com/helm/signing.asc | sudo apt-key add -
sudo apt-get install apt-transport-https --yes
echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm

Namespace:

Create a namespace for the Monitoring Tool

kubectl create ns monitor

Verify the Namespace by:

kubectl get namespace | grep monitor

Add prometheus-community Helm Repo:

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

Update Helm Repo:

helm repo update

Install kube-prometheus-stack using Helm:

helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack --namespace monitor

Verify the service, deployment, and pods using the below command:

Service:

kubectl --namespace monitor get service

Deployment:

kubectl --namespace monitor get deployment

Pod:

kubectl --namespace monitor get pod

Configure NodePort for the below service to expose the Prometheus and Grafana Dashboards

kube-prometheus-stack-prometheus

kube-prometheus-stack-grafana

To update the Nodeport on kube-prometheus-stack-prometheus:

kubectl --namespace monitor edit service kube-prometheus-stack-prometheus

Change cluster IP into Nodeport

  type: ClusterIP
  type: NodePort

Under the ports add nodePort: 30002

ports:
  - name: web
    nodePort: 30002
    port: 9090
    protocol: TCP
    targetPort: 9090

Save and exit. The changes were updated into service.

Now Verify the Prometheus Dashboard in the browser using server IP and Nodeport:

URL: http://192.168.1.1:30002/

To update the Nodeport on kube-prometheus-stack-grafana:

kubectl --namespace monitor edit service kube-prometheus-stack-grafana

Change cluster IP into Nodeport

  type: ClusterIP
  type: NodePort

Under the ports add nodePort: 30003

ports:
  - name: web
    nodePort: 30003
    port: 9090
    protocol: TCP
    targetPort: 9090

Save and exit. The changes were updated into service.

Now Verify the Grafana Dashboard in the browser using server IP and Nodeport:

URL: http://192.168.1.1:30003/

Default Grafana Login Cerentials

USER: admin
Password: prom-operator