k8s之heapster搭建 - liudd99/k8s GitHub Wiki

部署 heapster

1.下载yaml包:

wget https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/grafana.yaml

wget https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/influxdb.yaml

wget https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/heapster.yaml

wget https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/rbac/heapster-rbac.yaml

#mkdir /root/heapater

把刚下载的4个yaml文件保存该目录下(也可根据需要自己选择路径)。

注:这里已经下载好yaml文件,且已修改yaml文件内容,如果是重新下载则需要参考步骤2,直接引用现有yaml包则可跳过步骤1、2。

2.修改yaml文件

修改heapater.yaml文件,因为 kubelet 启用了 https 所以如下配置需要增加 https 端口

修改前

- --source=kubernetes:https://kubernetes.default

修改后

- --source=kubernetes:https://kubernetes.default?kubeletHttps=true&kubeletPort=10250&insecure=true

3.修改heapater-rbac.yaml文件,将 serviceAccount kube-system:heapster 与 ClusterRole system:kubelet-api-admin 绑定,授予它调用 kubelet API 的权限

metadata:

name: heapster

roleRef:

apiGroup: rbac.authorization.k8s.io

kind: ClusterRole

name: system:heapster

subjects:

- kind: ServiceAccount

name: heapster

namespace: kube-system

---

kind: ClusterRoleBinding

apiVersion: rbac.authorization.k8s.io/v1beta1

metadata:

name: heapster-kubelet-api

roleRef:

apiGroup: rbac.authorization.k8s.io

kind: ClusterRole

name: system:kubelet-api-admin

subjects:

- kind: ServiceAccount

name: heapster

namespace: kube-system

4.部署yaml文件

#kubectl cteate –f /root/heapater

删除清理重新部署

#kubectl delete –f /root/heapater

注:部署完成后在k8s仪表板上可能显示无法pull镜像,这是因为image地址失效,可以网上搜索有效地址更改,或者后期整理好后在私有仓库harbor中pull,harbor仓库地址:(http://10.4.7.153:180)