https://akomljen.com/get-kubernetes-cluster-metrics-with-prometheus-in-5-minutes/ https://github.com/kubernetes/ingress-nginx/tree/f56e839134fd4a1d020c3e95d4fe89496225041c/deploy/grafana/dashboards https://github.com/kubernetes/ingress-nginx/tree/f56e839134fd4a1d020c3e95d4fe89496225041c/deploy/monitoring
在ingress-nginx官網deploy/monitoring目錄下載相關yaml文件nginx
[root@elasticsearch01 monitoring]# pwd /k8s/yaml/ingress-nginx/monitoring [root@elasticsearch01 monitoring]# ls configuration.yaml grafana.yaml prometheus.yaml
使用kubectl部署prometheus和grafana容器podgit
[root@elasticsearch01 monitoring]# kubectl create -f ./ configmap/prometheus-configuration created deployment.extensions/grafana created service/grafana created role.rbac.authorization.k8s.io/prometheus-server created serviceaccount/prometheus-server created rolebinding.rbac.authorization.k8s.io/prometheus-server created deployment.apps/prometheus-server created service/prometheus-server created
查看對外暴露端口,服務以NoderPort方式對外提供服務
prometheus訪問地址爲:http://10.2.8.65:37941
grafana訪問地址爲:http://10.2.8.34:32358
以上服務也能夠部署ingress服務,經過域名訪問github
[root@elasticsearch01 monitoring]# kubectl get pods,svc -n ingress-nginx -o wide|egrep "grafana|prome" pod/grafana-69549786b6-69sqm 1/1 Running 0 14m 10.254.73.6 10.2.8.34 <none> <none> pod/prometheus-server-8658d8cdbb-8kf2g 1/1 Running 0 14m 10.254.35.7 10.2.8.65 <none> <none> service/grafana NodePort 10.254.108.105 <none> 3000:32358/TCP 14m app.kubernetes.io/name=grafana,app.kubernetes.io/part-of=ingress-nginx service/prometheus-server NodePort 10.254.155.29 <none> 9090:37941/TCP 14m app.kubernetes.io/name=prometheus,app.kubernetes.io/part-of=ingress-nginx
在ingress-nginx官網deploy/grafana/dashboards目錄下載相關nginx.json文件json
配置prometheus數據源app
導入dashboardelasticsearch
最終展現效果以下ide