Kubernetes : Deploy Prometheus2026/05/15 |
|
Deploy Prometheus to monitor metrics in Kubernetes Cluster. This example is based on the environment like follows.
+----------------------+ +----------------------+
| [ ctrl.srv.world ] | | [ dlp.srv.world ] |
| Manager Node | | Control Plane |
+-----------+----------+ +-----------+----------+
eth0|10.0.0.25 eth0|10.0.0.30
| |
------------+--------------------------+-----------
| |
eth0|10.0.0.51 eth0|10.0.0.52
+-----------+----------+ +-----------+----------+
| [ node01.srv.world ] | | [ node02.srv.world ] |
| Worker Node#1 | | Worker Node#2 |
+----------------------+ +----------------------+
|
| [1] |
On this example, configure [nfs.srv.world:/home/nfsshare] directory on NFS server
as external storage, |
| [2] | Install Prometheus chart with Helm. |
|
ubuntu@ctrl:~$
helm repo add prometheus https://prometheus-community.github.io/helm-charts "prometheus" has been added to your repositories # create a namespace for Prometheus ubuntu@ctrl:~$ kubectl create namespace monitoring namespace/monitoring created kubectl get storageclass NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE nfs-client cluster.local/nfs-client-nfs-subdir-external-provisioner Delete Immediate true 4m57s
ubuntu@ctrl:~$ helm install prometheus \
-n monitoring prometheus/kube-prometheus-stack \
--set prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.spec.storageClassName="nfs-client" \
--set prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.spec.resources.requests.storage=10Gi \
--set grafana.persistence.enabled=true \
--set grafana.persistence.storageClassName="nfs-client" \
--set grafana.persistence.size=10Gi
NAME: prometheus
LAST DEPLOYED: Fri May 15 00:40:18 2026
NAMESPACE: monitoring
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
kube-prometheus-stack has been installed. Check its status by running:
kubectl --namespace monitoring get pods -l "release=prometheus"
Get Grafana 'admin' user password by running:
kubectl --namespace monitoring get secrets prometheus-grafana -o jsonpath="{.data.admin-password}" | base64 -d ; echo
Access Grafana local instance:
export POD_NAME=$(kubectl --namespace monitoring get pod -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=prometheus" -oname)
kubectl --namespace monitoring port-forward $POD_NAME 3000
Get your grafana admin user password by running:
kubectl get secret --namespace monitoring -l app.kubernetes.io/component=admin-secret -o jsonpath="{.items[0].data.admin-password}" | base64 --decode ; echo
Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator.
ubuntu@ctrl:~$ kubectl get pods -n monitoring NAME READY STATUS RESTARTS AGE alertmanager-prometheus-kube-prometheus-alertmanager-0 2/2 Running 0 48s prometheus-grafana-c65cfd88b-jmj4q 2/3 Running 0 56s prometheus-kube-prometheus-operator-5fc897b57f-rztfw 1/1 Running 0 56s prometheus-kube-state-metrics-5d4654dd56-8svqz 1/1 Running 0 56s prometheus-prometheus-kube-prometheus-prometheus-0 2/2 Running 0 48s prometheus-prometheus-node-exporter-957xk 1/1 Running 0 56s prometheus-prometheus-node-exporter-px67r 1/1 Running 0 56s prometheus-prometheus-node-exporter-vss97 1/1 Running 0 56s # show admin password for Grafana ubuntu@ctrl:~$ echo "Password: $(kubectl get secret --namespace monitoring -l app.kubernetes.io/component=admin-secret -o jsonpath="{.items[0].data.admin-password}" | base64 -d)" Password: PlNdpFJpvTLjDLaaxmWJYOepfQbDWVosQYnD7SqS # if access from outside of cluster, set port-forwarding ubuntu@ctrl:~$ kubectl port-forward -n monitoring service/prometheus-kube-prometheus-prometheus --address 0.0.0.0 9090:9090 & ubuntu@ctrl:~$ kubectl port-forward -n monitoring service/prometheus-grafana --address 0.0.0.0 3000:80 &
|
| [3] |
If you set port-forwarding, access to the Prometheus URL below on a client computer in your local network. ⇒ http://(Manager Node Hostname or IP address):(setting port)/ That's OK if following Prometheus UI is displayed. |
|
|
| [4] |
For Grafana, access the following URL. ⇒ http://(Manager Node Hostname or IP address):(setting port)/ That's OK if following Grafana UI is displayed. |
|
|
|
|
| Sponsored Link |
|
|