How to install prometheus node exporter on both master and worker nodes

Today I’m working for one of the clients. they are running kubernetes on premise and they want to setup node exporter on both master and worker nodes.

The installation is exactly the same on both master node and worker node.

Firstly, you need to create a user called prometheus, and download the node exporter

adduser prometheus
cd /home/prometheus
curl -LO "https://github.com/prometheus/node_exporter/releases/download/v1.0.0-rc.0/node_exporter-1.0.0-rc.0.linux-amd64.tar.gz"
tar -xvzf node_exporter-1.0.0-rc.0.linux-amd64.tar.gz
mv node_exporter-1.0.0-rc.0.linux-amd64 node_exporter
cd node_exporter
chown prometheus:prometheus node_exporter

Configure the node exporter service

vi /etc/systemd/system/node_exporter.service

[Unit]
Description=Node Exporter

[Service]
User=prometheus
ExecStart=/home/prometheus/node_exporter/node_exporter

[Install]
WantedBy=default.target

Reload daemon and enable start node exporter service

systemctl daemon-reload systemctl enable node_exporter.service systemctl start node_exporter.service