Setup Prometheus Node Exporter on Kubernetes
Last Updated :
26 Aug, 2024
In monitoring has always been an essential layer of any powerful cloud-native architecture, and Kubernetes is not an exception. One of the most frequently used and mentioned open-source monitoring tools is Prometheus which is usually used in conjunction with Grafana for metrics visualization. of all exporters that are used with Prometheus, the Node Exporter is a must-have in your tool belt to collect hardware and OS-level metrics from your node. It will expose the steps for installing the Prometheus Node Exporter in the Kubernetes environment.
Setup Prometheus Node Exporter on Kubernetes Primary Terminologies
- Kubernetes Cluster: A set of Machines where container-based applications operate, all orchestrated by Kubernetes. It also supports the deployment, scaling, and usage of application containers.
- Helm: A package manager for shipping that makes installation and management of applications easier. Increases the speed at which application or software can be shipped. It employs what are called charts, which are predefined Kubernetes objects, for the deployment and running of applications.
- Daemon Set: A Kubernetes object that oversees whether a specific pod is run on all the nodes in a cluster or some. Usually, this is done for system-level services like log collectors, monitoring agents, or in this case node exporters.
- Node Exporter: A Prometheus exporter which this particular node level Prometheus exporter aims at as per its implementation to obtain information on the hardware and the operating system physical layer in the forms of CPU, memory and disk usage, and networks.
- Prometheus: This is an open-source tool, which monitors an alert toolkit designed to collect metrics at a fixed interval of a set of values, evaluate rule specifications, and alert when the condition meets them.
- Service Monitor: An object in the Kubernetes environment that defines how Prometheus should scrape a service. It provides the targets, which are the endpoints to scrape, and other configurations which are things like relabeling or validation
- Grafana: In data management and management tool that integrates with Prometheus (among other data sources) to create and display dashboards. It is widely used to monitor the health and performance of applications and infrastructure.
What is Node Exporter?
The Prometheus Exporter is a small application that can take monitoring metrics from the target system and display those metrics via a web URL that allows the Prometheus server to scrape those metrics.
In the node exporter exports hardware and OS metrics to the *NIX kernel. By default, Kubernetes does not publish monitoring metrics at the node level. To back up, to track metrics for a Kubernetes node, we need the Prometheus node exporter running on all nodes. It can collect all system monitoring metrics and display them using the /metrics web path on port 9100. It must be used as a daemon set in order for Kubernetes to run on every cluster node.
Step 1: Deploying Node Exporter on a Kubernetes Cluster
1. Connect to a GKE cluster.
gcloud container clusters get-credentials demo-k8s-cluster
2. Copy the following information to the file node-exporter. yaml. Here we are using a monitoring namespace that was already created when the Prometheus Server was deployed.
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
app: node-exporter
name: node-exporter
namespace: monitoring
spec:
selector:
matchLabels:
app: node-exporter
template:
metadata:
labels:
app: node-exporter
spec:
containers:
- args:
- --path.sysfs=/host/sys
- --path.rootfs=/host/root
- --no-collector.wifi
- --no-collector.hwmon
- --collector.filesystem.ignored-mount-points=^/(dev|proc|sys|var/lib/docker/.+|var/lib/kubelet/pods/.+)($|/)
- --collector.netclass.ignored-devices=^(veth.*)$
name: node-exporter
image: prom/node-exporter
ports:
- containerPort: 9100
protocol: TCP
resources:
limits:
cpu: 250m
memory: 180Mi
requests:
cpu: 102m
memory: 180Mi
volumeMounts:
- mountPath: /host/sys
mountPropagation: HostToContainer
name: sys
readOnly: true
- mountPath: /host/root
mountPropagation: HostToContainer
name: root
readOnly: true
volumes:
- hostPath:
path: /sys
name: sys
- hostPath:
path: /
name: root
3. Deploy the daemonset using a “kubctl apply” command.
kubectl apply -f node-exporter.yaml
4. List a daemonsets that make up search namespace and verify that their status is Running. Everyone should have a daemon configured for each node. In this demo we have only one node so only one daemonset is running.
5. Now we are going to use Kubernetes service for the node-exporter daemon sets. Copy following yaml entries to the file node-exporter-service.yaml.
6. Create node-exporter service with below command.
kubectl create -f node-exporter-service.yml
7. List a services for the node-exporter service.
8. Now we need to ensure that the node exporter scrape settings are added to Prometheus server config file. We have already added this when running the Prometheus server in a previous post. Add the following settings under the scrape_configs sections, if they are not already added.
9. Connect to a Prometheus console using the kubectl port-forwarding, see below.
from a browser you can be access Prometheus console by using url: http://localhost:8080
Step 2: node-exporter target
1.See targets section screen shot below for node-exporter target.
2. You can be query node exporter metrics from the Prometheus search console using the “node_” prefix.
Conclusion
In these steps, you have been successfully deployed Prometheus Node Exporter to your Kubernetes cluster. This is configuration allows to Prometheus to scrape valuable node-level metrics, which can be made visible in Grafana or managed directly in Prometheus. This is important step in how to build robust observability stack for your Kubernetes environment.
Similar Reads
Kubernetes Prometheus
With modern DevOps becoming more and more complex, monitoring and alerting stakeholders has become even more crucial for any microservice, and Prometheus is a tool to do the same. Prometheus is a completely open-sourced tool created to monitor highly dynamic container environments like Kubernetes, D
13 min read
Setup Latest Nexus OSS On Kubernetes
Nexus OSS is a popular repository manager that helps you manage your binaries and build artifacts efficiently. Deploying Nexus OSS on Kubernetes allows you to leverage Kubernetes' orchestration capabilities for better scalability and management. Hereâs a clear, step-by-step guide to setting up the l
5 min read
Kubernetes Node Vs. Pod Vs. Cluster: Whatâs The Difference?
Kubernetes automates most container management operations, allowing developers to operate high-performance, modern apps at scale. This includes built-in commands that handle most of the heavy lifting involved in application administration, allowing you to automate day-to-day tasks. Several component
7 min read
Monitoring Kubernetes Clusters with Prometheus and Grafana
In modern era of containers, Kubernetes has emerged as a leading band. like any robust system, effective assessment is critical to ensuring it works, reliably and is scalable. Prometheus and Grafana, two powerful tools, combine to provide robust solution for managing a Kubernetes clusters. This arti
8 min read
Kubernetes - NodePort Service
NodePort service in Kubernetes is a service that is used to expose the application to the internet from where the end-users can access it. If you create a NodePort Service Kubernetes will assign the port within the range of (30000-32767). The application can be accessed by end-users using the node's
5 min read
How To Use Kubernetes Network Policies?
Kubernetes is the kind of container-centric management software used for the deployment and operation of cont energized applications. It was originally developed by google clouds. It improves your reliability and reduces the time, workload and provides developers resources attributes to daily operat
5 min read
The Role of Kubernetes Cloud Controller Manager
Container orchestration is currently established to be well recognized and has emerged as one of the fundamental uses of Kubernetes for carrying out clusters in the cloud. The Kubernetes Cloud Controller Manager (CCM) is a sub-component of Kubernetes and contributes to making contact with cloud prov
10 min read
How to Add Roles to Nodes in Kubernetes?
Kubernetes (or k8) is an open-source container orchestration platform that helps in managing various containers. Its architecture consists of nodes that represent worker machines and the containers run inside those machines. The machines, or nodes, may require some roles attached to them as well in
2 min read
How To Troubleshoot Kubernetes Pods ?
Kubernetes (K8s) installations frequently present issues from multiple perspectives, including pods, services, ingress, non-responsive clusters, control planes, and high-availability configurations. Kubernetes pods are the smallest deployable units in the Kubernetes ecosystem, each containing one or
7 min read
How to Manage Kubernetes Secrets ?
Most applications deployed through Kubernetes require access to databases, services, and other resources located externally. The easiest way to manage the login information necessary to access those resources is by using Kubernetes secrets. Secrets help organize and distribute sensitive information
12 min read