You can proactive manage Kubernetes clusters and identify issues with Kubernetes monitoring. By monitoring uptime, utilization of cluster resources (such as memory, CPU, and storage), and interaction between cluster components, effective Kubernetes cluster monitoring makes managing your containerized infrastructure simpler.
In Kubernetes, bunch administrators screen the group and caution you on the off chance that the necessary number of cases is running, on the off chance that asset usage is approaching a basic cutoff, or on the other hand assuming that there is a disappointment or design blunder that keeps a unit or hub from joining the bunch. In addition to the built-in monitoring features, numerous businesses make use of cloud-native monitoring tools to fully monitor cluster activity.
What is Prometheus ?
Prometheus is a free software tool for alerting and monitoring events. With flexible queries and real-time alerting, it stores metrics in real time in a time series database built with an HTTP pull model.
What is Grafana ?
Grafana is a web application that combines interactive visualization with analytics and runs on a variety of platforms. When connected to supported data sources, it provides web-based charts, graphs, and alerts.
Prerequisites
We have have following access and service to use this monitoring process.
- Up and running K8s cluster
- Shell access on K8s nodes
- Helm package manager be installed
Click here to get installation process of HELM on k8s.
Step 1: Add the Helm Stable Charts
We need to add the Helm Stable Charts. Use the following command:
helm repo add stable https://charts.helm.sh/stable
Step 2: Add Prometheus Helm Repository
We need to use the Prometheus helm repository by using the following command.
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
Step 3: Install kube-prometheus-stack
We need to install prometheus-community/kube-prometheus-stack
which is comes with Grafana s well, We need to execute the following command for the same.
helm install stable prometheus-community/kube-prometheus-stack
Step 4: Verify the Prometheus-stack Pods
We need to execute the given command to check and validate the all the prometheus-stack pods are up and running, To do that.
kubectl get pods
Step 5: Check Service Status
We also need to verify Prometheus-stack’s service are successfully deployed, We need to use the following command.
kubectl get svc
By using Helm command we have installed successfully Grafana and Prometheus-stack for k8s monitoring.
Step 6: Get Grafana Access
To access Grafana from outside the private network, We need to expose the stable-grafana service by changing the ClusterIP to LoadBalancer in stable-grafana
service, Use the following command for the same.
kubectl edit svc stable-grafana
Step 7: Get Public-Endpoint for Grafana
We need to execute again kubectl get svc
to get external IP to get open Grafana portal from public network.
kubectl get svc
Step 8: Open Grafana Portal
In helm prometheus-stack, we need to use the following credentials to access the Grafana dashboard, and then we need to update the default password. We are ready to open the Grafana portal by using the external IP / DNS end-points.
To access the Grafana portal, please use the credentials listed below.
Username | admin |
Password | prom-operator |
Step 9: Import Kubernetes Grafana Dashboard
We have already pre-defined Grafana dashboard ID to import in Grafana by using the given IDs.
Type of Kubernetes dashboard | ID |
1. Create Kubernetes Monitoring Dashboard | 12740 |
2. Create Kubernetes Cluster Monitoring Dashboard | 3119 |
3. Create POD Monitoring Dashboard | 6417 |
Conclusion
We have successfully enabled the k8s monitoring tools using Prometheus-stack, if you still have questions, please post them in the comments section below.