在Kubernetes上安装Prometheus的正确方法是什么?

时间:2017-12-14 07:10:40

标签: kubernetes grafana prometheus prometheus-operator

我尝试在我的3节点kubernetes安装上安装Prometheus操作符。

# kubectl cluster-info
Client Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.3+coreos.0", GitCommit:"42de91f04e456f7625941a6c4aaedaa69708be1b", GitTreeState:"clean", BuildDate:"2017-08-07T19:44:31Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.3+coreos.0", GitCommit:"42de91f04e456f7625941a6c4aaedaa69708be1b", GitTreeState:"clean", BuildDate:"2017-08-07T19:44:31Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

# kubectl get nodes

NAME          STATUS    AGE       VERSION
master-k8s    Ready     64d       v1.7.3+coreos.0
worker1-k8s   Ready     64d       v1.7.3+coreos.0
worker2-k8s   Ready     64d       v1.7.3+coreos.0

What i did is 

# git clone https://github.com/coreos/prometheus-operator
# cd cd prometheus-operator/

changed default namespace to monitoring at bundle.yaml

# kubectl apply -f bundle.yaml -n monitoring 

然后我做了

# cd contrib/kube-prometheus
# hack/cluster-monitoring/deploy

当我看到Grafana界面时,我没有看到数据源,所以我应用了yaml文件。

# kubectl apply -f manifests/grafana/ -n monitoring


# kubectl get all -n monitoring

AME                                      READY     STATUS    RESTARTS   AGE
po/alertmanager-main-0                    2/2       Running   0          8h
po/alertmanager-main-1                    2/2       Running   0          8h
po/alertmanager-main-2                    2/2       Running   0          8h
po/grafana-3524315691-86bv9               2/2       Running   49         8h
po/kube-state-metrics-1058475279-p9r7b    2/2       Running   0          8h
po/node-exporter-cpz70                    1/1       Running   0          8h
po/node-exporter-kt8nx                    1/1       Running   0          8h
po/node-exporter-zbj86                    1/1       Running   0          8h
po/prometheus-k8s-0                       2/2       Running   0          8h
po/prometheus-k8s-1                       2/2       Running   0          8h
po/prometheus-operator-2365681585-zpkpb   1/1       Running   0          8h

NAME                        CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGE
svc/alertmanager-main       172.16.102.56    <nodes>       9093:30903/TCP      8h
svc/alertmanager-operated   None             <none>        9093/TCP,6783/TCP   8h
svc/grafana                 172.16.102.37    <nodes>       3000:30902/TCP      8h
svc/kube-state-metrics      172.16.102.174   <none>        8080/TCP            8h
svc/node-exporter           None             <none>        9100/TCP            8h
svc/prometheus-k8s          172.16.102.52    <nodes>       9090:30900/TCP      8h
svc/prometheus-operated     None             <none>        9090/TCP            8h
svc/prometheus-operator     172.16.102.207   <none>        8080/TCP            8h

NAME                             DESIRED   CURRENT   AGE
statefulsets/alertmanager-main   3         3         8h
statefulsets/prometheus-k8s      2         2         8h

NAME                         DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deploy/grafana               1         1         1            1           8h
deploy/kube-state-metrics    1         1         1            1           8h
deploy/prometheus-operator   1         1         1            1           8h

NAME                                DESIRED   CURRENT   READY     AGE
rs/grafana-3524315691               1         1         1         8h
rs/kube-state-metrics-1058475279    1         1         1         8h
rs/kube-state-metrics-3281504101    0         0         0         8h
rs/prometheus-operator-2365681585   1         1         1         8h

此时正在查看prometheus数据源,但没有仪表板可用。

似乎缺少某些东西。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我最近写了一篇tutorial让Prometheus运营商与Envoy合作。我遇到的最棘手的问题是调试运营商的RBAC问题。除了查看您的日志之外,我还要查看您的广告连播上的事件(kubectl describe pod grafana-3524315691-86bv9)。