# kubectl create ns monitoring
# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
# helm repo update
# helm install prometheus -n monitoring prometheus-community/prometheus -f prometheus.yaml
# helm upgrade prometheus -n monitoring prometheus-community/prometheus -f prometheus.yaml
server:
persistentVolume:
size: 20Gi
-
通過
kubectl port-forward --address 0.0.0.0 service/prometheus-server -n monitoring 8080:80
臨時查看prometheus中的數據 -
通過註解來監控pod/service。參考 https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus#scraping-pod-metrics-via-annotations
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: /metrics
prometheus.io/port: "8080"
# helm repo add grafana https://grafana.github.io/helm-charts
# helm repo update
# helm install grafana -n monitoring grafana/grafana -f grafana.yaml
# helm upgrade grafana -n monitoring grafana/grafana -f grafana.yaml
# 通過k8s dashboard查看admin密碼
ingress:
enabled: true
annotations:
traefik.ingress.kubernetes.io/router.tls: "true"
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.tls.certresolver: aliyun
traefik.ingress.kubernetes.io/router.tls.domains.0.main: monitoring.your_domain.com
hosts:
- monitoring.your_domain.com
persistence:
enabled: true
size: 20Gi
storageClassName: rook-cephfs
-
打開網站,添加prometheus源,爲service名稱
-
從 https://grafana.com/grafana/dashboards 找一個
ID 說明 1860 Node Exporter Full 8919 中文版Node Exporter 7636 Istio Service Dashboard 12250 Traefik 2.2需安裝 grafana-cli plugins install grafana-piechart-panel 7424 Kong (official) 4701 JVM (Micrometer) 9628 PostgreSQL Database 2842 Ceph - Cluster 5336 Ceph - OSD (Single)