Skip to content

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
The server is then installed but not exposed. To exposse Prometheus server outside the kubernetes cluster:

  1. copy the configuration of the Prometheus server service into a new yaml configuration file

    kubectl get service prometheus-server -o yaml > prometheus-server-ext.yaml
    

  2. Modify the following fields in prometheus-server-ext.yaml:

    • change metadata.name into prometheus-server-ext to avoid conflict;
    • change spec.type in NodePort to expose to external;
    • under spec.ports add the field nodePort: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.
  3. and, finally, apply the new configuration.

    kubectl apply -f prometheus-server-ext.yaml
    

On Minikube

Access the Prometheus Service Using Minikube:

minikube service prometheus-server-ext --profile igwn-kube

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
The server is then installed but not exposed. To exposse Grafana server outside the kubernetes cluster

  1. copy the configuration of the Grafana server service into a new yaml configuration file

    kubectl get service grafana -o yaml > grafana-ext.yaml
    

  2. Modify the following fields in grafana-ext.yaml:

    • change metadata.name into Grafana-server-ext to avoid conflict;
    • change spec.type in NodePort to expose to external;
    • under spec.ports add the field nodePort: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.
  3. and, finally, apply the new configuration.

    kubectl apply -f grafana-ext.yaml
    

On Minikube

Access the Grafana Service Using Minikube:

minikube service grafana-ext --profile igwn-kube

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
using kubectl get pvc check if there are some orphan volume and delete it with kubectl delete pvc <volume-name> -n <namespace>.