Kubernetes dashboard集成heapster

图形化展示度量指标的实现需要集成k8s的另外一个Addons组件: Heapster 。

Heapster原生支持K8s(v1.0.6及以后版本)和 CoreOS ,并且支持多种存储后端,比如: InfluxDB 、 ElasticSearch 、 Kafka 。

 

下载源包和images文件

下载地址https://github.com/kubernetes/heapster/archive/v1.2.0.zip,将包copy到kubernetes master节点上去.

打开deploy/kube-config/influxdb目录看到5个部署文件

 

参看这几个 yaml文件,预先把需要pull的image在nodes节点上准备好

docker pull kubernetes/heapster:canary
docker pull kubernetes/heapster_influxdb:v0.5
docker pull gcr.io/google_containers/heapster_grafana:v2.6.0-2

运行创建(master)

然后在master节点上运行

kubectl create -f deploy/kube-config/influxdb/

通过kube get pods -n kube-system发现heapster-zm85m没有运行起来,基于下面命令查看日志

 

kubectl logs -f pods/heapster-zm85m -n kube-system

 

发现错误

 

 编辑heapster-control.yaml文件,把其中source这行替换成本机的api server ip并添加?inClusterConfig=false

删除之前创建的pod重新create一遍.

    spec:
      containers:
      - name: heapster
        image: kubernetes/heapster:canary
        imagePullPolicy: Always
        command:
        - /heapster
        - --source=kubernetes:http://<api server ip>:<port>?inClusterConfig=false
        - --sink=influxdb:http://monitoring-influxdb:8086

最后的yaml文件:
[root@k8s-master influxdb]# cat heapster-controller.yaml 
apiVersion: v1
kind: ReplicationController
metadata:
  labels:
    k8s-app: heapster
    name: heapster
    version: v6
  name: heapster
  namespace: kube-system
spec:
  replicas: 1
  selector:
    k8s-app: heapster
    version: v6
  template:
    metadata:
      labels:
        k8s-app: heapster
        version: v6
    spec:
      containers:
      - name: heapster
        image: kubernetes/heapster:canary
        command:
        - /heapster
        - --source=kubernetes:http://10.182.169.33:8080?inClusterConfig=false
        - --sink=influxdb:http://monitoring-influxdb:8086

 




# kubectl delete  -f deploy/kube-config/influxdb/

# kubectl create -f deploy/kube-config/influxdb/


再次打开kubernetes dashboard,就可以看到获取的监控数据啦

 

 

posted @ 2017-05-12 11:25  ericnie  阅读(1886)  评论(0编辑  收藏  举报