3 minutes reading time
有了 Metrics Server,用户就可以访问Kubernetes 核心监控数据(core metrics)。这其中包括了 Pod、Node、容器、Service 等主要 Kubernetes 核心概念的 Metrics。
#Resource MetricsAPI: https://github.com/kubernetes/community/blob/master/contributors/design-proposals/instrumentation/resource-metrics-api.md
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
git clone https://github.com/prometheus-operator/kube-prometheus
cd kube-prometheus
kubectl create -f manifests/setup
until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done
kubectl create -f manifests/
通过 kubectl --namespace monitoring port-forward svc/prometheus-k8s 9090 就能展现prometheus ui
grafana
kubectl --namespace monitoring port-forward svc/grafana 3000
默认账户密码admin/admin,进入后会要求修改密码,可以看到已经有了预添加了数据源 可以看到有了许多K8S监控的默认看板
[1] https://time.geekbang.org/column/article/72281?utm_source=geektime&utm_medium=summary&utm_campaign=100015201&utm_content=textlink [2] https://www.cnblogs.com/CloudMan6/p/9148723.html [3] https://www.cnblogs.com/CloudMan6/p/9141757.html [4] kube-prometheus [5] https://prometheus-operator.dev/