Monitoring¶
The monitoring of the cluster can be done using Prometheus for the metrics and Grafana for visualization.
Install services¶
Prometheus is an open-source systems monitoring and alerting toolkit designed for reliability and scalability. It collects and stores metrics as time series data, enabling powerful querying and visualization. Originally developed by SoundCloud, Prometheus is now a part of the Cloud Native Computing Foundation and is widely used to monitor infrastructure, applications, and containerized environments like Kubernetes.
Install Prometheus¶
Prometheus can be installed into the kubernetes cluster via
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prometheus prometheus-community/prometheus
-
copy the configuration of the Prometheus server service into a new yaml configuration file
-
Modify the following fields in
prometheus-server-ext.yaml
:- change
metadata.name
intoprometheus-server-ext
to avoid conflict; - change
spec.type
inNodePort
to expose to external; - under
spec.ports
add the fieldnodePort:30001
to specify the port used to expose the Prometheus server, if not specified the assigned port will be randomized; - remove the field
clusterIP
to allow automatic ip assignement.
- change
-
and, finally, apply the new configuration.
On Minikube
Access the Prometheus Service Using Minikube:
Now the Prometheus webinterface sould be accessible via http://<server-ip>:30001
where <server-ip>
is the ip (or hostname) for the host who is hosting the kubernetes cluster.
Install Grafana¶
Grafana can be installed into the kubernetes cluster via
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
helm install grafana grafana/grafana
-
copy the configuration of the Grafana server service into a new yaml configuration file
-
Modify the following fields in
grafana-ext.yaml
:- change
metadata.name
intoGrafana-server-ext
to avoid conflict; - change
spec.type
inNodePort
to expose to external; - under
spec.ports
add the fieldnodePort:30002
to specify the port used to expose the Grafana server, if not specified the assigned port will be randomized; - remove the field
clusterIP
to allow automatic ip assignement.
- change
-
and, finally, apply the new configuration.
On Minikube
Access the Grafana Service Using Minikube:
Now the Grafana webinterface sould be accessible via http://<server-ip>:30002
, where <server-ip>
is the ip (or hostname) for the host who is hosting the kubernetes cluster.
to get admin password see Accessing grafana credential
Clean the system¶
To clean the system it is sufficient to unistall the servers and deleting the service
helm delete grafana
helm delete prometheus
kubectl delete svc grafana-ext
kubectl delete svc prometheus-server-ext
kubectl get pvc
check if there are some orphan volume and delete it with kubectl delete pvc <volume-name> -n <namespace>
.