在安装完Dashboard之后一个完美的云原生监控方案Prometheus加上Grafana。
Installs the kube-prometheus stack, a collection of Kubernetes manifests, Grafana dashboards, and Prometheus rules combined with documentation and scripts to provide easy to operate end-to-end Kubernetes cluster monitoring with Prometheus using the Prometheus Operator.
obviously to save some energy, we choose to use helm to install Promethues.
1.Get Helm Repository Info
1 2
| helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update
|
After that we will use helm to install it, but before this i’d like to create a namespace for it.(otherwise it will use the default namespace).
1
| kubectl create namespace monitoring
|
let’s install it.
1
| helm install prometheus-stack --namespace=monitoring prometheus-community/kube-prometheus-stack
|
Unistall cmd
1
| helm uninstall --namespace=monitoring prometheus-stack
|
By default this chart installs additional, dependent charts:
2.Check installation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| $ sudo kubectl get pod -n monitoring -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES alertmanager-prometheus-stack-kube-prom-alertmanager-0 2/2 Running 0 24m 10.42.0.15 rasp1 <none> <none> prometheus-prometheus-stack-kube-prom-prometheus-0 2/2 Running 0 24m 10.42.2.9 rasp3 <none> <none> prometheus-stack-grafana-85bd7bb576-wpnnb 3/3 Running 0 25m 10.42.1.6 rasp2 <none> <none> prometheus-stack-kube-prom-operator-6757bfd48f-v5f2v 1/1 Running 0 25m 10.42.2.7 rasp3 <none> <none> prometheus-stack-kube-state-metrics-78599cd9d4-758ww 1/1 Running 0 25m 10.42.0.14 rasp1 <none> <none> prometheus-stack-prometheus-node-exporter-29bpf 1/1 Running 0 25m 192.168.10.141 rasp2 <none> <none> prometheus-stack-prometheus-node-exporter-5kmkj 1/1 Running 0 25m 192.168.10.102 rasp1 <none> <none> prometheus-stack-prometheus-node-exporter-798l5 1/1 Running 0 25m 192.168.10.192 rasp3 <none> <none>
$ sudo kubectl get service --namespace=monitoring -o wide NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR alertmanager-operated ClusterIP None <none> 9093/TCP,9094/TCP,9094/UDP 6m55s app.kubernetes.io/name=alertmanager prometheus-operated ClusterIP None <none> 9090/TCP 6m55s app.kubernetes.io/name=prometheus prometheus-stack-grafana ClusterIP 10.43.26.9 <none> 80/TCP 7m9s app.kubernetes.io/instance=prometheus-stack,app.kubernetes.io/name=grafana prometheus-stack-kube-prom-alertmanager ClusterIP 10.43.223.165 <none> 9093/TCP,8080/TCP 7m9s alertmanager=prometheus-stack-kube-prom-alertmanager,app.kubernetes.io/name=alertmanager prometheus-stack-kube-prom-operator ClusterIP 10.43.7.113 <none> 443/TCP 7m9s app=kube-prometheus-stack-operator,release=prometheus-stack prometheus-stack-kube-prom-prometheus ClusterIP 10.43.69.81 <none> 9090/TCP,8080/TCP 7m9s app.kubernetes.io/name=prometheus,operator.prometheus.io/name=prometheus-stack-kube-prom-prometheus prometheus-stack-kube-state-metrics ClusterIP 10.43.2.91 <none> 8080/TCP 7m9s app.kubernetes.io/instance=prometheus-stack,app.kubernetes.io/name=kube-state-metrics prometheus-stack-prometheus-node-exporter ClusterIP 10.43.39.150 <none> 9100/TCP 7m9s app.kubernetes.io/instance=prometheus-stack,app.kubernetes.io/name=prometheus-node-exporter
|
3.How to use it.
we need to use port-forward to access the UI.
1 2 3
| sudo kubectl -n monitoring port-forward --address 0.0.0.0 svc/prometheus-stack-grafana 7443:80
sudo kubectl -n monitoring port-forward --address 0.0.0.0 svc/prometheus-stack-kube-prom-prometheus 9090:9090
|
with these two command can successfully access the web-ui.