Today I deploy a full monitoring stack in my Scaleway managed Kubernetes Kaspule cluster.
What do I want to achieve?
There is not much currently deployed in my Kapsule cluster. Apart from the standard stuff, I have this blog and a Gitea instance. Before deploying other applications to continue enhance this stack, I need to gain some visibility on the metrics of the Kapsule cluster. I decided to play safe and use the de-facto standard kube-prometheus-stack
Helm chart to deploy the following components :
- Prometheus
- AlertManager with predefined rules
- Grafana with predefined dashboards
- kube-state-metrics
- Prometheus Operator
- Prometheus Node Exporter
- Prometheus Adapter for Kubernetes Metrics APIs : purpose of this adapter is to expose metrics collected by Prometheus to Kubernetes so that these metrics can then be used for auto-scaling of pods for example.
There are some documentation available on Scaleway’s web site but it is unfortunately a bit outdated at the time of writing this post (04/2021) and I decided to document it in this blog.
Prerequisites
- a Kapsule cluster
- Helm v3 installed on your workstation
Deployment
The deployment is very straigthforward. There is one thing you need to take care of : persistance of data. If you do not customize the Helm chart with some values, the data of your Prometheus / AlertManager instances won’t survive a pod restart!
Remark: in this Helm chart, there is apparently (I have not found it) no option to enable data persistance for the Grafana deployment.
First get the repo where the Helm charts are located available to your Helm install.
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
To enable data persistance, create a file prometheus-values.yaml
with the following content:
alertmanager:
alertmanagerSpec:
storage:
volumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 10Gi
prometheus:
prometheusSpec:
storageSpec:
volumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 10Gi
Create the monitoring
namespace where we will deploy all resources specified in the Helm chart.
kubectl create namespace monitoring
Deploy the Helm chart
helm upgrade --namespace monitoring --install -f prometheus-values.yaml prometheus prometheus-community/kube-prometheus-stack
After a minute or 2, all pods are deployed.
You can access your Grafana instance by creating a port-forward
.
kubectl port-forward -n monitoring <name of your grafana pod> 3000
Open your web browser and browse to http://localhost:3000
Have a look at the cool dashboards available to monitor your Kapsule cluster.
Conclusion
The setup is a little bit different than what is described in the Scaleway documentation because I chose to deploy the kube-prometheus-stack
with the Prometheus Operator that helps the management of Prometheus, AlertManager instances, discovery of service to monitor and even monitoring and alert rukes.
In a future article, I will explain how to configure the monitoring of my Gitea and Postgres instances.
Stay tuned !