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
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 filed clusterIP
to allow automatic assignement.
kubectl get service prometheus-server -o yaml > prometheus-server-ext.yaml
vim prometheus-server-ext.yaml
kubectl apply -f prometheus-server-ext.yaml
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
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 filed clusterIP
to allow automatic assignement.
kubectl get service grafana -o yaml > grafana-ext.yaml
vim grafana-ext.yaml
kubectl apply -f grafana-ext.yaml
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.
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>
.