varie
This commit is contained in:
121
add-on/monitoring/files/README.md
Normal file
121
add-on/monitoring/files/README.md
Normal file
@@ -0,0 +1,121 @@
|
||||
# Stack di monitoring/alerting per RKE2 — CNPG come verticale iniziale
|
||||
|
||||
Stack generico, installato senza passare da Rancher Manager: kube-prometheus-stack
|
||||
(Prometheus Operator + Prometheus + Alertmanager + Grafana + node-exporter +
|
||||
kube-state-metrics) + Loki/Alloy per i log + monitoring dedicato per CloudNativePG.
|
||||
|
||||
## Ordine di installazione
|
||||
|
||||
1. **Namespace + kube-prometheus-stack**
|
||||
```bash
|
||||
kubectl create namespace monitoring
|
||||
|
||||
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
|
||||
helm repo add grafana https://grafana.github.io/helm-charts
|
||||
helm repo update
|
||||
|
||||
helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack \
|
||||
-n monitoring \
|
||||
-f 01-kube-prometheus-stack-values.yaml
|
||||
```
|
||||
|
||||
kube-prometheus-stack has been installed. Check its status by running:
|
||||
kubectl --namespace monitoring get pods -l "release=kube-prometheus-stack"
|
||||
|
||||
Get Grafana 'admin' user password by running:
|
||||
|
||||
kubectl --namespace monitoring get secrets kube-prometheus-stack-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=kube-prometheus-stack" -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.
|
||||
|
||||
kubectl run -it --rm debug --image=curlimages/curl -n monitoring --restart=Never -- curl -v http://kube-prometheus-stack-grafana.monitoring.svc.cluster.local:80/
|
||||
|
||||
|
||||
|
||||
|
||||
2. **Monitoring CNPG** (dopo che l'operatore CNPG è già installato)
|
||||
```bash
|
||||
kubectl apply -f 02-cnpg-monitoring.yaml
|
||||
```
|
||||
|
||||
3. **Alert rules** (infra + CNPG)
|
||||
```bash
|
||||
kubectl apply -f 03-alert-rules.yaml
|
||||
```
|
||||
|
||||
4. **Loki + Alloy** (log aggregation) — dividi il file in due se preferisci
|
||||
comandi helm separati (`loki-values.yaml` / `alloy-values.yaml`)
|
||||
```bash
|
||||
helm install loki grafana/loki -n monitoring -f 04-loki-alloy-values.yaml
|
||||
helm install alloy grafana/alloy -n monitoring -f 04-loki-alloy-values.yaml
|
||||
```
|
||||
|
||||
5. **Alertmanager routing** — crea prima i Secret con le credenziali reali,
|
||||
poi applica la config
|
||||
```bash
|
||||
kubectl create secret generic alertmanager-slack \
|
||||
-n monitoring --from-literal=url='<SLACK_WEBHOOK_URL>'
|
||||
kubectl create secret generic alertmanager-pagerduty \
|
||||
-n monitoring --from-literal=serviceKey='<PAGERDUTY_KEY>'
|
||||
|
||||
kubectl apply -f 05-alertmanager-config.yaml
|
||||
```
|
||||
|
||||
## Cose da personalizzare prima di applicare in un cluster reale
|
||||
|
||||
- **storageClassName** in tutti i file (`longhorn` è solo un placeholder —
|
||||
sostituisci con la storageClass effettivamente disponibile sul tuo RKE2,
|
||||
verificabile con `kubectl get storageclass`).
|
||||
- **adminPassword** di Grafana nel file 01 — spostalo in un Secret,
|
||||
non lasciarlo in chiaro nei values in produzione.
|
||||
- **Nomi metriche CNPG** — verifica che corrispondano alla versione esatta
|
||||
dell'operatore CNPG installata (vedi nota in fondo al file 03).
|
||||
- **Dashboard CNPG** — il ConfigMap nel file 02 è un placeholder; scarica
|
||||
il JSON reale da https://grafana.com/grafana/dashboards/20417 e
|
||||
sostituiscilo, oppure importa manualmente da Grafana UI (Dashboards →
|
||||
Import → ID 20417).
|
||||
- **Control-plane RKE2** (kubeEtcd/kubeControllerManager/kubeScheduler nel
|
||||
file 01) — porte ed endpoint possono variare in base a come RKE2 è
|
||||
configurato (hardening CIS, profili custom). Verifica con
|
||||
`kubectl get pods -n kube-system` quali pod statici girano e su quali
|
||||
porte, e correggi se necessario.
|
||||
- **AlertmanagerConfig selector** — deve combaciare con
|
||||
`alertmanagerConfigSelector` impostato dal chart (di default seleziona
|
||||
per label `release: <helm-release-name>`); se hai chiamato la release
|
||||
diversamente da `kube-prometheus-stack`, aggiorna la label.
|
||||
|
||||
## Verifiche post-installazione
|
||||
|
||||
```bash
|
||||
# Prometheus targets (verifica che CNPG, node-exporter, ecc. siano UP)
|
||||
kubectl port-forward -n monitoring svc/kube-prometheus-stack-prometheus 9090
|
||||
# -> http://localhost:9090/targets
|
||||
|
||||
# Grafana
|
||||
kubectl port-forward -n monitoring svc/kube-prometheus-stack-grafana 3000:80
|
||||
# -> http://localhost:3000 (utente: admin, password: quella impostata)
|
||||
|
||||
# Alertmanager
|
||||
kubectl port-forward -n monitoring svc/kube-prometheus-stack-alertmanager 9093
|
||||
# -> http://localhost:9093
|
||||
```
|
||||
|
||||
## Estensioni future (non incluse in questa prima fase)
|
||||
|
||||
- **blackbox_exporter** — probe HTTP/TCP/TLS per endpoint applicativi
|
||||
esterni e monitoraggio scadenza certificati (le regole `TLSCert*` nel
|
||||
file 03 presuppongono questo exporter già installato).
|
||||
- **Tempo + OpenTelemetry Collector** — tracing distribuito quando ci
|
||||
saranno più verticali applicative da correlare.
|
||||
- **Thanos/Mimir** — retention lunga e vista multi-cluster, se in futuro
|
||||
servirà storicizzare oltre i 15gg locali o aggregare più cluster RKE2.
|
||||
Reference in New Issue
Block a user