到 heapster release 页面 下载最新版本的 heapster
$ wget https://github.com/kubernetes/heapster/archive/v1.3.0.zip
$ unzip v1.3.0.zip
$ mv v1.3.0.zip heapster-1.3.0
$
文件目录: heapster-1.3.0/deploy/kube-config/influxdb
$ cd heapster-1.3.0/deploy/kube-config/influxdb
$ ls *.yaml
grafana-deployment.yaml grafana-service.yaml heapster-deployment.yaml heapster-service.yaml influxdb-deployment.yaml influxdb-service.yaml
已经修改好的 yaml 文件见:heapster
$ diff grafana-deployment.yaml.orig grafana-deployment.yaml
16c16
< image: gcr.io/google_containers/heapster-grafana-amd64:v4.0.2
---
> image: lvanneo/heapster-grafana-amd64:v4.0.2
40,41c40,41
< # value: /api/v1/proxy/namespaces/kube-system/services/monitoring-grafana/
< value: /
---
> value: /api/v1/proxy/namespaces/kube-system/services/monitoring-grafana/
> #value: /
- 如果后续使用 kube-apiserver 或者 kubectl proxy 访问 grafana dashboard,则必须将
GF_SERVER_ROOT_URL
设置为/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana/
,否则后续访问grafana时访问时提示找不到http://10.64.3.7:8086/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana/api/dashboards/home
页面;
$ diff heapster-deployment.yaml.orig heapster-deployment.yaml
16c16
< image: gcr.io/google_containers/heapster-amd64:v1.3.0-beta.1
---
> image: lvanneo/heapster-amd64:v1.3.0-beta.1
$ diff influxdb-deployment.yaml.orig influxdb-deployment.yaml
16c16
< image: gcr.io/google_containers/heapster-influxdb-amd64:v1.1.1
---
> image: lvanneo/heapster-influxdb-amd64:v1.1.1
$ pwd
/root/heapster-1.3.0/deploy/kube-config/influxdb
$ ls *.yaml
grafana-deployment.yaml grafana-service.yaml heapster-deployment.yaml heapster-service.yaml influxdb-deployment.yaml influxdb-service.yaml
$ kubectl create -f .
deployment "monitoring-grafana" created
service "monitoring-grafana" created
deployment "heapster" created
service "heapster" created
deployment "monitoring-influxdb" created
service "monitoring-influxdb" created
检查 Deployment
$ kubectl get deployments -n kube-system | grep -E 'heapster|monitoring'
heapster 1 1 1 1 1m
monitoring-grafana 1 1 1 1 1m
monitoring-influxdb 1 1 1 1 1m
检查 Pods
$ kubectl get pods -n kube-system | grep -E 'heapster|monitoring'
heapster-3273315324-tmxbg 1/1 Running 0 11m
monitoring-grafana-2255110352-94lpn 1/1 Running 0 11m
monitoring-influxdb-884893134-3vb6n 1/1 Running 0 11m
检查 kubernets dashboard 界面,看是显示各 Nodes、Pods 的 CPU、内存、负载等利用率曲线图;
-
通过 kube-apiserver 访问:
获取 monitoring-grafana 服务 URL
$ kubectl cluster-info Kubernetes master is running at http://10.64.3.7:8080 Heapster is running at http://10.64.3.7:8080/api/v1/proxy/namespaces/kube-system/services/heapster KubeDNS is running at http://10.64.3.7:8080/api/v1/proxy/namespaces/kube-system/services/kube-dns kubernetes-dashboard is running at http://10.64.3.7:8080/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard monitoring-grafana is running at http://10.64.3.7:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana monitoring-influxdb is running at http://10.64.3.7:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-influxdb $
浏览器访问 URL:
http://10.64.3.7:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana
-
通过 kubectl proxy 访问:
创建代理
$ kubectl proxy --address='10.64.3.7' --port=8086 --accept-hosts='^*$' Starting to serve on 10.64.3.7:8086
浏览器访问 URL:
http://10.64.3.7:8086/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana