Step-by-Step Installation and Configuration of Prometheus, Node Exporter, and Grafana on a Kubernetes Cluster
This guide walks through installing Prometheus on the master node, deploying node_exporter on both master and worker nodes, and setting up Grafana on a third node, including service files, systemd registration, and verification of monitoring endpoints within a Kubernetes environment.
1. Install and configure Prometheus on the master node (192.168.210.85)
Extract the archive and move it to /data/prometheus:
tar -zxvf prometheus-2.23.0.linux-amd64.tar.gz -C /data mv prometheus-2.23.0.linux-amd64 /data/prometheusSet ownership: chown prometheus:prometheus -R /data/prometheus Create a systemd service file ( /etc/systemd/system/prometheus.service) with the following content:
[Unit]
Description=Prometheus
After=network.target
[Service]
ExecStart=/data/prometheus/prometheus --config.file=/data/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus/data
User=prometheus
[Install]
WantedBy=multi-user.targetEnable and start the service:
systemctl enable prometheus systemctl start prometheusVerify that Prometheus is listening on port 9090:
netstat -nltp|grep prometheus2. Install node_exporter on the master and worker nodes
On the master node:
tar -zxvf node_exporter-1.0.1.linux-amd64.tar.gz -C /usr/local/ mv /usr/local/node_exporter-1.0.1.linux-amd64 /usr/local/node_exporterRun it in the background: nohup /usr/local/node_exporter/node_exporter & Repeat the same steps on k8s-node1 (192.168.210.177) (see the detailed commands in the original text).
Update prometheus.yml to scrape the new targets:
static_configs:
- targets: ['192.168.210.85:9090']
- job_name: 'k8s-node1'
- targets: ['192.168.210.177:9100']
- job_name: 'k8s-master1'
- targets: ['192.168.210.85:9100']Restart Prometheus to apply the changes: systemctl restart prometheus 3. Install and configure Grafana on node2 (192.168.210.195)
Download and extract Grafana:
wget https://dl.grafana.com/oss/release/grafana-7.3.5.linux-amd64.tar.gz tar -zxvf grafana-7.3.5.linux-amd64.tar.gzMove it to /usr/local/ and create a symlink:
mv grafana-7.3.5 /usr/local/ ln -s /usr/local/grafana-7.3.5/ /usr/local/grafanaCreate a non‑login user for Grafana and set up data directories:
useradd -s /sbin/nologin -M grafana mkdir -p /data/grafanaAdjust ownership:
chown -R grafana:grafana /usr/local/grafana chown -R grafana:grafana /data/grafanaEdit /usr/local/grafana/conf/defaults.ini (or a copy) to point to the data directories:
data = /data/grafana/data
logs = /data/grafana/log
plugins = /data/grafana/plugins
provisioning = /data/grafana/conf/provisioningCreate a systemd service file ( /etc/systemd/system/grafana-server.service) with the following content:
[Unit]
Description=Grafana
After=network.target
[Service]
User=grafana
Group=grafana
Type=notify
ExecStart=/usr/local/grafana/bin/grafana-server -homepath /usr/local/grafana
Restart=on-failure
[Install]
WantedBy=multi-user.targetStart and enable the service: systemctl start grafana-server Verify it is listening on port 3000:
netstat -nltp|grep grafanaAccess Grafana via a browser at http://192.168.210.195:3000 (default login: admin / admin).
4. Verify basic monitoring of the master and nodes
Open the Prometheus targets page ( http://192.168.210.85:9090/targets) to see the status of the master, node1, and node_exporter instances.
Similarly, view Grafana dashboards to monitor the collected metrics.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
