Kubernetes v1.9.7安装部署-Heapster监控插件

heapster release 页面下载最新版的heapster

img

$ wget https://github.com/kubernetes/heapster/archive/v1.5.3.tar.gz
tar -xzvf v1.5.3.tar.gztar−xzvfv1.5.3.tar.gz

部署相关文件目录:

ls heapster-1.5.3/deploy/kube-config ls influxdb/ && ls rbac/
grafana.yaml heapster.yaml influxdb.yaml
heapster-rbac.yaml

为方便测试访问,将grafana.yaml下面的服务类型设置为type=NodePort

img

1、执行所有文件

$ kubectl create -f rbac/heapster-rbac.yaml
clusterrolebinding "heapster" created
$ kubectl create -f influxdb
deployment "monitoring-grafana" created
service "monitoring-grafana" created
serviceaccount "heapster" created
deployment "heapster" created
service "heapster" created
deployment "monitoring-influxdb" created
service "monitoring-influxdb" created

2、检查执行结果

检查 Deployment

$ kubectl get deployments -n kube-system | grep -E 'heapster|monitoring'
heapster               1         1         1            1           2m
monitoring-grafana     1         1         1            0           2m
monitoring-influxdb    1         1         1            1           2m

3、检查 Pods

$ kubectl get pods -n kube-system | grep -E 'heapster|monitoring'
heapster-7cf895f48f-p98tk              1/1       Running            0          2m
monitoring-grafana-c9d5cd98d-gb9xn     0/1       CrashLoopBackOff   4          2m
monitoring-influxdb-67f8d587dd-zqj6p   1/1       Running            0          2m

我们可以看到monitoring-grafana的POD 是没有执行成功的,通过查看日志可以看到下面的错误信息:Failed to parse /etc/grafana/grafana.ini, open /etc/grafana/grafana.ini: no such file or directory。要解决这个问题(heapster issues)我们需要将grafana 的镜像版本更改成:gcr.io/google_containers/heapster-grafana-amd64:v4.0.2,然后重新执行,即可正常。

4、访问 grafana

上面我们修改grafana 的Service 为NodePort 类型:

$ kubectl get svc -n kube-system
NAME                   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE
monitoring-grafana     NodePort    10.254.34.89    <none>        80:32538/TCP    28m

则我们就可以通过任意一个节点加上上面的 32538 端口就可以访问grafana 了。

img

heapster 正确安装后,我们便可以回去看我们的dashboard 是否有图表出现了:

img

推荐文章