Cloud Native 5 min read

Deploying Prometheus and Grafana on a Test Kubernetes Cluster

This guide walks through setting up a Prometheus monitoring stack and Grafana visualization on a test Kubernetes cluster, covering pod inspection, directory preparation, YAML deployments for node-exporter, RBAC, ConfigMap, Prometheus and Grafana, and final service exposure.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Deploying Prometheus and Grafana on a Test Kubernetes Cluster

This article demonstrates how to deploy a Prometheus monitoring stack and Grafana dashboard on a test Kubernetes (K8s) cluster.

First, verify the existing system pods:

[root@master ~]# kubectl get pods -n kube-system

Typical output shows core DNS, etcd, API server, controller manager, flannel, proxy, and scheduler pods all in Running state.

Create a directory for Prometheus data and switch to it:

[root@master ~]# mkdir /data/prometheus
[root@master ~]# cd /data/prometheus/

Deploy the node‑exporter daemonset and related services:

[root@master prometheus]# kubectl create -f node-exporter.yaml

Output:

daemonset.apps/node-exporter created
service/node-exporter created

Apply RBAC configuration, ConfigMap, and the Prometheus deployment and service:

[root@master prometheus]# kubectl create -f rbac-setup.yaml
clusterrole.rbac.authorization.k8s.io/prometheus created
serviceaccount/prometheus created
clusterrolebinding.rbac.authorization.k8s.io/prometheus created
[root@master prometheus]# kubectl create -f configmap.yaml
configmap/prometheus-config created
[root@master prometheus]# kubectl create -f prometheus.deploy.yml
deployment.apps/prometheus created
[root@master prometheus]# kubectl create -f prometheus.svc.yml
service/prometheus created

Check pod status again:

[root@master prometheus]# kubectl get pods -n kube-system

Most system pods remain Running , while the newly created node-exporter pods show ImagePullBackOff and the prometheus pod is in ContainerCreating state, indicating that the images are being pulled.

Deploy Grafana components:

[root@master prometheus]# kubectl create -f grafana-deploy.yaml
deployment.apps/grafana-core created
[root@master prometheus]# kubectl create -f grafana-svc.yaml
service/grafana created
[root@master prometheus]# kubectl create -f grafana-ing.yaml
ingress.extensions/grafana created

List services in the kube-system namespace to verify exposure:

[root@master prometheus]# kubectl get svc -n kube-system

Typical output shows Grafana exposed as a NodePort (port 3000), kube‑dns, node‑exporter, and Prometheus services with their respective cluster IPs and ports.

In Grafana, add a new Data Source of type Prometheus, configure the Prometheus server IP, import a ready‑made Prometheus dashboard template, and wait for metrics to appear.

After the dashboard loads, the monitoring platform is ready for use.

--- End of tutorial ---

monitoringCloud NativedeploymentKubernetesPrometheusGrafana
Practical DevOps Architecture
Written by

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.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.