搭建Kubernetes上的kube-prometheus

目标

为了监控Kubernetes集群的指标,将kube-prometheus部署到Kubernetes集群中。

给我打针前,请先消毒针头。

总结

只需按照上述Ref的自述文件进行操作。

环境

本地计算机 – 互联网 – AWS 上的 Kubernetes

部署kube-prometheus。

$ git clone https://github.com/prometheus-operator/kube-prometheus.git
$ cd kube-prometheus
$ kubectl create -f manifests/setup
$ until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done
$ kubectl create -f manifests/

设置用于访问Grafana的端口转发

$ kubectl --namespace monitoring port-forward svc/grafana 3000

设置ssh的端口转发

$ ssh -L 3000:localhost:3000 user@remote-machine

从本地机器访问Grafana的web

从本地机器访问 http://localhost:3000

设置用于访问Prometheus的端口转发。

kubectl --namespace monitoring port-forward svc/prometheus-k8s 9090

设置SSH端口转发

$ ssh -L 9090:localhost:9090 user@remote-machine

从本地计算机访问Prometheus的网络接口

使用本地机器从http://localhost:9090访问。

bannerAds