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.
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-systemTypical 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.yamlOutput:
daemonset.apps/node-exporter created service/node-exporter createdApply 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 createdCheck pod status again:
[root@master prometheus]# kubectl get pods -n kube-systemMost 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 createdList services in the kube-system namespace to verify exposure:
[root@master prometheus]# kubectl get svc -n kube-systemTypical 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 ---
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.